[cs631apue] [CS 631] Semaphores
tparisi
tparisi at stevens.edu
Wed Nov 14 20:03:58 EST 2012
Hi,
I am trying to use semaphores in the web server to prevent a file from
being altered by another process when being read by the server. The
current logic of the locking procedure for every request is:
1. create the lock/test for existence
2. lock the file
3. serve the file
4. release the lock
That all works. My main concern is that in class we were shown that
the locks that we create (my understanding is that semaphore lock is
attached to a single file) stay around long after a process terminates,
I would like to destroy the lock when the daemon exits. However, there
is only one semaphore ID in the parent process so I'll only be able to
destroy on such lock right? Right now, I'm of the understanding that
destroying the lock in the child is a poor choice because another forked
child of the parent could be trying to acquire that lock and destroying
it would mess the operations up.
I'm really stumped here so any helpful clues would be just great.
Also, on a side note, are we allowed to use outside code as long as its
cited in someway?
Thanks,
Tom
More information about the cs631apue
mailing list