Path: utzoo!utgpu!watmath!watcgl!fjhenigman
From: fjhenig...@watcgl.waterloo.edu (Frank J. Henigman)
Newsgroups: comp.sys.sgi
Subject: Are semaphores initialized?
Keywords: semaphore, ipc
Message-ID: <9893@watcgl.waterloo.edu>
Date: 25 May 89 00:57:24 GMT
Distribution: comp
Organization: U of Waterloo, Ontario
Lines: 6

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)?
-- 
fjhenig...@watcgl.uwaterloo.ca                       Computer Graphics Lab
fjhenig...@watcgl.waterloo.edu   Frank J. Henigman   University of Waterloo
 ...!watmath!watcgl!fjhenigman                       Waterloo, Ontario, Canada

Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!sgi!...@patton.sgi.com
From: j...@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: dae...@sgi.SGI.COM
Distribution: comp
Organization: Silicon Graphics, Inc., Mountain View, CA
Lines: 25

In article <9...@watcgl.waterloo.edu>, fjhenig...@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)?
> -- 
> fjhenig...@watcgl.uwaterloo.ca                       Computer Graphics Lab
> fjhenig...@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!"
j...@sgi.sgi.com, sgi!...@decwrl.dec.com, ...{decwrl,sun}!sgi!jmb

  "I used to be disgusted, now I'm just amused."
			- Elvis Costello, 'Red Shoes'
--