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_
);
29 MIF_Task::~MIF_Task (void)
35 MIF_Task::pre_activate (void)
37 DT_TEST::instance ()->scheduler ()->incr_thr_count ();
41 MIF_Task::post_activate (void)
43 DT_TEST::instance ()->scheduler ()->wait ();
47 MIF_Task::activate_task (RTScheduling::Current_ptr current
,
48 CORBA::Policy_ptr sched_param
,
50 ACE_Time_Value
* base_time
)
53 if (TAO_debug_level
> 0)
55 "MIF_Task::activate %d\n",
59 ACE_OS::sprintf (msg
, "MIF_Task::activate task\n");
60 dt_creator_
->log_msg (msg
);
62 base_time_
= base_time
;
64 current_
= RTScheduling::Current::_narrow (current
);
66 sched_param_
= CORBA::Policy::_duplicate (sched_param
);
70 if (this->activate (flags
,
73 if (ACE_OS::last_error () == EPERM
)
74 ACE_ERROR_RETURN ((LM_ERROR
,
75 ACE_TEXT ("Insufficient privilege to run this test.\n")),
84 MIF_Task::perform_task (void)
89 ACE_TCHAR msg
[BUFSIZ
];
91 ACE_TEXT("MIF_Task::perform_task ")
92 ACE_SIZE_T_FORMAT_SPECIFIER
95 dt_creator_
->log_msg (ACE_TEXT_ALWAYS_CHAR(msg
));
97 static CORBA::ULong prime_number
= 9619;
98 CORBA::Policy_var sched_param
;
99 sched_param
= dt_creator_
->sched_param (this->importance_
);
100 const char * name
= 0;
102 for (int i
= 0; i
< this->iter_
; i
++)
104 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
105 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
107 ACE_Time_Value
count_down_time (1);
108 ACE_Countdown_Time
count_down (&count_down_time
);
110 while (count_down_time
> ACE_Time_Value::zero
)
112 ACE::is_prime (prime_number
,
116 count_down
.update ();
119 current_
->update_scheduling_segment (name
,
126 this->job_
->work (this->load_
,
129 for (int j
= 0; j
< this->iter_
; j
++)
131 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
132 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
134 ACE_Time_Value
count_down_time (1);
135 ACE_Countdown_Time
count_down (&count_down_time
);
137 while (count_down_time
> ACE_Time_Value::zero
)
140 ACE::is_prime (prime_number
,
143 count_down
.update ();
146 current_
->update_scheduling_segment (name
,
155 catch (const CORBA::Exception
& ex
)
157 ex
._tao_print_exception ("Caught exception:");
161 if (TAO_debug_level
> 0)
162 ACE_DEBUG ((LM_DEBUG
,