Discussion:
[ace-users] ACE_Semaphore::acquire
(too old to reply)
Spang Oliver
2005-05-23 10:45:12 UTC
ACE VERSION: 5.4.5

HOST MACHINE and OPERATING SYSTEM:
Linux, Fedora Core 3

CONTENTS OF $ACE_ROOT/ace/config.h
config-linux.h

CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU
platform_linux.GNU

AREA/CLASS/EXAMPLE AFFECTED:
ACE_Semaphore

DOES THE PROBLEM AFFECT:
EXECUTION

SYNOPSIS:
ACE_Semaphore::acquire immediately returns with -1 and errno 0.

DESCRIPTION:
In the following code, the call to acquire immediately returns with -1, ACE_OS::last_error returns 0.
Debugging the code makes me think that the call to pthread_mutex_lock doesn't work as it should, but I've no idea why.
With Redhat 7.3 the code worked well.

ACE_Semaphore WaitSemaphore(0);
int iSema;
int iErrno;
ACE_Time_Value ExpireTime = ACE_OS::gettimeofday() + ACE_Time_Value(20);
iSema=WaitSemaphore.acquire(ExpireTime);
iErrno=ACE_OS::last_error();

regards,
Oliver



**************************************
Oliver Spang
Siemens AG
Com SC GMS HD MR
Werner-von-Siemens-Str. 2-6
76642 Bruchsal
Tel.: +49-7251-73-(6)4273
Fax: +49-7251-73-3720
mailto:***@siemens.com <mailto:***@siemens.com>
**************************************
Douglas C. Schmidt
2005-05-23 11:52:59 UTC
Hi Oliver,

Thanks for using the PRF.
Post by Spang Oliver
ACE VERSION: 5.4.5
Linux, Fedora Core 3
CONTENTS OF $ACE_ROOT/ace/config.h
config-linux.h
CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU
platform_linux.GNU
ACE_Semaphore
EXECUTION
ACE_Semaphore::acquire immediately returns with -1 and errno 0.
In the following code, the call to acquire immediately returns with -1, ACE_OS::last_error returns 0.
Debugging the code makes me think that the call to pthread_mutex_lock doesn't work as it should, but I've no idea why.
With Redhat 7.3 the code worked well.
ACE_Semaphore WaitSemaphore(0);
int iSema;
int iErrno;
ACE_Time_Value ExpireTime = ACE_OS::gettimeofday() + ACE_Time_Value(20);
iSema=WaitSemaphore.acquire(ExpireTime);
iErrno=ACE_OS::last_error();
If you check errno you'll probably see that it's set to ENOTSUP, which
means that by default timed waits on a semaphore aren't supported on
Linux.

Take care,

Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Institute for Software Integrated Systems WEB: www.dre.vanderbilt.edu/~schmidt
Vanderbilt University, Nashville TN, 37203 NET: ***@vanderbilt.edu