3 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
4 #include "tao/RTCORBA/Priority_Mapping.h"
5 #include "ace/High_Res_Timer.h"
6 #include "ace/OS_NS_errno.h"
7 #include "ace/Countdown_Time.h"
9 FP_Task::FP_Task (int importance
,
15 DT_Creator
*dt_creator
)
19 this->start_time_
= start_time
;
20 this->importance_
= importance
;
21 this->dt_creator_
= dt_creator
;
23 this->job_name_
= CORBA::string_dup (job_name
);
27 FP_Task::activate_task (RTScheduling::Current_ptr current
,
28 CORBA::Policy_ptr sched_param
,
30 ACE_Time_Value
* base_time
)
32 if (TAO_debug_level
> 0)
34 "FP_Task::activate %d\n",
38 ACE_OS::sprintf (msg
, "FP_Task::activate task\n");
39 dt_creator_
->log_msg (msg
);
41 base_time_
= base_time
;
43 current_
= RTScheduling::Current::_narrow (current
);
45 sched_param_
= CORBA::Policy::_duplicate (sched_param
);
49 if (this->activate (flags
,
52 this->importance_
) == -1)
54 if (ACE_OS::last_error () == EPERM
)
55 ACE_ERROR_RETURN ((LM_ERROR
,
56 ACE_TEXT ("Insufficient privilege to run this test.\n")),
64 FP_Task::pre_activate ()
66 CORBA::Object_var object
=
67 DT_TEST::instance ()->orb ()->resolve_initial_references ("PriorityMappingManager");
69 RTCORBA::PriorityMappingManager_var mapping_manager
=
70 RTCORBA::PriorityMappingManager::_narrow (object
.in ());
72 RTCORBA::PriorityMapping
*pm
= mapping_manager
->mapping ();
74 CORBA::Short native_priority
;
75 if (pm
->to_native (this->importance_
, native_priority
) == 0)
77 "Cannot convert native priority %d to corba priority\n",
79 if (TAO_debug_level
> 0)
81 "Native Priority = %d\n",
84 ACE_OS::sprintf (msg
, "Native Priority %d\n",
86 dt_creator_
->log_msg (msg
);
88 this->importance_
= native_priority
;
92 FP_Task::perform_task ()
94 static CORBA::ULong prime_number
= 9619;
96 for (int j
= 0; j
< this->iter_
; j
++)
98 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
99 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
101 ACE_Time_Value
count_down_time (1);
102 ACE_Countdown_Time
count_down (&count_down_time
);
104 while (count_down_time
> ACE_Time_Value::zero
)
106 ACE::is_prime (prime_number
,
110 count_down
.update ();
114 if (TAO_debug_level
> 0)
115 ACE_DEBUG ((LM_DEBUG
,
121 job_
->work (this->load_
, this->importance_
);
124 for (int j
= 0; j
< this->iter_
; j
++)
126 ACE_Time_Value run_time
= ACE_OS::gettimeofday () - *base_time_
;
127 TASK_STATS::instance ()->sample (run_time
.sec (), count_
);
129 ACE_Time_Value
count_down_time (1);
130 ACE_Countdown_Time
count_down (&count_down_time
);
132 while (count_down_time
> ACE_Time_Value::zero
)
134 if (TAO_debug_level
> 0)
135 ACE_DEBUG ((LM_DEBUG
,
136 "Waiting on count down\n"));
139 ACE::is_prime (prime_number
,
142 count_down
.update ();
146 if (TAO_debug_level
> 0)
147 ACE_DEBUG ((LM_DEBUG
,