tags: threads thread user-space implementation is_child_of: implementations

Implementing Threads in User space

  1. Libraries in user space are handling creation and management of threads.
  2. There is a run-time maintaining a thread table similar to process table managed in kernel space.
  3. Thread table stores the state of each thread which is used in threads switching.

Advantages over Kernel space

  1. There is no system call invoked for thread switching leading to performance gain.
  2. There is no kernel trap.
  3. Each process can have its own customized scheduling algorithm.
  4. It is scalable as memory won’t be a problem for threads table when the threads numbers increase.

Disadvantages

  1. Threads using blocking calls such as for I/O or networking, it blocks the whole process, so blocks all threads.
  2. This can be avoided using non-blocking calls. However, it would require to change system calls of operating system which is unwanted.
  3. If a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU.
  4. If a thread causes page-fault, the kernel naturally blocks the entire process until the respective instructions are fetched from the disk.