📄 scheduler_factory.cpp
字号:
"static int configs_size = sizeof(configs)/sizeof(configs[0]);\n\n";
static char end_configs_empty[] =
"};\n\n"
"static int configs_size = 0;\n\n";
int ACE_Scheduler_Factory::dump_schedule
(const RtecScheduler::RT_Info_Set& infos,
const RtecScheduler::Dependency_Set& dependencies,
const RtecScheduler::Config_Info_Set& configs,
const RtecScheduler::Scheduling_Anomaly_Set& anomalies,
const char* file_name,
const char* rt_info_format,
const char* dependency_format,
const char* config_info_format,
int dump_disabled_infos,
int dump_disabled_dependencies)
{
u_int i;
char entry_point [BUFSIZ];
// Default format for printing RT_Info output.
if (rt_info_format == 0)
rt_info_format = "{%20s, /* entry_point */\n"
"%10d, /* handle */\n"
"%10d, /* worst_case_execution_time */,\n"
"%10d, /* typical_execution_time */,\n"
"%10d, /* cached_execution_time */,\n"
"%10d, /* period */\n"
"(RtecScheduler::Criticality_t) %d, /* [ VL_C = 0, L_C = 1, M_C = 2, H_C = 3, VH_C = 4] */\n"
"(RtecScheduler::Importance_t) %d, /* [ VL_I = 0, L_I = 1, M_I = 2, H_I = 3, VH_I = 4] */\n"
"%10d, /* quantum */\n"
"%10d, /* threads */\n"
"%10d, /* priority */\n"
"%10d, /* preemption_subpriority */\n"
"%10d, /* preemption_priority */\n"
"(RtecScheduler::Info_Type_t) %d, /* [OPERATION = 0, CONJUNCTION = 1, DISJUNCTION = 2, REMOTE_DEPENDANT = 3] */\n"
"(RtecScheduler::RT_Info_Enabled_Type_t) %d } /* [RT_INFO_DISABLED = 0, RT_INFO_ENABLED = 1, RT_INFO_NON_VOLATILE = 2] */\n";
// Default format for printing dependency output.
if (dependency_format == 0)
dependency_format = " { (RtecScheduler::Dependency_Type_t) %d, %10d, "
"%10d, %10d,"
"(RtecScheduler::Dispatching_Type_t) %d }";
// Default format for printing Config_Info output.
if (config_info_format == 0)
config_info_format = " { %10d, %10d, "
"(RtecScheduler::Dependency_Enabled_Type_t) %d }";
FILE* file = stdout;
if (file_name != 0)
{
file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR(file_name), ACE_LIB_TEXT("w"));
if (file == 0)
return -1;
}
ACE_OS::fprintf (file, header);
// Indicate anomalies encountered during scheduling.
ACE_OS::fprintf(file, (anomalies.length () > 0
? start_anomalies_found
: start_anomalies_none));
for (i = 0; i < anomalies.length (); ++i)
{
const RtecScheduler::Scheduling_Anomaly& anomaly = anomalies[i];
switch (anomaly.severity)
{
case RtecScheduler::ANOMALY_FATAL:
ACE_OS::fprintf(file, "FATAL: ");
break;
case RtecScheduler::ANOMALY_ERROR:
ACE_OS::fprintf(file, "ERROR: ");
break;
case RtecScheduler::ANOMALY_WARNING:
ACE_OS::fprintf(file, "// WARNING: ");
break;
default:
ACE_OS::fprintf(file, "// UNKNOWN: ");
break;
}
ACE_OS::fprintf (file,
"%s\n",
(const char *) anomaly.description);
}
// Print out banner indicating which infos are dumped.
if (dump_disabled_infos)
{
ACE_OS::fprintf (file, "\n// Both enabled and disabled RT_Infos were dumped to this file.\n\n");
}
else
{
ACE_OS::fprintf (file, "\n// Only enabled RT_Infos were dumped to this file.\n\n");
}
// Print out operation QoS info.
ACE_OS::fprintf (file, start_infos);
for (i = 0;
i < infos.length ();
++i)
{
const RtecScheduler::RT_Info& info = infos[i];
if (dump_disabled_infos
|| info.enabled == RtecScheduler::RT_INFO_ENABLED
|| info.enabled == RtecScheduler::RT_INFO_NON_VOLATILE)
{
if (i != 0)
// Finish previous line.
ACE_OS::fprintf(file, ",\n");
const RtecScheduler::RT_Info& info = infos[i];
// Put quotes around the entry point name, exactly as it is stored.
ACE_OS::sprintf (entry_point,
"\"%s\"",
(const char *) info.entry_point);
// @@ TODO Eventually the TimeT structure will be a 64-bit
// unsigned int, we will have to change this dump method then.
ACE_OS::fprintf (file,
rt_info_format,
entry_point,
info.handle,
ACE_CU64_TO_CU32 (info.worst_case_execution_time),
ACE_CU64_TO_CU32 (info.typical_execution_time),
ACE_CU64_TO_CU32 (info.cached_execution_time),
info.period,
info.criticality,
info.importance,
ACE_CU64_TO_CU32 (info.quantum),
info.threads,
info.priority,
info.preemption_subpriority,
info.preemption_priority,
info.info_type,
info.enabled);
}
}
// Finish last line.
ACE_OS::fprintf(file, "\n");
if (infos.length () > 0)
ACE_OS::fprintf (file, end_infos);
else
ACE_OS::fprintf (file, end_infos_empty);
// Print out banner indicating which dependencies are dumped.
if (dump_disabled_dependencies)
{
ACE_OS::fprintf (file, "\n// Both enabled and disabled dependencies were dumped to this file.\n\n");
}
else
{
ACE_OS::fprintf (file, "\n// Only enabled dependencies were dumped to this file.\n\n");
}
// Print out operation dependency info.
ACE_OS::fprintf (file, start_dependencies);
for (i = 0;
i < dependencies.length ();
++i)
{
const RtecScheduler::Dependency_Info& dep = dependencies[i];
if (dump_disabled_infos
|| dep.enabled == RtecBase::DEPENDENCY_ENABLED
|| dep.enabled == RtecBase::DEPENDENCY_NON_VOLATILE)
{
// Finish previous line.
if (i != 0)
{
ACE_OS::fprintf (file, ",\n");
}
ACE_OS::fprintf (file,
dependency_format,
dep.dependency_type,
dep.number_of_calls,
dep.rt_info,
dep.rt_info_depended_on,
dep.enabled);
}
}
// Finish last line.
ACE_OS::fprintf (file, "\n");
if (dependencies.length () > 0)
ACE_OS::fprintf (file, end_dependencies);
else
ACE_OS::fprintf (file, end_dependencies_empty);
// Print out queue configuration info.
ACE_OS::fprintf (file, start_configs);
for (i = 0;
i < configs.length ();
++i)
{
if (i != 0)
// Finish previous line.
ACE_OS::fprintf (file, ",\n");
const RtecScheduler::Config_Info& config = configs[i];
ACE_OS::fprintf (file,
config_info_format,
config.preemption_priority,
config.thread_priority,
config.dispatching_type);
}
// Finish last line.
ACE_OS::fprintf (file, "\n");
if (configs.length () > 0)
ACE_OS::fprintf (file, end_configs);
else
ACE_OS::fprintf (file, end_configs_empty);
ACE_OS::fprintf (file, footer);
ACE_OS::fclose (file);
return 0;
}
void ACE_Scheduler_Factory::log_scheduling_entry(TAO_Reconfig_Scheduler_Entry * entry, FILE* file)
{
if( entry == 0 )
{
ACE_OS::fprintf (file, "Entry is NULL");
return;
}
// Print out the actual rt_info data
const char* rt_info_format = "{%20s, /* entry_point */\n"
"%10d, /* handle */\n"
"%10d, /* period */\n"
"%10d, /* criticality */\n"
"%10d, /* threads */\n"
"%10d, /* priority */\n"
"%10d, /* preemption_subpriority */\n"
"%10d, /* preemption_priority */\n"
"%10d /* enabled */\n";
TAO_RT_Info_Ex* actual_info = entry->actual_rt_info();
ACE_OS::fprintf (file,
rt_info_format,
actual_info->entry_point.in(),
actual_info->handle,
actual_info->period,
actual_info->criticality,
actual_info->threads,
actual_info->priority,
actual_info->preemption_subpriority,
actual_info->preemption_priority,
actual_info->enabled);
// Print out the current admitted tuple
const char* admitted_tuple_format = " {"
"%13d, /* handle */\n"
"%13d, /* rate_index */\n"
"%13d, /* period */\n"
"%13d, /* criticality */\n"
"%13d, /* priority */\n"
"%13d, /* preemption_subpriority */\n"
"%13d, /* preemption_priority */\n"
"%13d } /* enabled */\n";
TAO_RT_Info_Tuple* current_admitted_tuple = entry->current_admitted_tuple();
ACE_OS::fprintf(file, "\n Current admitted Tuple:\n");
if( current_admitted_tuple == 0 )
{
ACE_OS::fprintf (file, " =>NONE_ADMITTED\n");
}
else
{
ACE_OS::fprintf (file,
admitted_tuple_format,
current_admitted_tuple->handle,
current_admitted_tuple->rate_index,
current_admitted_tuple->period,
current_admitted_tuple->criticality,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -