Pthread spin locks

Peter Holmes peter_holmes2003 at yahoo.com
Mon Mar 19 17:59:09 UTC 2007


I have a related question - it would be great if someone could help me. Let's say there are multiple system scope pthreads running on  an SMP  system. Is there a chance that if a pthread holding a spinlock is scheduled out (due to a scheduling decision etc.) then other pthreads will be starved. Is there anything the system provides to guard against pthread starvation.
   
  Thanks,
  Peter

Peter Holmes <peter_holmes2003 at yahoo.com> wrote:
  I am not very sure about the spin lock behavior of pthreads.

Here is the man page description:
The pthread_spin_lock() function will acquire lock if it is not currently
owned by another thread. If the lock cannot be acquired immediately, it
will spin attempting to acquire the lock (it will not sleep) until it
becomes available.

For a single processor scenario.
Let's say a pthread owns the lock and is blocked and now another thread tries to acquire it. Will the second thread not block until the first thread releases the lock.


- Peter


---------------------------------
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.
_______________________________________________
freebsd-hackers at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"


 
---------------------------------
Sucker-punch spam with award-winning protection.
 Try the free Yahoo! Mail Beta.


More information about the freebsd-hackers mailing list