Why thread is necessary? In which circumstances user-level thread is better than kernel level thread?

Thread is necessary due to the following reasons:
  •   Will by default share memory
  •   Will share file descriptors
  •   Will share file system context
  •   Will share signal handling
    There are two distinct models of thread controls, and they are user-level threads and kernel-level threads. The thread function library to implement user-level threads usually runs on top of the system in user mode. Thus, these threads within a process are invisible to the operating system. User-level threads have extremely low overhead, and can achieve high performance in computation. However, using the blocking system calls like read(), the entire process would block. Also, the scheduling control by the thread runtime system may cause some threads to gain exclusive access to the CPU and prevent other threads from obtaining the CPU. Finally, access to multiple processors is not guaranteed since the operating system is not aware of existence of these types of threads. On the other hand, kernel-level threads will guarantee multiple processor access but the computing performance is lower than user-level threads due to load on the system. The synchronization and sharing resources among threads are still less expensive than multiple- process model, but more expensive than user-level threads. Thus, user-level thread is better than kernel level thread.


Feel free to contact the admin for any suggestions and help.