Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!sgi!jmb@patton.sgi.com From: jmb@patton.sgi.com (Jim Barton) Newsgroups: comp.sys.sgi Subject: Re: Are semaphores initialized? Summary: No. Keywords: semaphore, ipc Message-ID: <33648@sgi.SGI.COM> Date: 25 May 89 22:16:07 GMT References: <9893@watcgl.waterloo.edu> Sender: daemon@sgi.SGI.COM Distribution: comp Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 25 In article <9893@watcgl.waterloo.edu>, fjhenigman@watcgl.waterloo.edu (Frank J. Henigman) writes: > Can someone from SGI answer this? I scoured the documentation with no luck. > Are semaphores created with semget(2) initialized to some value (like zero)? > -- > fjhenigman@watcgl.uwaterloo.ca Computer Graphics Lab > fjhenigman@watcgl.waterloo.edu Frank J. Henigman University of Waterloo > ...!watmath!watcgl!fjhenigman Waterloo, Ontario, Canada I perused sem.c (the semaphore code) and it appears that semaphores are not initialized each time they are allocated. The kernel uses a static area for the semaphores (thus those wonderful SEM* constants in master.d/kernel) and a chunk of them is allocated for each semget with no initialization. One could argue (rightly) that this is a bug (especially for a secure system), but this is what AT&T ships us. I'll turn in a bug report locally, so we remember to set them to something like zero. If you wish to write portable code, however, you should always assume that they are not initialized. -- Jim Barton Silicon Graphics Computer Systems "UNIX: Live Free Or Die!" jmb@sgi.sgi.com, sgi!jmb@decwrl.dec.com, ...{decwrl,sun}!sgi!jmb "I used to be disgusted, now I'm just amused." - Elvis Costello, 'Red Shoes' --