00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #if !defined(DEBUG)
00021 #define DEBUG 1
00022 #endif
00023
00024 #include <stdlib.h>
00025
00026 #include <assert.h>
00027 #include <assert_pp.h>
00028
00029 #include <timesFile.h>
00030
00031 #include <rk.h>
00032 #include <rk_stub.h>
00033
00034 #include <iostream>
00035
00036 #include <BrokerC.h>
00037 #include <StrictPolicyC.h>
00038
00039 #include <ManagerImpl.hh>
00040 #include <BasicDelegate.hh>
00041 #include <RealTimeTaskImpl.hh>
00042
00043 #include <StrictPolicyImpl.hh>
00044
00045 #include <LoggingAdvocate.hh>
00046 #include <MaxDecayTaskAdvocate.hh>
00047 #include <GlacialTaskAdvocate.hh>
00048
00049 int main(int argc, char *argv[])
00050 {
00051 int retval = EXIT_SUCCESS;
00052
00053
00054 rk_stub_set_mode(RK_STUB_SIM);
00055
00056 #if defined(HAVE_ACE)
00057
00058 ACE_Log_Msg::instance()->priority_mask(0, ACE_Log_Msg::PROCESS);
00059 #endif
00060
00061
00062 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00063 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00064
00065 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
00066 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00067 mgr->activate();
00068
00069
00070 assert(tfMakeTimesFile("c1_cpu_times",
00071 (const float[]){
00072 55.0,
00073
00074
00075
00076
00077 TIMES_FILE_TERMINATOR
00078 }));
00079 assert(tfMakeTimesFile("c2_cpu_times",
00080 (const float[]){
00081 20.0,
00082 TIMES_FILE_TERMINATOR
00083 }));
00084 assert(tfMakeTimesFile("c3_cpu_times",
00085 (const float[]){
00086 20.0,
00087 TIMES_FILE_TERMINATOR
00088 }));
00089
00090
00091 Broker::Manager_var manager;
00092 ManagerImpl *mi;
00093
00094 mi = new ManagerImpl("dummy");
00095 manager = mi->_this();
00096
00097 BrokerPolicies::StrictPolicy_var policy;
00098 StrictPolicyImpl *spi;
00099
00100 spi = new StrictPolicyImpl("StrictPolicy");
00101 policy = spi->_this();
00102
00103 mi->CurrentPolicy(policy.in());
00104
00105 BasicDelegate c1("c1", 10000, 10000);
00106
00107
00108 BasicDelegate c2("c2", 20000, 20000);
00109 BasicDelegate c3("c3", 10000, 10000);
00110
00111
00112 RealTimeTaskDelegateImpl *rttdi;
00113 RealTimeTaskImpl *rtti;
00114
00115
00116 rtti = new RealTimeTaskImpl(c1.bd_TaskDescription);
00117 c1.bd_Advocate = Broker::RealTimeTask::_narrow(rtti->_this());
00118 assert(!CORBA::is_nil(c1.bd_Advocate.in()));
00119 manager->AddTask(c1.bd_Advocate.in(), c1.bd_CPUSchedule);
00120
00121
00122 rtti = new RealTimeTaskImpl(c2.bd_TaskDescription);
00123 c2.bd_Advocate = Broker::RealTimeTask::_narrow(rtti->_this());
00124 assert(!CORBA::is_nil(c2.bd_Advocate.in()));
00125 manager->AddTask(c2.bd_Advocate.in(), c2.bd_CPUSchedule);
00126
00127
00128 rtti = new RealTimeTaskImpl(c3.bd_TaskDescription);
00129 rttdi = new GlacialTaskAdvocate();
00130 rttdi->SetDelegateAttributeObject("remote-object", rtti->_this());
00131 c3.bd_Advocate = Broker::RealTimeTask::_narrow(rttdi->_this());
00132 assert(!CORBA::is_nil(c3.bd_Advocate.in()));
00133 manager->AddTask(c3.bd_Advocate.in(), c3.bd_CPUSchedule);
00134
00135
00136 struct timespec curr, end = { 1, 0 };
00137
00138
00139 do {
00140 rk_stub_next_tick();
00141 rk_clock_gettime(CLOCK_REALTIME, &curr);
00142 } while( curr.tv_sec < end.tv_sec );
00143
00144
00145 policy->SetTaskPriority(c2.bd_Advocate.in(), 1);
00146
00147 end.tv_sec = 2;
00148
00149 do {
00150 rk_stub_next_tick();
00151 rk_clock_gettime(CLOCK_REALTIME, &curr);
00152 } while( curr.tv_sec < end.tv_sec );
00153
00154
00155 policy->SetTaskPriority(c3.bd_Advocate.in(), 1);
00156
00157 end.tv_sec = 3;
00158
00159 do {
00160 rk_stub_next_tick();
00161 rk_clock_gettime(CLOCK_REALTIME, &curr);
00162 } while( curr.tv_sec < end.tv_sec );
00163
00164
00165 policy->SetTaskPriority(c1.bd_Advocate.in(), 2);
00166
00167 end.tv_sec = 4;
00168
00169 do {
00170 rk_stub_next_tick();
00171 rk_clock_gettime(CLOCK_REALTIME, &curr);
00172 } while( curr.tv_sec < end.tv_sec );
00173
00174 return( retval );
00175 }