Re: semaphores or spinlocks ?

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

 



Eric BEGOT <eric_begot@yahoo.fr> writes:

> Well i'm writing a little driver and I don't know if i have to use
> semaphores or spinlocks to synchronize it. I know that spinlocks are
> prefered on SMP environment becoz there's no reschedule so no process
> switch.
> I guess that if the blocking time will be long, i have to use a
> semaphore. But on my driver, this time depends on the user operations
> and can vary from seconds to minutes. Well in fact, even a second is
> long for a processor. But you see what i mean i'm sure :)
> By reading the linux source code, i found a lot of spinlocks and few
> (less than spinlocks :) ) semaphores. So spinlocks are really the
> prefered synchronization method ?

The kernel comes with a good general overview of locking methods in
Documentation/DocBook/kernel-locking.tmpl, Rusty Russell's "Unreliable
Guide To Locking".  You can use "make psdocs" to generate that
document in PostScript.

It's also on the web in a few places, including this one:

  http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/

-- 
--Ed L Cashin            |   PGP public key:
  ecashin@uga.edu        |   http://noserose.net/e/pgp/


--
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