km@hpfclj.UUCP (11/06/83)
#N:hpfclj:19800001:000:545 hpfclj!km Nov 4 14:09:00 1983 I have just begun to look at System V semaphores. Needless to say, the Bell documentation leaves much to be desired, and we do not have System V up and running. Can anyone help me with the following: * What's the benefit to such a complex data structure? Does it solve some special problems elegantly? What's the performance? * Examples: dining philosophers, consumer-producer, etc.? * What is SEM_UNDO all about? Any comments or references to published literature would be appreciated. Thanks. Ken Martin hpfcla!km
abs@fortune.UUCP (Andrea Salzman) (11/11/83)
Regarding the question of System V semaphores, I have a bit of knowledge to share. I do not know System V semaphores specifically, however, I hope I can shed some light about semaphores in general. The word 'semaphore', in my dictionary is defined as, "any visual signaling apparatus with flags, lights, or mechanically moving arms". For instance, a semaphore is used in train stations to signal a train to go to the left or to the right track. The semaphore is the lighting, flags or raising/lowering of a track device to allow or deny a train from proceeding in a direction. A software semaphore works similarly. The software semaphore acts as a signaling device to asynchronous concurrent processes wishing to access the same set of data. If two processes were allowed to access (modify) one common set of data simultaneously, each would believe that the data was in one state when in reality the data had been changed by another accessing process. The results would be unpredictable at best. In order to prevent the ensuing chaos of simultaneous access of critical (common) data, semaphores are used to signal when a process is accessing critical data sections. The semaphore says, "there is already someone here; one at a time". Other processes are blocked entrance to the critical section and may proceed only when the critical section is clear as relayed by the semaphore. This signal/wait algorithm serves to protect the integrity of data for all accessing processes. Software semaphores then do, indeed, parallel their railway counterparts in signaling and directing traffic flow. Software semaphores are used extensively in operating system design specifically for data protecting and in solving the problems involved with mutual exclusion and deadlock. The dining philosopher and producer-consumer problems are excellent examples of semaphore application. An excellent reference and text which is informative, complete, technical and yet easy to read and understand is, "An Introduction to Operating Systems" (sorry no underline) by H. M. Deitel; Addison-Wesley Publishing Co., 1983. I highly recommend it! Further discussion of the dining philosopher problem and the producer- consumer problem are on pages 112 and 109, respectively. I hope this information is helpful. Just an overview, though. Andi Salzman