1. A system to allocate memory to tasks executed by a device, comprising: a memory of the device defining a stack; a stack head pointer to indicate locations in the memory; and an operating system configured to: determine a size of the stack used by the tasks; assign portions of the stack to individual tasks; organize data elements corresponding to register contents of the device in the portions of the stack; set the stack head pointer to specify a top position in the stack of an executing task; save the register contents used by an executing task in the stack; and modify the stack head pointer when a context switch of the tasks occurs.