Mutating Algorithm
Mutating Algorithm

Reputation: 2758

Why is user mode thread handling not acceptable on a multi-core computer?

It is my understanding that threads in user mode are often cheaper to execute and don't require system calls. Why would it not be acceptable on a multi-core machine ?

Upvotes: 1

Views: 138

Answers (1)

displayName
displayName

Reputation: 14379

Threads don't require system calls, but that doesn't mean that they can't make system calls.

There are two fundamental problems with implementing threads in a user mode library:

  • what happens when a system call blocks

If a user-mode thread issues a system call that blocks (e.g. open or read), the process is blocked until that operation completes. This means that when a thread blocks, all threads (within that process) stop executing. Since the threads were implemented in user-mode, the operating system has no knowledge of them, and cannot know that other threads (in that process) might still be runnable.

  • exploiting multi-processors

If the CPU has multiple execution cores, the operating system can schedule processes on each to run in parallel. But if the operating system is not aware that a process is comprised of multiple threads, those threads cannot execute in parallel on the available cores.

Both of these problems are solved if threads are implemented by the operating system rather than by a user-mode thread library.

Taken from here.

Upvotes: 1

Related Questions