1 // This program exercises a run-time scheduler,
2 // using the config run generated C++ header file.
4 #include "ace/Sched_Params.h"
5 #include "ace/Get_Opt.h"
6 #include "ace/OS_NS_string.h"
9 #include "orbsvcs/CosNamingC.h"
10 #include "orbsvcs/Scheduler_Factory.h"
11 #include "orbsvcs/Naming/Naming_Server.h"
13 #include "Sched_Conf_Runtime.h"
20 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
26 CORBA::ORB_init (argc
, argv
, "internet");
28 CORBA::Object_var poa_object
=
29 orb
->resolve_initial_references("RootPOA");
31 if (CORBA::is_nil(poa_object
.in ()))
32 ACE_ERROR_RETURN ((LM_ERROR
,
33 " (%P|%t) Unable to initialize the POA.\n"),
36 PortableServer::POA_var root_poa
=
37 PortableServer::POA::_narrow (poa_object
.in());
39 PortableServer::POAManager_var poa_manager
=
40 root_poa
->the_POAManager ();
42 poa_manager
->activate ();
44 // Store a pointer to the local run-time scheduler.
45 RtecScheduler::Scheduler_ptr runtime_scheduler
=
46 ACE_Scheduler_Factory::server ();
48 // Some useful variables for retrieving values from the scheduler.
49 RtecScheduler::RT_Info
*rt_info
= 0;
50 RtecScheduler::OS_Priority priority
;
51 RtecScheduler::Preemption_Subpriority_t subpriority
;
52 RtecScheduler::Preemption_Priority_t p_priority
;
53 RtecScheduler::Dispatching_Type_t dispatching_type
;
55 for (int i
= 0; i
< infos_size
; ++i
)
57 // Make sure the correct handle is returned by the
58 // run-time scheduler's create and lookup methods.
59 ACE_ASSERT (infos
[i
].handle
==
60 runtime_scheduler
->create (infos
[i
].entry_point
));
62 ACE_ASSERT (infos
[i
].handle
==
63 runtime_scheduler
->lookup (infos
[i
].entry_point
));
65 // Make sure the values in the RT_Info returned by get are OK.
67 rt_info
= runtime_scheduler
->get (infos
[i
].handle
);
69 ACE_ASSERT (rt_info
!= 0);
70 ACE_ASSERT (ACE_OS::strcmp (rt_info
->entry_point
,
71 infos
[i
].entry_point
) == 0);
72 ACE_ASSERT (rt_info
->handle
==
74 ACE_ASSERT (rt_info
->worst_case_execution_time
==
75 infos
[i
].worst_case_execution_time
);
76 ACE_ASSERT (rt_info
->typical_execution_time
==
77 infos
[i
].typical_execution_time
);
78 ACE_ASSERT (rt_info
->cached_execution_time
==
79 infos
[i
].cached_execution_time
);
80 ACE_ASSERT (rt_info
->period
==
82 ACE_ASSERT (rt_info
->criticality
==
83 static_cast<RtecScheduler::Criticality_t
> (infos
[i
].criticality
));
84 ACE_ASSERT (rt_info
->importance
==
85 static_cast<RtecScheduler::Importance_t
> (infos
[i
].importance
));
86 ACE_ASSERT (rt_info
->quantum
==
88 ACE_ASSERT (rt_info
->threads
==
90 ACE_ASSERT (rt_info
->priority
==
92 ACE_ASSERT (rt_info
->preemption_subpriority
==
93 infos
[i
].static_subpriority
);
94 ACE_ASSERT (rt_info
->preemption_priority
==
95 infos
[i
].preemption_priority
);
96 ACE_ASSERT (rt_info
->info_type
==
97 static_cast<RtecScheduler::Info_Type_t
> (infos
[i
].info_type
));
99 // Make sure the values in the scheduler's internal RT_Info are OK.
100 // Scheduler will generate messages if any values don't match.
101 runtime_scheduler
->set (infos
[i
].handle
,
102 static_cast<RtecScheduler::Criticality_t
> (infos
[i
].criticality
),
103 infos
[i
].worst_case_execution_time
,
104 infos
[i
].typical_execution_time
,
105 infos
[i
].cached_execution_time
,
107 static_cast<RtecScheduler::Importance_t
> (infos
[i
].importance
),
110 static_cast<RtecScheduler::Info_Type_t
> (infos
[i
].info_type
));
112 // Make sure the correct priority values are returned.
113 runtime_scheduler
->priority (infos
[i
].handle
,
118 ACE_ASSERT (priority
== infos
[i
].priority
);
119 ACE_ASSERT (subpriority
== infos
[i
].static_subpriority
);
120 ACE_ASSERT (p_priority
== infos
[i
].preemption_priority
);
121 runtime_scheduler
->entry_point_priority (infos
[i
].entry_point
,
126 ACE_ASSERT (priority
== infos
[i
].priority
);
127 ACE_ASSERT (subpriority
== infos
[i
].static_subpriority
);
128 ACE_ASSERT (p_priority
== infos
[i
].preemption_priority
);
131 for (int j
= 0; j
< configs_size
; ++j
)
133 // Make sure the correct preemption priority is stored.
134 ACE_ASSERT (j
== configs
[j
].preemption_priority
);
136 // Make sure the correct queue configuration values are returned.
138 dispatch_configuration (configs
[j
].preemption_priority
,
142 ACE_ASSERT (priority
== configs
[j
].thread_priority
);
143 ACE_ASSERT (dispatching_type
== configs
[j
].dispatching_type
);
147 catch (const CORBA::Exception
& ex
)
149 ex
._tao_print_exception ("SYS_EX");