[lug] Semaphore stuff

David Lovering lovering at boulder.nist.gov
Fri Feb 25 18:35:08 MST 2000


----- Original Message -----
From: Hugh Brown <hugh at math.byu.edu>
To: <lug at lug.boulder.co.us>
Sent: Friday, February 25, 2000 6:05 PM
Subject: Re: [lug] Semaphore stuff


> In addition to the original query, can someone explain briefly what a
> semaphore is (with regards to OS's).
>
> Hugh

Without going into a lot of gruesome detail, a semaphore is a flag (usually
stored as a file)
which marks the state of a specific resource (like a physical i/o port) as
being unavailable,
or awaiting input, or whatever.  For example, when a printer is actively
accepting input from a
print server, it is customary for a "lock" file to exist in the print-spool
var directory and linked
by name with the active device.  This precludes its use by another
application, or a simultaneous
print job (if you've got more than one lpd which can access the port).  Once
the job concludes satisfactorily, the lock file is removed and the device is
once again available.

A semaphore can be a flag or variable inside a single program which does the
same sort of
thing, but within a single process.  An EOF semaphore is often used in C++
code to signal when a file or i/o channel has run out of data.  Etc. etc.

-- Dave Lovering





More information about the LUG mailing list