Abstract
- Thread managed in the User Space entirely
- The Kernel knows nothing about them
- As far as the kernel is concerned, it is managing single-threaded Process (进程)
- The threads run on top of a Runtime System
- Each process needs its own private Thread Table
- Thread are implemented by a library
When thread becoming blocked locally
- Thread calls Runtime System
- checks to see if the thread must be put into blocked state.
- If so, it stores the thread’s registers (i.e., its own) in the thread table, looks in the table for a ready thread to run
Benefits
Good Compatibility
Great Performance
- Thread switching is at least an order of magnitude faster than trapping to the kernel
- No Trap Interrupt (陷入) is needed
- No Context Switch needed
- the CPU Cache need not be flushed
Great Customisation
- Allow each Process (进程) to have its own customized Process Scheduling Algorithms
Better Scalability
- Kernel Thread require some table space and Stack Segment in the Kernel, which can be a problem if there are a very large number of threads.
Cons
Declined Performance
- The Kernel sees a Process (进程) with multiple user threads as one single Thread
- When the running user thread has a Page Faults, other user threads aren’t scheduled to run
Risk of Thread Hogging
- If an user thread starts running, no other User Thread in that Process (进程) will ever run unless the first thread voluntarily gives up the CPU
- Within a single process, there are no Interrupts (中断), making it impossible to schedule processes round-robin fashion (taking turns)
- The Interrupts (中断) from Runtime System is resource intensive
Programmers generally want threads in applications where the threads block often
Examples
PThread (C)
pthread_yield()
- The Library Call for thread to give CPU to other threads
- In Process (进程), we don’t have this. Because Thread is in the same program, written by the same programmer, so they collaborate to get fulfil a particular feature
Others
Terminologies
Runtime System
- The Thread Scheduler in User Space
Scheduler Activations
- Instead of relying on the Kernel for every thread management decision, the Runtime System is responsible for scheduling Thread
- Mitigates inefficiency from Kernel