Linux multi-threading
Software multi-threading facilitates concurrency in applications; this is of particular importance to applications that may have blocking calls like I/O. The advantage of user-level multi-threading over multiple processes is that it allows for switching of tasks without incurring a kernel level context switch; one thread can switch to another without having to make a kernel level call. This is especially important to servers that must be able to handle multiple requests at any given time. The disadvantage is, if the OS is single threaded, a thread makes a system call, then all other threads from that process must wait until the system call finishes because the process scheduling happens at the process level; the kernel doesn't see the individual user-level threads.
Kernel-level threading mitigates this problem because the kernel is aware of each thread an threats them as separate processes as far as scheduling is concerned. But, kernel-level threads will cause scheduling bias towards the processes that have more threads. A process with 100 threads will get 100 times more scheduling time, on average, then a process with one thread.
The threads of a multi-threaded application all share the same memory so care must be taken to avoid memory corruption and access to resources thus requiring semaphores and mutexs. One multi-threaded process uses fewer resources than multiple redundant processes including memory, open files and CPU scheduling.
Pascal Aschwanden
Kernel-level threading mitigates this problem because the kernel is aware of each thread an threats them as separate processes as far as scheduling is concerned. But, kernel-level threads will cause scheduling bias towards the processes that have more threads. A process with 100 threads will get 100 times more scheduling time, on average, then a process with one thread.
The threads of a multi-threaded application all share the same memory so care must be taken to avoid memory corruption and access to resources thus requiring semaphores and mutexs. One multi-threaded process uses fewer resources than multiple redundant processes including memory, open files and CPU scheduling.
Pascal Aschwanden

0 Comments:
Post a Comment
<< Home