Re: preemtive or non-prempteve ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jan Hudec wrote:
> On Fri, Aug 05, 2005 at 19:35:14 +0100, Tristan Wibberley wrote:
> 
>>I wrote:
>>
>>
>>>There is also Ingo Molnar's (and probably others') RT-PREEMPT patches
>>>currenty under development. These really do try to get nearly every
>>>point preemtible. Drivers should synchronise with semaphores, mutexes
>>>(which both do priority inheritance), and completions.
>>
>>I think that's a bit wrong. It doesn't make sense for a semaphore to do
>>priority inheritance as the whole point of a semaphore is that things
>>are supposed to receive notification when something has finished, and
>>the thing that does the notifying does not try to make progress for the
>>waiters. While a mutex identifies a critical section and the
>>process/thread holding the mutex moves out of the way quickly when a
>>high priority thread/process is waiting (essentially starts making rapid
>>progress for the benefit of the waiter, since the waiter has important
>>things to do).
> 
> 
> In kernel there is NO PRIMITIVE CALLED MUTEX. It is a special case of
> semaphore. Thus it is the semaphore that has to do priority inheritance.

In CS, a mutex is *not* a special case of semaphore. A semaphore can
sensibly be started at zero, then be upped to indicate there is
something to process. If a high priority thread tries to down a
semaphore that is at zero, there is no thread that it is waiting for to
get out of the way. A mutex is different, and Ingo's patch adds such a
primitive. I think Ingo's patch has a PI semaphore (the rw-semaphore),
but it is limited to behaving and being used like a rw-mutex and is a
bit of a misnomer. The rw-semaphore no longer permits multiple readers
(to ensure fairness and make PI behave better - and even make sense).

> There are also spin-locks, which are conceptually mutexes, but they
> are special in that they disable preemption -- the real-time patches
> need to reduce the span of these.

I thought the realtime preempt patch made them preemptible, so they'll
spin when the lock is held on another CPU, but if a higher priority
process on the local CPU becomes runnable, the spinner will have to wait.

> Notifications when something is finished are usually sent using
> wait-queues (which are "conditional variables") and completions (which
> are rather similar to semaphores).

I think semaphores use wait queues for their implementation in the
rt-preempt patch. I thought the standard kernel doesn't have
completions, but uses semaphores to approximate them, and that
rt-preempt adds them.

-- 
Tristan Wibberley


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux