(too old to reply)
[ace-users] ACE_Semaphore::acquire
Spang Oliver
2005-05-23 10:45:13 UTC
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C55F83.52083030
Content-Type: text/plain

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>
**************************************


------_=_NextPart_001_01C55F83.52083030
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2658.24">
<TITLE>ACE_Semaphore::acquire</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; ACE VERSION: =
5.4.5</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; HOST MACHINE and =
OPERATING SYSTEM:</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux, Fedora =
Core 3</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; CONTENTS OF =
$ACE_ROOT/ace/config.h </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">config-linux.h</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; CONTENTS OF =
$ACE_ROOT/include/makeinclude/platform_macros.GNU</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">platform_linux.GNU</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; AREA/CLASS/EXAMPLE =
AFFECTED:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">ACE_Semaphore</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; DOES THE PROBLEM =
AFFECT:</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
EXECUTION</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; SYNOPSIS:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">ACE_Semaphore::acquire immediately returns with -1 and =
errno 0.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; DESCRIPTION:</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">In the following code, the call to acquire immediately =
returns with -1, ACE_OS::last_error returns 0.</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">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.</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">With Redhat 7.3 the code worked well.</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">ACE_Semaphore&nbsp;&nbsp; WaitSemaphore(0);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">int iSema;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">int iErrno;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">ACE_Time_Value ExpireTime =3D ACE_OS::gettimeofday() =
+&nbsp;&nbsp; ACE_Time_Value(20);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">iSema=3DWaitSemaphore.acquire(ExpireTime);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">iErrno=3DACE_OS::last_error();</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">regards,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Oliver</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=3D2 =
FACE=3D"Arial">**************************************</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Oliver Spang</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Siemens AG</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Com SC GMS HD MR</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Werner-von-Siemens-Str. 2-6</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">76642 Bruchsal</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Tel.: +49-7251-73-(6)4273</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Fax: +49-7251-73-3720</FONT>
<BR><A HREF=3D"mailto:***@siemens.com"><U><FONT =
COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">mailto:***@siemens.com</FONT></U></A>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">**************************************</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C55F83.52083030--
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