|
-
April 20th, 2010, 01:55 AM
#2
Re: User threads versus kernel threads
First of all, user mode "threads" (fibers) are not actually threads in the sense that they do not allow one to utilize parallel hardware. They are useful only as a replacement for explicit state machines and continuations. They are no more than "a syntactic sugar" in the context of parallel hardware.
Then, kernel mode threads do use user-level synchronization w/o kernel calls. pthread_mutex_t, CRITICAL_SECTION are all fast-pathed in user space, not saying about __sync_XXX/_InterlocedXXX functions. Kernel threads do not imply kernel synchronization.
Moreover, provided cooperative user mode scheduling blocked fiber does not have to block the entire underlying thread. Take a look at a Windows 7 UMS (user mode scheduling).
As a bottom line. If you need to utilize parallel hardware you must use kernel threads. User threads is a mean for program structuring and have nothing to do with concurrency.
There is also quite popular nowadays abstraction of tasks, which are basically lightweight user threads. Modern libraries usually use kernel threads for concurrency, and tasks (which run on top of kernel threads) for program structuring.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|