diff --git a/repos/os/include/sandbox/utils.h b/repos/os/include/sandbox/utils.h
index cba9ca5d2c..cf39778efb 100644
--- a/repos/os/include/sandbox/utils.h
+++ b/repos/os/include/sandbox/utils.h
@@ -205,6 +205,10 @@ namespace Sandbox {
return priority;
}
+ inline bool is_brick_from_xml(Xml_node start_node)
+ {
+ return start_node.attribute_value("brick", false);
+ }
inline Affinity::Location
affinity_location_from_xml(Affinity::Space const &space, Xml_node start_node)
diff --git a/repos/os/src/hoitaja/config.xsd b/repos/os/src/hoitaja/config.xsd
index 727b5b91e6..6c5a664a89 100644
--- a/repos/os/src/hoitaja/config.xsd
+++ b/repos/os/src/hoitaja/config.xsd
@@ -202,6 +202,7 @@
+
diff --git a/repos/os/src/hoitaja/core_allocator.h b/repos/os/src/hoitaja/core_allocator.h
index 5d87cfbd29..ce0d2ea3f9 100644
--- a/repos/os/src/hoitaja/core_allocator.h
+++ b/repos/os/src/hoitaja/core_allocator.h
@@ -41,20 +41,32 @@ class Hoitaja::Core_allocator
double _resource_coeff; // Coefficient used for calculating resource shares
+ unsigned int _cores_for_cells; // Number of cores available to cells. This is the total number of cores in the habitat minus the cores occupied by bricks.
+
public:
inline unsigned int _calculate_resource_share(long priority) {
- double ref_share = static_cast(_affinity_space.total()) / _resource_coeff;
+ double ref_share = static_cast(_cores_for_cells) / _resource_coeff;
return static_cast((1.0 / static_cast(priority)) * ref_share);
}
- Core_allocator(Genode::Affinity::Space &affinity_space, ::Sandbox::Prio_levels prio_levels) : _affinity_space(affinity_space), _prio_levels(prio_levels), _resource_coeff(0.0)
+ Core_allocator(Genode::Affinity::Space &affinity_space, ::Sandbox::Prio_levels prio_levels) : _affinity_space(affinity_space), _prio_levels(prio_levels), _resource_coeff(0.0), _cores_for_cells(_affinity_space.total())
{
Genode::log("Created core allocator for ", affinity_space.total(), " cores and ", prio_levels.value, " priorities.");
Nova::create_habitat(0, affinity_space.total());
}
+ unsigned int cores_available() {
+ return _cores_for_cells;
+ }
+
Genode::Affinity::Location allocate_cores_for_cell(Genode::Xml_node const &start_node)
{
+ if (::Sandbox::is_brick_from_xml(start_node)) {
+ Genode::Affinity::Location brick = ::Sandbox::affinity_location_from_xml(_affinity_space, start_node);
+ _cores_for_cells -= brick.width();
+ return brick;
+ }
+
// Calculate affinity from global affinity space and priority
long priority = ::Sandbox::priority_from_xml(start_node, _prio_levels);
priority = (priority == 0) ? 1 : priority;
@@ -63,7 +75,7 @@ class Hoitaja::Core_allocator
unsigned int cores_share = _calculate_resource_share(priority);
- return Genode::Affinity::Location( _affinity_space.total()-cores_share, 0, cores_share, 1 ); /* always use the core_share last cores, for now */
+ return Genode::Affinity::Location( _cores_for_cells-cores_share, 0, cores_share, 1 ); /* always use the core_share last cores, for now */
}
void free_cores_from_cell(Cell &cell)
@@ -77,7 +89,7 @@ class Hoitaja::Core_allocator
* @brief Update core allocations for cells reported by Cell controller
*
*/
- void update(Hoitaja::Cell &cell, int *xpos) {
+ void update(Hoitaja::Cell &cell, int *xpos, int *lower_limit) {
if (cell.abandoned())
return;
Cell::Resources resources = cell.resources();
@@ -88,8 +100,8 @@ class Hoitaja::Core_allocator
cores_to_reclaim = (static_cast(cores_to_reclaim) < 0) ? 0 : cores_to_reclaim;
- if (*xpos - cores_share == 0) {
- cores_share--; // Save one core for Hoitaja
+ if (*xpos - static_cast(cores_share) <= *lower_limit) {
+ cores_share-= *lower_limit; // Save one core for Hoitaja
}
Genode::Affinity::Location location(*xpos - cores_share, resources.affinity.location().ypos(), cores_share, resources.affinity.location().height());
diff --git a/repos/os/src/hoitaja/habitat.cc b/repos/os/src/hoitaja/habitat.cc
index ba84770962..43084d7d40 100644
--- a/repos/os/src/hoitaja/habitat.cc
+++ b/repos/os/src/hoitaja/habitat.cc
@@ -98,11 +98,14 @@ void Hoitaja::Habitat::_destroy_abandoned_children()
void Hoitaja::Habitat::maintain_cells()
{
int xpos = _affinity_space->total();
+ int lower_limit = _affinity_space->total() - _core_allocator->cores_available();
_children.for_each_child([&](Child &child)
{
//log(child.name(), " ram: ", child.ram_quota());
Cell &cell = static_cast| (child);
- _core_allocator->update(cell, &xpos); });
+ if (!(cell.is_brick()))
+ _core_allocator->update(cell, &xpos, &lower_limit);
+ });
/*suoritin.for_each([&](Tukija::Suoritin::Session_component &client)
{ Genode::log("Cell ", client.label(), "\n------------");
for (unsigned long channel_id = 0; channel_id < client.channels(); channel_id++)
|