1 #include "FP_Scheduler.h"
2 #include "ace/Atomic_Op.h"
3 #include "tao/RTScheduling/Request_Interceptor.h"
6 ACE_Atomic_Op
<TAO_SYNCH_MUTEX
, long> server_guid_counter
;
9 Segment_Sched_Param_Policy::value (void)
15 Segment_Sched_Param_Policy::value (RTCORBA::Priority value
)
21 Segment_Sched_Param_Policy::copy (void)
23 Segment_Sched_Param_Policy
*copy
= 0;
24 ACE_NEW_THROW_EX (copy
,
25 Segment_Sched_Param_Policy
,
28 copy
->value (this->value_
);
34 Segment_Sched_Param_Policy::policy_type (void)
40 Segment_Sched_Param_Policy::destroy (void)
44 Fixed_Priority_Scheduler::Fixed_Priority_Scheduler (CORBA::ORB_ptr orb
)
48 CORBA::Object_var object
=
49 orb
->resolve_initial_references ("RTScheduler_Current");
52 RTScheduling::Current::_narrow (object
.in ());
54 catch (const CORBA::Exception
& ex
)
56 ex
._tao_print_exception ("Caught exception:");
60 Fixed_Priority_Scheduler::~Fixed_Priority_Scheduler (void)
64 FP_Scheduling::SegmentSchedulingParameterPolicy_ptr
65 Fixed_Priority_Scheduler::create_segment_scheduling_parameter (RTCORBA::Priority segment_priority
)
67 FP_Scheduling::SegmentSchedulingParameterPolicy_ptr segment_policy
;
68 ACE_NEW_THROW_EX (segment_policy
,
69 Segment_Sched_Param_Policy
,
71 CORBA::SystemException::_tao_minor_code (
74 CORBA::COMPLETED_NO
));
76 segment_policy
->value (segment_priority
);
78 return segment_policy
;
84 Fixed_Priority_Scheduler::begin_new_scheduling_segment (const RTScheduling::Current::IdType
&,
86 CORBA::Policy_ptr
/*sched_policy*/,
92 Fixed_Priority_Scheduler::begin_nested_scheduling_segment (const RTScheduling::Current::IdType
&guid
,
94 CORBA::Policy_ptr sched_param
,
95 CORBA::Policy_ptr implicit_sched_param
)
97 this->begin_new_scheduling_segment (guid
,
100 implicit_sched_param
);
104 Fixed_Priority_Scheduler::update_scheduling_segment (const RTScheduling::Current::IdType
&guid
,
106 CORBA::Policy_ptr sched_param
,
107 CORBA::Policy_ptr implicit_sched_param
)
109 this->begin_new_scheduling_segment (guid
,
112 implicit_sched_param
);
117 Fixed_Priority_Scheduler::end_scheduling_segment (const RTScheduling::Current::IdType
&,
123 Fixed_Priority_Scheduler::end_nested_scheduling_segment (const RTScheduling::Current::IdType
&,
131 Fixed_Priority_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr request_info
)
135 ACE_hthread_t current
;
136 ACE_Thread::self (current
);
137 if (ACE_Thread::getprio (current
, priority
) == -1)
140 ACE_DEBUG ((LM_DEBUG
,
141 "Request thread priority is %d %d\n",
143 ACE_DEFAULT_THREAD_PRIORITY
));
146 RTScheduling::Current::IdType_var guid
= this->current_
->id ();
147 IOP::ServiceContext
* srv_con
= new IOP::ServiceContext
;
148 srv_con
->context_id
= Client_Interceptor::SchedulingInfo
;
149 srv_con
->context_data
.length (sizeof (size_t));
150 ACE_OS::memcpy (srv_con
->context_data
.get_buffer (),
153 request_info
->add_request_service_context (*srv_con
,
159 Fixed_Priority_Scheduler::receive_request (PortableInterceptor::ServerRequestInfo_ptr request_info
,
160 RTScheduling::Current::IdType_out guid_out
,
161 CORBA::String_out
/*name*/,
162 CORBA::Policy_out
/*sched_param*/,
163 CORBA::Policy_out
/*implicit_sched_param*/)
165 IOP::ServiceContext
* serv_cxt
=
166 request_info
->get_request_service_context (Server_Interceptor::SchedulingInfo
);
171 ACE_OS::memcpy (&gu_id
,
172 serv_cxt
->context_data
.get_buffer (),
173 serv_cxt
->context_data
.length ());
175 ACE_TCHAR msg
[BUFSIZ
];
176 ACE_OS::sprintf (msg
,
177 ACE_TEXT("The Guid is ")
178 ACE_SIZE_T_FORMAT_SPECIFIER
179 ACE_TEXT("\n"), gu_id
);
181 DT_TEST::instance ()->dt_creator ()->log_msg (ACE_TEXT_ALWAYS_CHAR(msg
));
183 RTScheduling::Current::IdType
* guid
= 0;
185 RTScheduling::Current::IdType
);
189 guid
->length (sizeof(size_t));
191 ACE_OS::memcpy (guid
->get_buffer (),
195 if (TAO_debug_level
> 0)
196 ACE_DEBUG ((LM_DEBUG
,
197 "Receive request The Guid is %d\n",
200 guid_out
.ptr () = guid
;
206 Fixed_Priority_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr
)
211 Fixed_Priority_Scheduler::send_exception (PortableInterceptor::ServerRequestInfo_ptr
)
216 Fixed_Priority_Scheduler::send_other (PortableInterceptor::ServerRequestInfo_ptr
)
221 Fixed_Priority_Scheduler::send_poll (PortableInterceptor::ClientRequestInfo_ptr
)
226 Fixed_Priority_Scheduler::receive_reply (PortableInterceptor::ClientRequestInfo_ptr
)
231 Fixed_Priority_Scheduler::receive_exception (PortableInterceptor::ClientRequestInfo_ptr
)
236 Fixed_Priority_Scheduler::receive_other (PortableInterceptor::ClientRequestInfo_ptr
)
241 Fixed_Priority_Scheduler::cancel (const RTScheduling::Current::IdType
&)
246 Fixed_Priority_Scheduler::scheduling_policies (void)
252 Fixed_Priority_Scheduler::scheduling_policies (const CORBA::PolicyList
&)
257 Fixed_Priority_Scheduler::poa_policies (void)
263 Fixed_Priority_Scheduler::scheduling_discipline_name (void)
268 RTScheduling::ResourceManager_ptr
269 Fixed_Priority_Scheduler::create_resource_manager (const char *,
276 Fixed_Priority_Scheduler::set_scheduling_parameter (PortableServer::Servant
&,