summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-30 18:19:04 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-30 18:19:04 +0000
commita7e6132e33fd2f700e1f060a3e2fa0e6f0de3ac9 (patch)
tree72717d8d4e790014e4a566787b456547c92b1645 /tests
parent2ec1332afd6253900edf3e52e4ef10826e2fbe49 (diff)
downloadATCD-a7e6132e33fd2f700e1f060a3e2fa0e6f0de3ac9.tar.gz
.
Diffstat (limited to 'tests')
-rw-r--r--tests/SV_Shared_Memory_Test.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp
index 5186d3274f1..973f24a72c3 100644
--- a/tests/SV_Shared_Memory_Test.cpp
+++ b/tests/SV_Shared_Memory_Test.cpp
@@ -52,13 +52,18 @@ parent (char *shm)
{
ACE_SV_Semaphore_Complex mutex;
+ // This semaphore is initially created with a count of 0, i.e., it
+ // is "locked."
ACE_ASSERT (mutex.open (SEM_KEY_1,
ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1);
ACE_SV_Semaphore_Complex synch;
+ // This semaphore is initially created with a count of 0, i.e., it
+ // is "locked."
ACE_ASSERT (synch.open (SEM_KEY_2,
ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1);
+ // This for loop executes in a critical section proteced by <mutex>.
for (int i = 0; i < SHMSZ; i++)
shm[i] = SHMDATA[i];
@@ -80,14 +85,21 @@ static int
child (char *shm)
{
ACE_SV_Semaphore_Complex mutex;
+ // This semaphore is initially created with a count of 0, i.e., it
+ // is "locked."
ACE_ASSERT (mutex.open (SEM_KEY_1,
ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1);
ACE_SV_Semaphore_Complex synch;
-
+ // This semaphore is initially created with a count of 0, i.e., it
+ // is "locked."
ACE_ASSERT (synch.open (SEM_KEY_2,
ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1);
+ // Perform "busy waiting" here until we acquire the semaphore. This
+ // isn't really a good design -- it's just to illustrate that you
+ // can do non-blocking acquire() calls with the ACE System V
+ // semaphore wrappers.
while (mutex.tryacquire () == -1)
if (errno == EAGAIN)
ACE_DEBUG ((LM_DEBUG, "(%P) spinning in child!\n"));
@@ -113,10 +125,7 @@ template class ACE_Read_Guard<ACE_SV_Semaphore_Simple>;
#pragma instantiate ACE_Write_Guard<ACE_SV_Semaphore_Simple>
#pragma instantiate ACE_Read_Guard<ACE_SV_Semaphore_Simple>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-
-
#endif /* ACE_HAS_SYSV_IPC */
-
int
main (int, char *[])
{