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

RE: semaphore and spin locks





> A spin lock is a primitive mechanism to prevent two or more processes
> accessing a certain data structure at the same time. The lock is an
> integer that's initially set to 0. A process which wants to enter the
> critical area has to set the lock to 1 using an atomic "if 0 then set
> 1"-operation. If the lock is in use, the process has to busy-wait,
> spinning in a tight loop. ==> CPU-time-consuming if you have to wait
> long, but very efficient if you don't have to wait.

Since a process has to busy wait on spin-lock, what if 2 or more processes
get stuck on the same spin lock, which process will be allowed to enter the
critical region..??

atul


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/