summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-09-18 17:41:22 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-09-18 17:41:22 +0000
commit3807d41351b612aa36fc3afba43cf8244b4f2a65 (patch)
tree5dddd795f67f33fe588abc44064f4dc46907ff27
parentcd826fa9741a14a7001caeb2650395af17181d6a (diff)
downloadATCD-3807d41351b612aa36fc3afba43cf8244b4f2a65.tar.gz
*** empty log message ***
-rw-r--r--ChangeLog-97b32
-rw-r--r--ace/Synch.h3
-rw-r--r--tests/Semaphore_Test.cpp27
3 files changed, 40 insertions, 22 deletions
diff --git a/ChangeLog-97b b/ChangeLog-97b
index d8908de96e8..241791a3623 100644
--- a/ChangeLog-97b
+++ b/ChangeLog-97b
@@ -1,3 +1,22 @@
+Thu Sep 18 12:24:08 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
+
+ * tests/Semaphore_Test.cpp: Updated the test to use a temporary
+ ACE_Time_Value variable that is passed to
+ ACE_Semaphore::acquire() so that we don't have problems with
+ reference anachronisms... Thanks to David Levine for reporting
+ this.
+
+ * ace/Log_Msg.cpp: Changed over to using ACE_SPIPEs for the
+ logging mechanism rather than ACE_FIFOs to conform to the
+ changes to Client_Logging_Handler.
+
+ * netsvcs/lib/Client_Logging_Handler.cpp:
+ Completely rewrote the Client Logging Daemon so that it uses
+ ACE_SPIPEs by default, rather than ACE_FIFOs. This is more
+ portable and makes it easier to write a generic client logging
+ daemon... If a platform doesn't support ACE_SPIPEs, then we
+ revert to using sockets.
+
Thu Sep 18 09:04:40 1997 <irfan@TWOSTEP>
* ace/Dynamic: Changed the way ACE_Dynamic worked. Instead of
@@ -13,19 +32,6 @@ Thu Sep 18 01:12:36 1997 Douglas C. Schmidt <schmidt@cs.wustl.edu>
* ACE version 4.3.8, released Thu Sep 18 01:12:36 1997.
-Thu Sep 18 00:21:33 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-
- * ace/Log_Msg.cpp: Changed over to using ACE_SPIPEs for the
- logging mechanism rather than ACE_FIFOs to conform to the
- changes to Client_Logging_Handler.
-
- * netsvcs/lib/Client_Logging_Handler.cpp:
- Completely rewrote the Client Logging Daemon so that it uses
- ACE_SPIPEs by default, rather than ACE_FIFOs. This is more
- portable and makes it easier to write a generic client logging
- daemon... If a platform doesn't support ACE_SPIPEs, then we
- revert to using sockets.
-
Wed Sep 17 22:47:20 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
* ace/ACE: Added two new varargs methods for send() and recv().
diff --git a/ace/Synch.h b/ace/Synch.h
index 9b56bb8e5f3..b340c59db96 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -186,6 +186,9 @@ public:
int acquire (ACE_Time_Value &tv);
// Block the thread until <tv> times out or until the semaphore
// count becomes greater than 0 (at which point it is decremented).
+ // The value of <tv> is updated upon return, i.e., the caller gets
+ // the amount of time that has elapsed while waiting to acquire the
+ // semaphore.
int tryacquire (void);
// Conditionally decrement the semaphore if count is greater than 0
diff --git a/tests/Semaphore_Test.cpp b/tests/Semaphore_Test.cpp
index 81ee015fdb2..6884a81b9fb 100644
--- a/tests/Semaphore_Test.cpp
+++ b/tests/Semaphore_Test.cpp
@@ -32,10 +32,16 @@ static ACE_Thread_Semaphore s (0);
// Default number of iterations.
static size_t n_iterations = 10;
+// Number of worker threads.
static size_t n_workers = 10;
-static size_t n_semcount = 3;
+// Amount to release the semaphore.
+static size_t n_release_count = 3;
+// Number of times to call test_timeout().
+static size_t test_timeout_count;
+
+// Number of timeouts.
static size_t timeouts = 0;
// Explain usage and exit.
@@ -43,7 +49,7 @@ static void
print_usage_and_die (void)
{
ACE_DEBUG ((LM_DEBUG,
- "usage: %n [-s n_semcount] [-w n_workers] [-n iteration_count]\n"));
+ "usage: %n [-s n_release_count] [-w n_workers] [-n iteration_count]\n"));
ACE_OS::exit (1);
}
@@ -58,7 +64,7 @@ parse_args (int argc, char *argv[])
switch (c)
{
case 's':
- n_semcount = ACE_OS::atoi (get_opt.optarg);
+ n_release_count = ACE_OS::atoi (get_opt.optarg);
break;
case 'w':
n_workers = ACE_OS::atoi (get_opt.optarg);
@@ -72,7 +78,7 @@ parse_args (int argc, char *argv[])
}
}
-
+#if !defined (ACE_HAS_STHREADS)
// Tests the amount of time spent in a timed wait.
static int
@@ -110,7 +116,9 @@ worker (void *)
iterations <= n_iterations;
iterations++)
{
- if (s.acquire (ACE_Time_Value (0, (ACE_OS::rand () % 1000) * 1000)))
+ ACE_Time_Value tv (0, (ACE_OS::rand () % 1000) * 1000);
+
+ if (s.acquire (tv))
++timeouts;
else
{
@@ -125,6 +133,7 @@ worker (void *)
return 0;
}
+#endif /* !ACE_HAS_STHREADS */
#endif /* ACE_HAS_THREADS */
// Test semaphore functionality
@@ -136,14 +145,14 @@ int main (int argc, char *argv[])
#if defined (ACE_HAS_THREADS)
parse_args (argc, argv);
ACE_OS::srand (ACE_OS::time (0L));
-#if !defined (ACE_HAS_STHREADS)
+#if !defined (ACE_HAS_STHREADS)
// Test timed waits.
- for (size_t i = 0; i < 5; i++)
+ for (size_t i = 0; i < test_timeout_count; i++)
test_timeout ();
- // Initialize the semaphore to a certain number.
- s.release (n_semcount);
+ // Release the semaphore a certain number of times.
+ s.release (n_release_count);
if (ACE_Thread_Manager::instance ()->spawn_n
(n_workers, ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1)