Made TASKING service, Suoritin, a member of the Habitat rather than Hoitaja. This way the habitat has direct access to the Suoritin sessions without sending pointers around. Also added new entrypoint for Hoitaja's timer.

This commit is contained in:
Michael Mueller
2023-10-13 19:01:45 +02:00
parent 80bde5fd90
commit 539bb07995
3 changed files with 27 additions and 10 deletions

View File

@@ -102,6 +102,17 @@ void Hoitaja::Habitat::maintain_cells()
log(child.name(), " ram: ", child.ram_quota());
Cell &cell = static_cast<Cell&>(child);
_core_allocator->update(cell, &xpos); });
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++) {
Tukija::Suoritin::Channel &channel = client.channels_if()[channel_id];
Genode::log("\t", "Channel ", channel_id, ": length=", channel.length(), " worker=", client.worker(channel._worker).name(), ",", client.worker(channel._worker).cap() );
if (channel.length() > 0xFFFF) {
Genode::Parent::Resource_args grant_args("cpu_quota=10");
client.send_request(grant_args);
}
}
});
}
void Hoitaja::Habitat::update(Cell &cell)

View File

@@ -17,6 +17,7 @@
#include <core_allocator.h>
#include <cell.h>
#include <state_handler.h>
#include <suoritin/component.h>
#pragma once
namespace Hoitaja {
@@ -32,9 +33,14 @@ struct Hoitaja::Habitat : public Sandbox::Library
State_handler &_habitat_handler;
Heap _heap;
Sliced_heap suoritin_heap;
Entrypoint suoritin_ep{_env, 4 * 4096, "suoritin", Affinity::Location()};
Genode::Constructible<Hoitaja::Core_allocator> _core_allocator;
Tukija::Suoritin::Root_component suoritin;
Registry<Genode::Sandbox::Local_service_base>
_local_services{};
@@ -59,8 +65,10 @@ struct Hoitaja::Habitat : public Sandbox::Library
void update(Cell &cell);
Habitat(Env &env, State_handler &habitat_handler, Genode::Sandbox::State_handler &handler)
: Sandbox::Library(env, _heap, _local_services, handler), _habitat_handler(habitat_handler), _heap(env.ram(), env.rm()), _core_allocator()
: Sandbox::Library(env, _heap, _local_services, handler), _habitat_handler(habitat_handler), _heap(env.ram(), env.rm()),
suoritin_heap(env.ram(), env.rm()), _core_allocator(), suoritin(env, suoritin_heap)
{
env.parent().announce(suoritin_ep.manage(suoritin));
}
Sandbox::Child &create_child(Xml_node const &) override;

View File

@@ -45,9 +45,9 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler
{
Env &_env;
Habitat _sandbox { _env, *this, *this };
Entrypoint timer_ep{_env, 4 * 4096, "hoitaja_timer", Affinity::Location()};
Entrypoint suoritin_ep{_env, 4 * 4096, "suoritin", Affinity::Location()};
Habitat _sandbox { _env, *this, *this };
Timer::Connection _timer{_env};
@@ -94,14 +94,15 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler
void _handle_timeout()
{
//log("Hoitaja's entering its maintance cycle");
log("Hoitaja's entering its maintance cycle");
// For now just print all cells created by Hoitaja
//_handle_config();
//_timer.trigger_once(1000 * 1000);
_sandbox.maintain_cells();
_timer.trigger_once(10*1000 * 1000);
}
Signal_handler<Main> _timeout_handler{
_env.ep(), *this, &Main::_handle_timeout};
timer_ep, *this, &Main::_handle_timeout};
/**
* Sandbox::State_handler interface
@@ -143,12 +144,9 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler
_handle_config();
Genode::log("Starting TASKING service");
static Genode::Sliced_heap sliced_heap{env.ram(), env.rm()};
static Tukija::Suoritin::Root_component suoritin(env, sliced_heap);
env.parent().announce(suoritin_ep.manage(suoritin));
//_timer.trigger_once(1000 * 1000);
_timer.trigger_once(1000 * 1000);
}
};