4 #include "ace/OS_NS_errno.h"
5 #include "ace/Countdown_Time.h"
7 MIF_Task::MIF_Task (int importance
,
13 DT_Creator
*dt_creator
)
17 this->start_time_
= start_time
;
18 this->importance_
= importance
;
19 this->dt_creator_
= dt_creator
;
21 this->job_name_
= CORBA::string_dup (job_name
);
23 // create the stat object.
24 ACE_NEW (task_stats_
, Task_Stats
);
25 task_stats_
->init (iter_
);
28 MIF_Task::~MIF_Task ()
34 MIF_Task::pre_activate ()
36 DT_TEST::instance ()->scheduler ()->incr_thr_count ();
40 MIF_Task::post_activate ()
42 DT_TEST::instance ()->scheduler ()->wait ();
46 MIF_Task::activate_task (RTScheduling::Current_ptr current
,
47 CORBA::Policy_ptr sched_param
,
49 ACE_Time_Value
* base_time
)
51 if (TAO_debug_level
> 0)
53 "MIF_Task::activate %d\n",
57 ACE_OS::sprintf (msg
, "MIF_Task::activate task\n");
58 dt_creator_
->log_msg (msg
);
60 base_time_
= base_time
;
62 current_
= RTScheduling::Current::_narrow (current
);
64 sched_param_
= CORBA::Policy::_duplicate (sched_param
);
68 if (this->activate (flags
,
71 if (ACE_OS::last_error () == EPERM
)
72 ACE_ERROR_RETURN ((LM_ERROR
,
73 ACE_TEXT ("Insufficient privilege to run this test.\n")),
82 MIF_Task::perform_task ()
86 ACE_TCHAR msg
[BUFSIZ
];
88 ACE_TEXT("MIF_Task::perform_task ")
89 ACE_SIZE_T_FORMAT_SPECIFIER
92 dt_creator_
->log_msg (ACE_TEXT_ALWAYS_CHAR(msg
));
94 static CORBA::ULong prime_number
= 9619;
95 CORBA::Policy_var sched_param
;
96 sched_param
= dt_creator_
->sched_param (this->importance_
);
97 const char * name
= 0;
99 for (int i
= 0; i
< this->iter_
; i
++)
101 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
102 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
104 ACE_Time_Value
count_down_time (1);
105 ACE_Countdown_Time
count_down (&count_down_time
);
107 while (count_down_time
> ACE_Time_Value::zero
)
109 ACE::is_prime (prime_number
,
113 count_down
.update ();
116 current_
->update_scheduling_segment (name
,
123 this->job_
->work (this->load_
,
126 for (int j
= 0; j
< this->iter_
; j
++)
128 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
129 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
131 ACE_Time_Value
count_down_time (1);
132 ACE_Countdown_Time
count_down (&count_down_time
);
134 while (count_down_time
> ACE_Time_Value::zero
)
136 ACE::is_prime (prime_number
,
139 count_down
.update ();
142 current_
->update_scheduling_segment (name
,
150 catch (const CORBA::Exception
& ex
)
152 ex
._tao_print_exception ("Caught exception:");
156 if (TAO_debug_level
> 0)
157 ACE_DEBUG ((LM_DEBUG
,