tags: threads thread user-space implementation is_child_of: implementations
Implementing Threads in User space
- Libraries in user space are handling creation and management of threads.
- There is a run-time maintaining a thread table similar to process table managed in kernel space.
- Thread table stores the state of each thread which is used in threads switching.
Advantages over Kernel space
- There is no system call invoked for thread switching leading to performance gain.
- There is no kernel trap.
- Each process can have its own customized scheduling algorithm.
- It is scalable as memory won’t be a problem for threads table when the threads numbers increase.
Disadvantages
- Threads using blocking calls such as for I/O or networking, it blocks the whole process, so blocks all threads.
- This can be avoided using non-blocking calls. However, it would require to change system calls of operating system which is unwanted.
- If a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU.
- If a thread causes page-fault, the kernel naturally blocks the entire process until the respective instructions are fetched from the disk.