diff options
Diffstat (limited to 'netsvcs/clients/Tokens/collection')
-rw-r--r-- | netsvcs/clients/Tokens/collection/Makefile | 131 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/README | 25 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/collection.cpp | 210 | ||||
-rw-r--r-- | netsvcs/clients/Tokens/collection/rw_locks.cpp | 173 |
4 files changed, 0 insertions, 539 deletions
diff --git a/netsvcs/clients/Tokens/collection/Makefile b/netsvcs/clients/Tokens/collection/Makefile deleted file mode 100644 index 571971acec3..00000000000 --- a/netsvcs/clients/Tokens/collection/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -#---------------------------------------------------------------------------- -# $Id: Makefile 1.1 10/18/96 -# -# Makefile for repeating token client application -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = collection - -FILES = collection - -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.lib.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. - -.obj/collection.o .obj/collection.so .shobj/collection.o .shobj/collection.so: collection.cpp \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/inc_user_config.h \ - $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/Get_Opt.i \ - $(ACE_ROOT)/ace/Local_Tokens.h \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Local_Tokens.i \ - $(ACE_ROOT)/ace/Token_Collection.h \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Token_Collection.i \ - $(ACE_ROOT)/ace/Remote_Tokens.h \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Token_Request_Reply.h \ - $(ACE_ROOT)/ace/Token_Request_Reply.i \ - $(ACE_ROOT)/ace/Remote_Tokens.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/netsvcs/clients/Tokens/collection/README b/netsvcs/clients/Tokens/collection/README deleted file mode 100644 index 4c25a1f729e..00000000000 --- a/netsvcs/clients/Tokens/collection/README +++ /dev/null @@ -1,25 +0,0 @@ - -Shows how applications can use the ACE_Token_Collection utility. This -example creates three collections and spawns a thread to operate on -each. The threads use the collective acquire, renew, and release -features of ACE_Token_Collection. - -Here are the command-line parameters for collection: - -./collection: -[-h <remote host>] -[-p <remote port>] -[-n <iterations>] -[-d debug] - -To run the collection locally with debugging info, type - -% ./collection -d - -To run the collection remotely with debugging info, first start a -token server and the type: - -% ./collection -d -h <token-server-host> -p <token-server-port> - -The -n <iterations> option is to control how often each thread -iterates on the acquire, renew, release cycle. diff --git a/netsvcs/clients/Tokens/collection/collection.cpp b/netsvcs/clients/Tokens/collection/collection.cpp deleted file mode 100644 index 44e0b0a2bbd..00000000000 --- a/netsvcs/clients/Tokens/collection/collection.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// ============================================================================ -// $Id$ - -// -// = LIBRARY -// examples -// -// = FILENAME -// collection.cpp -// -// = DESCRIPTION -// Shows how applications can use the ACE_Token_Collection -// utility. This example creates three collections and spawns a -// thread to operate on each. The threads use the collective -// acquire, renew, and release features of ACE_Token_Collection. -// -// = AUTHOR -// Tim Harrison -// -// ============================================================================ - -#include "ace/OS.h" - -#include "ace/Get_Opt.h" -#include "ace/Local_Tokens.h" -#include "ace/Token_Collection.h" -#include "ace/Remote_Tokens.h" -#include "ace/Thread_Manager.h" -#include "ace/Service_Config.h" - -#if defined (ACE_HAS_THREADS) - -static char *server_host = ACE_DEFAULT_SERVER_HOST; -static int server_port = ACE_DEFAULT_SERVER_PORT; -// unused: static int threads = 2; -static int iterations = 50; -static int debug = 0; -static int remote = 0; -// unused: static int tokens = 5; - -static void * -run_thread (void *vp) -{ - ACE_Token_Proxy *collection = (ACE_Token_Proxy *) vp; - - int count = iterations; - while (count--) - { - if (collection->acquire () == -1) - { - if (ACE_OS::last_error () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "deadlock detected in acquire")); - continue; - } - ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s acquired.\n", collection->name ())); - - if (collection->renew () == -1) - { - if (ACE_OS::last_error () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "deadlock detected")); - goto deadlock; - } - ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s renewed.\n", collection->name ())); - - deadlock: - if (collection->release () == -1) - { - ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","run_thread")); - return (void *) -1; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) %s released.\n", collection->name ())); - } - - - ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); - return 0; -} - -static int -parse_args (int argc, char *argv[]) -{ - ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); - - ACE_Get_Opt get_opt (argc, argv, "un:dp:h:", 1); - - for (int c; (c = get_opt ()) != -1; ) - { - switch (c) - { - case 'h': // specify the host machine on which the server is running - server_host = get_opt.optarg; - remote = 1; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.optarg); - remote = 1; - break; - case 'd': - debug = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'u': - // usage: fallthrough - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-h <remote host>]\n" - "[-p <remote port>]\n" - "[-n <iterations>]\n" - "[-d debug]\n", 1), -1); - /* NOTREACHED */ - } - } - - return 0; -} - -int -main (int argc, char* argv[]) -{ - if (parse_args (argc, argv) == -1) - return -1; - - ACE_Token_Proxy *A; // Mutex *A*. - ACE_Token_Proxy *B; // Mutex *B*. - ACE_Token_Proxy *R; // *R*eader Lock. - ACE_Token_Proxy *W; // *W*riter Lock. - - // Depending on the command line arguments, we will create local or - // remote tokens. The names of the tokens are not important as long - // as they are unique. - if (remote) - { - ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); - A = new ACE_Remote_Mutex ("R Mutex A", 0, debug); - B = new ACE_Remote_Mutex ("R Mutex B", 0, debug); - R = new ACE_Remote_RLock ("R Reader Lock", 0, debug); - W = new ACE_Remote_WLock ("R Writer Lock", 0, debug); - } - else - { - A = new ACE_Local_Mutex ("L Mutex A", 0, debug); - B = new ACE_Local_Mutex ("L Mutex B", 0, debug); - R = new ACE_Local_RLock ("L Reader Lock", 0, debug); - W = new ACE_Local_WLock ("L Writer Lock", 0, debug); - } - - // These collections will be treated as Tokens by the threads. - ACE_Token_Collection collectionAR (debug, "A and Reader"); - ACE_Token_Collection collectionAW (debug, "A and Writer"); - ACE_Token_Collection collectionBR (debug, "B and Reader"); - - // AR and BR can run concurrently. Neither AR or BR can run when AW - // is running. - collectionAR.insert (*A); - collectionAR.insert (*R); - - collectionAW.insert (*A); - collectionAW.insert (*W); - - collectionBR.insert (*B); - collectionBR.insert (*R); - - // Spawn off three threads. - ACE_Thread_Manager *mgr = ACE_Thread_Manager::instance (); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1); - - if (mgr->spawn (ACE_THR_FUNC (run_thread), - (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1); - -#if ! defined (ACE_HAS_PTHREADS) - if (mgr->resume_all () == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); -#endif - - // Wait for all threads to exit. - mgr->wait (); - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ diff --git a/netsvcs/clients/Tokens/collection/rw_locks.cpp b/netsvcs/clients/Tokens/collection/rw_locks.cpp deleted file mode 100644 index 6fd852ff97e..00000000000 --- a/netsvcs/clients/Tokens/collection/rw_locks.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "ace/OS.h" -// $Id$ - - -#include "ace/Get_Opt.h" -#include "ace/Local_Tokens.h" -#include "ace/Remote_Tokens.h" -#include "ace/Thread_Manager.h" - -#if defined (ACE_HAS_THREADS) - -static ACE_Token_Proxy *global_rlock; -static ACE_Token_Proxy *global_wlock; - -static char *server_host = ACE_DEFAULT_SERVER_HOST; -static int server_port = ACE_DEFAULT_SERVER_PORT; -static int ignore_deadlock = 0; -static int threads = 2; -static int iterations = 50; -static int debug = 0; -static int remote = 0; -static int reads = 4; -static int write_sleep = 0; - -static void * -run_thread (void *vp) -{ - for (int x = 0; x < iterations; x++) - { - int y = 0; - for (; y < reads; y++) - { - if (global_rlock->acquire () == -1) - { - if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) - { - ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected\n")); - goto READ_DEADLOCK; - } - else return 0; - } - - ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); - } - - READ_DEADLOCK: - - for (; y > 0; y--) - { - if (global_rlock->release () == 0) - ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); - } - - if (global_wlock->acquire () == -1) - { - ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected\n")); - } - else - { - if (write_sleep) - ACE_OS::sleep (1); - ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); - if (global_wlock->release () == 0) - ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); - } - } - - ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); - return 0; -} - -static int -parse_args (int argc, char *argv[]) -{ - ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); - - ACE_Get_Opt get_opt (argc, argv, "t:iun:drR:sp:h:", 1); - - for (int c; (c = get_opt ()) != -1; ) - { - switch (c) - { - case 'h': // specify the host machine on which the server is running - server_host = get_opt.optarg; - break; - case 'p': // specify the port on which the server is running - server_port = ACE_OS::atoi (get_opt.optarg); - break; - case 't': - threads = ACE_OS::atoi (get_opt.optarg); - break; - case 'R': - reads = ACE_OS::atoi (get_opt.optarg); - break; - case 'd': - debug = 1; - break; - case 'r': - remote = 1; - break; - case 's': - write_sleep = 1; - break; - case 'n': - iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'i': - ignore_deadlock = 1; - break; - case 'u': - // usage: fallthrough - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n" - "[-i ignore deadlock]\n" - "[-n <iterations>]\n" - "[-R <reads>]\n" - "[-r use remote locks]\n" - "[-d debug]\n" - "[-s sleep during writes]\n" - "[-t <threads>\n", 1), -1); - break; - } - } - - return 0; -} - -int -main (int argc, char* argv[]) -{ - if (parse_args (argc, argv) == -1) - return -1; - - if (remote) - { - ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); - global_rlock = (ACE_Token_Proxy *) new - ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug); - global_wlock = (ACE_Token_Proxy *) new - ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug); - } - else - { - global_rlock = (ACE_Token_Proxy *) new - ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug); - global_wlock = (ACE_Token_Proxy *) new - ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug); - } - - ACE_Thread_Manager mgr; - - if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread), - (void *) &0, - THR_BOUND | THR_SUSPENDED) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); - - if (mgr.resume_all () == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); - - mgr.wait (); - - return 0; -} - -#else -int -main (int, char *[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "threads not supported on this platform\n"), -1); -} -#endif /* ACE_HAS_THREADS */ |