2 #include "ace/High_Res_Timer.h"
6 #include "ace/Countdown_Time.h"
8 #if !defined(__ACE_INLINE__)
10 #endif /* __ACE_INLINE__ */
13 Simple_Server_i::test_method (CORBA::Long exec_duration
)
15 ACE_hthread_t thr_handle
;
16 ACE_Thread::self (thr_handle
);
19 RTScheduling::Current::IdType_var id
= this->current_
->id ();
21 ACE_OS::memcpy (&guid
,
23 sizeof (id
->length ()));
25 ACE_High_Res_Timer timer
;
26 ACE_Time_Value elapsed_time
;
28 ACE_DEBUG ((LM_DEBUG
, "Request in thread %t\n"));
30 if (ACE_Thread::getprio (thr_handle
, prio
) == -1)
35 ACE_TEXT ("getprio not supported on this platform\n")));
39 ACE_ERROR_RETURN ((LM_ERROR
,
41 ACE_TEXT ("getprio failed")),
46 "Request in thread %t, prio = %d,"
47 "exec duration = %u\n", prio
, exec_duration
));
49 static CORBA::ULong prime_number
= 9619899;
51 ACE_Time_Value
compute_count_down_time (exec_duration
, 0);
52 ACE_Countdown_Time
compute_count_down (&compute_count_down_time
);
54 //Applicable only for CV based implementations
56 ACE_Time_Value
yield_interval (1,0);
58 ACE_Time_Value
yield_count_down_time (yield_interval
);
59 ACE_Countdown_Time
yield_count_down (&yield_count_down_time
);
63 while (compute_count_down_time
> ACE_Time_Value::zero
)
65 ACE::is_prime (prime_number
,
71 #ifdef KOKYU_DSRT_LOGGING
75 "(%t|%T) loop # = %d, load = %usec\n", j
, exec_duration
));
80 ACE_Time_Value run_time
= ACE_OS::gettimeofday ();
81 task_stats_
.sample (run_time
.msec (), guid
);
84 compute_count_down
.update ();
88 yield_count_down
.update ();
89 if (yield_count_down_time
<= ACE_Time_Value::zero
)
91 CORBA::Policy_var sched_param_policy
=
92 current_
->scheduling_parameter();
94 const char * name
= 0;
96 CORBA::Policy_ptr implicit_sched_param
= 0;
97 current_
->update_scheduling_segment (name
,
98 sched_param_policy
.in (),
99 implicit_sched_param
);
100 yield_count_down_time
= yield_interval
;
101 yield_count_down
.start ();
107 timer
.elapsed_time (elapsed_time
);
109 ACE_DEBUG ((LM_DEBUG
,
110 "Request processing in thread %t done, "
111 "prio = %d, load = %d, elapsed time = %umsec\n",
112 prio
, exec_duration
, elapsed_time
.msec () ));
114 return exec_duration
;
118 Simple_Server_i::shutdown ()
120 ACE_DEBUG ((LM_DEBUG
, "shutdown request from client\n"));
121 this->orb_
->shutdown (false);