This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Re: Bug in sem_getvalue


The sem_getvalue() function shall update the location referenced
by the sval argument to have the value of the semaphore
referenced by sem without affecting the state of the semaphore.
The updated value represents an actual semaphore value that
occurred at some unspecified time during the call, but it need
not be the actual value of the semaphore when it is returned to
the calling process.
If sem is locked, then the value returned by sem_getvalue() is
either zero or a negative number whose absolute value represents
the number of processes waiting for the semaphore at some
unspecified time during the call.
RETURN VALUE
Upon successful completion, the sem_getvalue() function shall
return a value of zero. Otherwise, it shall return a value of -1
and set errno to indicate the error.
since there is only one (1) process in eCos (only threads), does
this mean that no matter how many threads are waiting on the
semaphore that the value returned in the sval argument will be
never be <-1 (e.g., -2, -3,...)? 

apologize if the format is messed up somewhat.

Tom Woller
Cirrus Logic Corp
tom.woller@cirrus.com

 -----Original Message-----
From: 	Jonathan Larmour [mailto:jlarmour@redhat.com] 
Sent:	Monday, April 08, 2002 12:38 PM
To:	jyl087@netscape.net
Cc:	eCos discussion
Subject:	[ECOS] Re: Bug in sem_getvalue

jyl087@netscape.net wrote:
> 
> In "sem.cxx" ...
> 
> I don't know what POSIX says about sem_getvalue, but at least
my
> RH7.2 manpage on sem_getvalue says that:
> 
>   sem_getvalue should always return 0.
>   *sval = retval;

There is indeed a mistake in sem_getvalue, although the man page
is also
strictly incorrect with respect to the standard (although it may
be correct
with respect to the Linux implementation). According to my spec:

"If sem is locked, then the value returned by sem_getvalue()
shall be
either zero or a negative number whose absolute value represents
the number
of processes waiting for the semaphore at some unspecified time
during the
call."

Anyway, I've fixed this for the future. Thanks for the report.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44
(1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley ||
Opinions==mine

-- 
Before posting, please read the FAQ:
http://sources.redhat.com/fom/ecos
and search the list archive:
http://sources.redhat.com/ml/ecos-discuss

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]