Wednesday, October 2, 2013

Threads vs Process on Linux

See the following links:

Thread has its own stack, its own register set/context. User space threads or kernel space threads?
The context of a thread is the register set, including the stack pointer.
Context switch between threads includes saving registers, restore registers only, while MMU context(Page table) & TLB stays.

Process has its own virtual address space, and has at least one thread; all threads within it share the parent process's virtual address space.
The context of a process includes state, priority, signal info, process id, and a pointer to thread.
Context switch between processes needs a switch of virtual address space, including cache and TLB flushing, MMU context switching, and thread switching.

Both thread and process 's creation in user space went to the same system call(clone) in the kernel.
Linux implements 1:1 model.
Keep in mind, TLB and MMU context is per-CPU on Linux.

No comments:

Post a Comment