1 #include "Server_Task.h"
2 #include "Client_Task.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Sched_Params.h"
5 #include "ace/OS_NS_errno.h"
6 #include "ace/Manual_Event.h"
8 #include "tao/Strategies/advanced_resource.h"
10 int niterations
= 250000;
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:"));
18 while ((c
= get_opts ()) != -1)
22 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
26 // This is a hack but that is okay!
29 // Indicates successful parsing of the command line
37 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
38 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
39 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
41 // Enable FIFO scheduling
42 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
44 ACE_SCOPE_PROCESS
)) != 0)
46 if (ACE_OS::last_error () == EPERM
)
49 "server (%P|%t): user is not superuser, "
50 "test runs in time-shared class\n"));
54 "server (%P|%t): sched_params failed\n"));
59 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
61 //Use Real-time Scheduling class if possible
67 CORBA::ORB_init (argc
, argv
);
69 if (parse_args (argc
,argv
) == -1)
72 ACE_Manual_Event wait_for_event
;
74 Server_Task
server_task (sorb
.in (),
76 ACE_Thread_Manager::instance ());
78 if (server_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
82 ACE_ERROR ((LM_ERROR
, "Error activating server task\n"));
85 // Wait for the server thread to do some processing
86 wait_for_event
.wait ();
88 // Obtain the object reference
89 Test::Roundtrip_var reference
= server_task
.get_reference ();
91 Client_Task
client_task (reference
.in (),
93 ACE_Thread_Manager::instance ());
95 if (client_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
99 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
102 ACE_Thread_Manager::instance ()->wait ();
104 catch (const CORBA::Exception
&)
106 // Ignore exceptions..