Re: temporary disable thread switching using pthreads
- From: Marcel Müller <news.5.maazl@xxxxxxxxxxxxxxx>
- Date: Tue, 23 May 2006 22:39:22 +0200
Joe Seigh wrote:
On single CPU machines this is much faster than anything else, because all other threads are obviously not running. There is only a flag for each process to be set, which prevents the scheduler from scheduling other threads of the same process. You do not even need a mutex to protect this flag. No thread is ever descheduled because of the synchronization. The overhead is nearly zero.
The flag has to be examined and set with a single instruction so it
doesn't get interrupted. Something like INC or XCHG.
No. A single atomic write instruction is sufficient, since the field might not be set by another thread due to the fact that your thread is running.
Also there
isn't the need for an extra test in the dispatcher code path, probably
one of the most performance sensitive pathes around.
That's true. Nevertheless OS/2's UNI-CPU dispatcher is well known to be one of the fastest dispatchers on x86 platforms, faster than Linux and faster than WinNT ff. anyway.
[with SMP]
> Probably the
implementation would be to suspend the calling thread, mark the other
threads unrunnable, wait for them to all stop running, and resume the
calling thread. Hardly very efficient.
Most likely it is done this way. But it is not open source. So I am only guessing about this fact. (Or we have to ask Scott from IBM.)
Marcel
.
- Follow-Ups:
- Re: temporary disable thread switching using pthreads
- From: Martin James
- Re: temporary disable thread switching using pthreads
- References:
- temporary disable thread switching using pthreads
- From: Marcel Müller
- Re: temporary disable thread switching using pthreads
- From: David Hopwood
- Re: temporary disable thread switching using pthreads
- From: Marcel Müller
- Re: temporary disable thread switching using pthreads
- From: Joe Seigh
- Re: temporary disable thread switching using pthreads
- From: Marcel Müller
- Re: temporary disable thread switching using pthreads
- From: Joe Seigh
- temporary disable thread switching using pthreads
- Prev by Date: Re: temporary disable thread switching using pthreads
- Next by Date: Re: temporary disable thread switching using pthreads
- Previous by thread: Re: temporary disable thread switching using pthreads
- Next by thread: Re: temporary disable thread switching using pthreads
- Index(es):
Relevant Pages
|