Search code examples
assemblycomputer-sciencecpu-architecturelow-level

What happens to data stored in registers and on stack when OS switches to other tasks?


I've been getting a bit interested in low level programming in the last couple of weeks. I wonder what happens to the data stored in proc registers, when the OS "decides" to switch to another task. Where is it stored?


Solution

  • "Where" heavily depends on underlying hardware architecture, but usually it's in main memory (RAM). For example Intel architecture has "protected mode" (available on 268+ processors) that offers hardware-level tools to handle multi-tasking; for example the task state segment (which is a main memory segment) that holds CPU registers, among other data for this task.