Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / tests / Sched_Conf / Sched_Conf_Runtime.cpp
blob55ef7703736e683e0336533c0e728d40903eb277
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"
7 #include "tao/corba.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"
19 int
20 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
22 try
24 // Initialize ORB.
25 CORBA::ORB_var orb =
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"),
34 1);
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.
66 delete rt_info;
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 ==
73 infos [i].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 ==
81 infos [i].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 ==
87 infos [i].quantum);
88 ACE_ASSERT (rt_info->threads ==
89 infos [i].threads);
90 ACE_ASSERT (rt_info->priority ==
91 infos [i].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,
106 infos [i].period,
107 static_cast<RtecScheduler::Importance_t> (infos [i].importance),
108 infos [i].quantum,
109 infos [i].threads,
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,
114 priority,
115 subpriority,
116 p_priority);
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,
122 priority,
123 subpriority,
124 p_priority);
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.
137 runtime_scheduler->
138 dispatch_configuration (configs [j].preemption_priority,
139 priority,
140 dispatching_type);
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");
152 return 0;