summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-05 09:30:57 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-05 09:30:57 +0000
commite79938403278841e9ea32d0f5ca6db6db9d1c7de (patch)
tree25921b5c677d49296f8a32183501bdfc989053e3
parent97226f6d7dae1be457d17c91a291baf55235c864 (diff)
downloadATCD-e79938403278841e9ea32d0f5ca6db6db9d1c7de.tar.gz
ChangeLogTag:Thu Apr 05 03:26:13 2001 Nanbor Wang <nanbor@cs.wustl.edu>
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLogs/ChangeLog-02a10
-rw-r--r--ChangeLogs/ChangeLog-03a10
-rw-r--r--examples/Makefile1
-rw-r--r--examples/Synch/Makefile46
-rw-r--r--examples/Synch/README21
-rw-r--r--examples/Synch/Synch.dsw29
-rw-r--r--examples/Synch/proc_sema.cpp95
-rw-r--r--examples/Synch/proc_sema.dsp89
9 files changed, 311 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c092ec4267f..8593c44164d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Apr 05 03:26:13 2001 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * examples/Makefile:
+ * examples/Synch/Makefile:
+ * examples/Synch/README:
+ * examples/Synch/Synch.dsw:
+ * examples/Synch/proc_sema.cpp:
+ * examples/Synch/proc_sema.dsp: Added a new explame to play with
+ process semaphores.
+
Thu Apr 05 02:48:51 2001 Nanbor Wang <nanbor@cs.wustl.edu>
* ace/MEM_IO.cpp (write): My earlier change was causing the test
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index c092ec4267f..8593c44164d 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,13 @@
+Thu Apr 05 03:26:13 2001 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * examples/Makefile:
+ * examples/Synch/Makefile:
+ * examples/Synch/README:
+ * examples/Synch/Synch.dsw:
+ * examples/Synch/proc_sema.cpp:
+ * examples/Synch/proc_sema.dsp: Added a new explame to play with
+ process semaphores.
+
Thu Apr 05 02:48:51 2001 Nanbor Wang <nanbor@cs.wustl.edu>
* ace/MEM_IO.cpp (write): My earlier change was causing the test
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index c092ec4267f..8593c44164d 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,13 @@
+Thu Apr 05 03:26:13 2001 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * examples/Makefile:
+ * examples/Synch/Makefile:
+ * examples/Synch/README:
+ * examples/Synch/Synch.dsw:
+ * examples/Synch/proc_sema.cpp:
+ * examples/Synch/proc_sema.dsp: Added a new explame to play with
+ process semaphores.
+
Thu Apr 05 02:48:51 2001 Nanbor Wang <nanbor@cs.wustl.edu>
* ace/MEM_IO.cpp (write): My earlier change was causing the test
diff --git a/examples/Makefile b/examples/Makefile
index b55c5c1f4ad..df8a15f2088 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -25,6 +25,7 @@ DIRS = ASX \
Shared_Malloc \
Shared_Memory \
System_V_IPC \
+ Synch \
Threads \
Timer_Queue
diff --git a/examples/Synch/Makefile b/examples/Synch/Makefile
new file mode 100644
index 00000000000..bbddc67f5cb
--- /dev/null
+++ b/examples/Synch/Makefile
@@ -0,0 +1,46 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Makefile for repeating token client application
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+BIN = proc_sema
+
+FILES = proc_sema
+
+LSRC = $(addsuffix .cpp,$(FILES))
+LOBJ = $(LSRC:%.cpp=$(VDIR)%.o)
+SHOBJ = $(addsuffix .so,$(FILES))
+
+BUILD = $(VBIN)
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/examples/Synch/README b/examples/Synch/README
new file mode 100644
index 00000000000..51dd14ce4ae
--- /dev/null
+++ b/examples/Synch/README
@@ -0,0 +1,21 @@
+This directory currently only contains one example for testing process
+semaphores.
+
+proc_sema:
+ This test can be used to test out the named process semaphores
+support on your platform. It can be run as either a supplier or a
+consumer process. The available options are:
+
+ -c: Make us a consumer.
+ -s: Make us a supplier.
+ -x: Remove the semaphore after we're done.
+ -n: Specify the name of the semaphore.
+ -i: Number of acquire/release we'll perform.
+ -d: Delay for # of second before exiting the program
+
+ You can use this test to see how process semaphores work. For
+example, run the program as:
+
+ proc_sema -c -n 10
+ proc_sema -s -n 3
+ proc_sema -s -n 7
diff --git a/examples/Synch/Synch.dsw b/examples/Synch/Synch.dsw
new file mode 100644
index 00000000000..c305fe87d2e
--- /dev/null
+++ b/examples/Synch/Synch.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "proc_sema"=.\proc_sema.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/examples/Synch/proc_sema.cpp b/examples/Synch/proc_sema.cpp
new file mode 100644
index 00000000000..db925f8c15b
--- /dev/null
+++ b/examples/Synch/proc_sema.cpp
@@ -0,0 +1,95 @@
+/// $Id$
+
+#include "ace/Process_Semaphore.h"
+#include "ace/Synch_T.h"
+#include "ace/Get_Opt.h"
+
+int producer (ACE_SYNCH_PROCESS_SEMAPHORE &sema,
+ int iter)
+{
+ for (int i = iter; i > 0; --i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Try acquiring the semaphore (%d): ",
+ i));
+
+ int result = sema.release ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%s",
+ (result != 0 ? "fail\n" : "succeed\n")));
+ }
+ return 0;
+}
+
+int consumer (ACE_SYNCH_PROCESS_SEMAPHORE &sema,
+ int iter)
+{
+ for (int i = iter; i > 0; --i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Try acquiring the semaphore (%d): ",
+ i));
+
+ int result = sema.acquire ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ "%s",
+ (result != 0 ? "fail\n" : "succeed\n")));
+ }
+ return 0;
+}
+
+
+int main (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt getopt (argc, argv, "csn:xi:d:");
+
+ int is_consumer = 1; // By default, make us a consumer.
+ int delete_sema = 0;
+ int iteration = 0;
+ int exit_delay = 0;
+ ACE_TCHAR *sema_name = ACE_TEXT ("Process_Semaphore_Test");
+
+ int opt;
+
+ while ((opt = getopt ()) != -1)
+ {
+ switch (opt)
+ {
+ case 'c': // Make us a consumer.
+ is_consumer = 1;
+ break;
+ case 's': // Make us a supplier.
+ is_consumer = 0;
+ break;
+ case 'x': // Remove the semaphore after we're done.
+ delete_sema = 1;
+ break;
+ case 'n': // Specify the name of the semaphore.
+ sema_name = getopt.optarg;
+ break;
+ case 'i': // Number of acquire/release we'll perform.
+ iteration = ACE_OS::atoi (getopt.optarg);
+ break;
+ case 'd':
+ exit_delay = ACE_OS::atoi (getopt.optarg);
+ break;
+ default:
+ return -1;
+ }
+ };
+
+ ACE_SYNCH_PROCESS_SEMAPHORE sema (0, sema_name);
+
+ if (is_consumer != 0)
+ consumer (sema, iteration);
+ else
+ producer (sema, iteration);
+
+ ACE_OS::sleep (exit_delay);
+
+ if (delete_sema != 0)
+ sema.remove ();
+ return 0;
+}
diff --git a/examples/Synch/proc_sema.dsp b/examples/Synch/proc_sema.dsp
new file mode 100644
index 00000000000..13d6647a9b2
--- /dev/null
+++ b/examples/Synch/proc_sema.dsp
@@ -0,0 +1,89 @@
+# Microsoft Developer Studio Project File - Name="proc_sema" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=proc_sema - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "proc_sema.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "proc_sema.mak" CFG="proc_sema - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "proc_sema - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "proc_sema - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "proc_sema - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "proc_sema - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ace"
+
+!ENDIF
+
+# Begin Target
+
+# Name "proc_sema - Win32 Release"
+# Name "proc_sema - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\proc_sema.cpp
+# End Source File
+# End Target
+# End Project