mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
init: use Prio_levels type instead of basic type
This commit is contained in:
parent
06943f413d
commit
29c4ed45cc
@ -621,7 +621,7 @@ Init::Child::Child(Env &env,
|
||||
Name_registry &name_registry,
|
||||
Ram_quota ram_limit,
|
||||
Ram_limit_accessor &ram_limit_accessor,
|
||||
long prio_levels,
|
||||
Prio_levels prio_levels,
|
||||
Affinity::Space const &affinity_space,
|
||||
Registry<Parent_service> &parent_services,
|
||||
Registry<Routed_service> &child_services)
|
||||
|
@ -134,7 +134,7 @@ class Init::Child : Child_policy, Child_service::Wakeup
|
||||
}
|
||||
};
|
||||
|
||||
Resources _resources_from_start_node(Xml_node start_node, long prio_levels,
|
||||
Resources _resources_from_start_node(Xml_node start_node, Prio_levels prio_levels,
|
||||
Affinity::Space const &affinity_space)
|
||||
{
|
||||
size_t cpu_quota_pc = 0;
|
||||
@ -156,13 +156,13 @@ class Init::Child : Child_policy, Child_service::Wakeup
|
||||
}
|
||||
});
|
||||
|
||||
return Resources { log2(prio_levels),
|
||||
priority_from_xml(start_node, prio_levels),
|
||||
Affinity(affinity_space,
|
||||
affinity_location_from_xml(affinity_space, start_node)),
|
||||
Ram_quota { ram_bytes },
|
||||
cpu_quota_pc,
|
||||
constrain_phys };
|
||||
return Resources { log2(prio_levels.value),
|
||||
priority_from_xml(start_node, prio_levels),
|
||||
Affinity(affinity_space,
|
||||
affinity_location_from_xml(affinity_space, start_node)),
|
||||
Ram_quota { ram_bytes },
|
||||
cpu_quota_pc,
|
||||
constrain_phys };
|
||||
}
|
||||
|
||||
Resources _resources;
|
||||
@ -360,7 +360,7 @@ class Init::Child : Child_policy, Child_service::Wakeup
|
||||
Name_registry &name_registry,
|
||||
Ram_quota ram_limit,
|
||||
Ram_limit_accessor &ram_limit_accessor,
|
||||
long prio_levels,
|
||||
Prio_levels prio_levels,
|
||||
Affinity::Space const &affinity_space,
|
||||
Registry<Parent_service> &parent_services,
|
||||
Registry<Routed_service> &child_services);
|
||||
|
@ -255,7 +255,7 @@ void Init::Main::_handle_config()
|
||||
_default_route.construct(_heap, _config.xml().sub_node("default-route")); }
|
||||
catch (...) { }
|
||||
|
||||
long const prio_levels = prio_levels_from_xml(_config.xml());
|
||||
Prio_levels const prio_levels = prio_levels_from_xml(_config.xml());
|
||||
Affinity::Space const affinity_space = affinity_space_from_xml(_config.xml());
|
||||
|
||||
_update_aliases_from_config();
|
||||
|
@ -26,6 +26,8 @@ namespace Init {
|
||||
|
||||
struct Ram_quota { size_t value; };
|
||||
|
||||
struct Prio_levels { long value; };
|
||||
|
||||
typedef List<List_element<Init::Child> > Child_list;
|
||||
}
|
||||
|
||||
|
@ -151,19 +151,19 @@ namespace Init {
|
||||
/**
|
||||
* Read priority-levels declaration from config
|
||||
*/
|
||||
inline long prio_levels_from_xml(Xml_node config)
|
||||
inline Prio_levels prio_levels_from_xml(Xml_node config)
|
||||
{
|
||||
long const prio_levels = config.attribute_value("prio_levels", 0UL);
|
||||
|
||||
if (prio_levels && (prio_levels != (1 << log2(prio_levels)))) {
|
||||
warning("prio levels is not power of two, priorities are disabled");
|
||||
return 0;
|
||||
return Prio_levels { 0 };
|
||||
}
|
||||
return prio_levels;
|
||||
return Prio_levels { prio_levels };
|
||||
}
|
||||
|
||||
|
||||
inline long priority_from_xml(Xml_node start_node, long prio_levels)
|
||||
inline long priority_from_xml(Xml_node start_node, Prio_levels prio_levels)
|
||||
{
|
||||
long priority = Cpu_session::DEFAULT_PRIORITY;
|
||||
try { start_node.attribute("priority").value(&priority); }
|
||||
@ -178,8 +178,8 @@ namespace Init {
|
||||
*/
|
||||
priority = -priority;
|
||||
|
||||
if (priority && (priority >= prio_levels)) {
|
||||
long new_prio = prio_levels ? prio_levels-1 : 0;
|
||||
if (priority && (priority >= prio_levels.value)) {
|
||||
long new_prio = prio_levels.value ? prio_levels.value - 1 : 0;
|
||||
char name[Service::Name::capacity()];
|
||||
start_node.attribute("name").value(name, sizeof(name));
|
||||
warning(Cstring(name), ": invalid priority, upgrading "
|
||||
|
Loading…
Reference in New Issue
Block a user