semaphores vs locks?
Mark Moraes
moraes at csri.toronto.edu
Wed Sep 6 08:55:11 AEST 1989
On an Iris4d multiprocessor, what is the difference between a semaphore
and a lock? I couldn't find any specific mention of the difference in
the documentation. As far as I can tell, semaphores have queues in
which threads wait till the semaphore is freed, whereas locks are
continuously retried (assuming ussetlock) with some delay.
For a system with hardware locks, which is faster/cheaper - a
semaphore or a lock? Does a lock consume much cpu time while spinning?
Is the cost of going to sleep and awakening on a semaphore high? Does
anyone have any numbers on these?
Is there a section of the manual summarizing the parallel facilities
available? (Suggestion: Perhaps a future release of the documentation
could group manual pages by subsection and alphabetically - i.e. all
manual pages for 3P together, rather than alphabetically across all
subsections) The following is a list I've created, with some attempt
to order them in 'recommended reading order'. Have I missed anything?
usinit, _utrace (3P) - semaphore and lock initialization routine
usconfig (3P) - semaphore and lock configuration operations
taskblock, taskunblock, tasksetblockcnt (3P) - routines to block/unblock tasks
taskcreate (3P) - create a new task
taskdestroy (3P) - destroy a task
taskctl (3P) - operations on a task
barrier, new_barrier, free_barrier (3P) - barrier functions
usnewlock (3P) - allocates and initializes a lock
usinitlock (3P) - initializes a lock
ussetlock, uscsetlock, uswsetlock, ustestlock, usunsetlock (3P) - lock routines
usfreelock (3P) - free a lock
usctllock (3P) - lock control operations
usnewsema (3P) - allocates and initializes a semaphore
usinitsema (3P) - initializes a semaphore
uspsema (3P) - attempt to acquire a semaphore
usvsema (3P) - frees a resource to a semaphore
ustestsema (3P) - return the value of a semaphore
uscpsema (3P) - attempts to acquire a semaphore, and fails if not possible
usfreesema (3P) - free a semaphore
usctlsema (3P) - semaphore control operations
usmalloc, usfree, usrealloc (3P) - user shared memory allocator
acreate, adelete, amalloc, afree, arealloc, acalloc, amallopt, amallinfo (3P) - arbitrary arena main memory allocator
pcreate: pcreatel, pcreatev, pcreateve, pcreatelp, pcreatevp (3P) - create a process
m_fork, m_kill_procs, m_set_procs, m_get_numprocs, m_get_myid, m_next, m_lock, m_unlock, (3P) - parallel programming primitives
sproc (2) - create a new share group process
blockproc, unblockproc, setblockproccnt (2) - routines to block/unblock processes
Thanks.
More information about the Comp.sys.sgi
mailing list