mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-15 05:38:18 +00:00
Adapt high-level components to new parent API
This patch adjusts the various users of the 'Child' API to the changes on the account of the new non-blocking parent interface. It also removes the use of the no-longer-available 'Connection::KEEP_OPEN' feature. With the adjustment, we took the opportunity to redesign several components to fit the non-blocking execution model much better, in particular the demo applications. Issue #2120
This commit is contained in:
committed by
Christian Helmuth
parent
8bafb9d41b
commit
b44f0554bd
@ -25,25 +25,29 @@ struct Child : Child_base, List<Child>::Element
|
||||
Argument argument;
|
||||
|
||||
Child(Ram &ram,
|
||||
char const *label,
|
||||
char const *binary,
|
||||
Genode::Cap_session &cap_session,
|
||||
Name const &label,
|
||||
Binary_name const &binary,
|
||||
Genode::Pd_session &pd_session,
|
||||
Genode::Ram_session &ref_ram,
|
||||
Genode::Ram_session_capability ref_ram_cap,
|
||||
Genode::Region_map &local_rm,
|
||||
Genode::size_t ram_quota,
|
||||
Genode::size_t ram_limit,
|
||||
Genode::Signal_context_capability yield_response_sig_cap,
|
||||
Genode::Signal_context_capability exit_sig_cap,
|
||||
Genode::Dataspace_capability ldso_ds)
|
||||
Genode::Signal_context_capability exit_sig_cap)
|
||||
:
|
||||
Child_base(ram,
|
||||
label,
|
||||
binary,
|
||||
cap_session,
|
||||
pd_session,
|
||||
ref_ram,
|
||||
ref_ram_cap,
|
||||
local_rm,
|
||||
ram_quota,
|
||||
ram_limit,
|
||||
yield_response_sig_cap,
|
||||
exit_sig_cap,
|
||||
ldso_ds),
|
||||
argument(label, "subsystem")
|
||||
exit_sig_cap),
|
||||
argument(label.string(), "subsystem")
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Child_registry : public List<Child>
|
||||
bool _child_name_exists(const char *label)
|
||||
{
|
||||
for (Child *child = first() ; child; child = child->next())
|
||||
if (strcmp(child->name(), label) == 0)
|
||||
if (child->name() == label)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ struct Kill_command : Command
|
||||
|
||||
void _destroy_child(Child *child, Terminal::Session &terminal)
|
||||
{
|
||||
tprintf(terminal, "destroying subsystem '%s'\n", child->name());
|
||||
tprintf(terminal, "destroying subsystem '%s'\n", child->name().string());
|
||||
_children.remove(child);
|
||||
Genode::destroy(Genode::env()->heap(), child);
|
||||
}
|
||||
@ -38,8 +38,8 @@ struct Kill_command : Command
|
||||
|
||||
void _for_each_argument(Argument_fn const &fn) const override
|
||||
{
|
||||
auto child_name_fn = [&] (char const *child_name) {
|
||||
Argument arg(child_name, "");
|
||||
auto child_name_fn = [&] (Child_base::Name const &child_name) {
|
||||
Argument arg(child_name.string(), "");
|
||||
fn(arg);
|
||||
};
|
||||
|
||||
@ -65,7 +65,7 @@ struct Kill_command : Command
|
||||
|
||||
/* lookup child by its unique name */
|
||||
for (Child *child = _children.first(); child; child = child->next()) {
|
||||
if (strcmp(child->name(), label) == 0) {
|
||||
if (child->name() == label) {
|
||||
_destroy_child(child, terminal);
|
||||
return;
|
||||
}
|
||||
|
@ -132,11 +132,12 @@ void Component::construct(Genode::Env &env)
|
||||
commands.insert(new Help_command);
|
||||
Kill_command kill_command(children);
|
||||
commands.insert(&kill_command);
|
||||
commands.insert(new Start_command(ram, cap, children,
|
||||
commands.insert(new Start_command(ram, env.pd(),
|
||||
env.ram(), env.ram_session_cap(),
|
||||
env.rm(), children,
|
||||
subsystem_config_registry,
|
||||
yield_response_sig_cap,
|
||||
exited_child_sig_cap,
|
||||
ldso_ds));
|
||||
exited_child_sig_cap));
|
||||
commands.insert(new Status_command(ram, children));
|
||||
commands.insert(new Yield_command(children));
|
||||
commands.insert(new Ram_command(children));
|
||||
|
@ -40,13 +40,13 @@ struct Ram_command : Command
|
||||
size_t const avail = Genode::env()->ram_session()->avail();
|
||||
if (amount > avail) {
|
||||
tprintf(terminal, "upgrade of '%s' exceeds available quota of ",
|
||||
child.name());
|
||||
child.name().string());
|
||||
tprint_bytes(terminal, avail);
|
||||
tprintf(terminal, "\n");
|
||||
amount = avail;
|
||||
}
|
||||
|
||||
tprintf(terminal, "upgrading quota of '%s' to ", child.name());
|
||||
tprintf(terminal, "upgrading quota of '%s' to ", child.name().string());
|
||||
tprint_bytes(terminal, old_quota + amount);
|
||||
tprintf(terminal, "\n");
|
||||
|
||||
@ -69,7 +69,7 @@ struct Ram_command : Command
|
||||
amount = avail;
|
||||
}
|
||||
|
||||
tprintf(terminal, "depleting quota of '%s' to ", child.name());
|
||||
tprintf(terminal, "depleting quota of '%s' to ", child.name().string());
|
||||
tprint_bytes(terminal, old_quota - amount);
|
||||
tprintf(terminal, "\n");
|
||||
|
||||
@ -82,8 +82,8 @@ struct Ram_command : Command
|
||||
|
||||
void _for_each_argument(Argument_fn const &fn) const override
|
||||
{
|
||||
auto child_name_fn = [&] (char const *child_name) {
|
||||
Argument arg(child_name, "");
|
||||
auto child_name_fn = [&] (Child_base::Name const &child_name) {
|
||||
Argument arg(child_name.string(), "");
|
||||
fn(arg);
|
||||
};
|
||||
|
||||
@ -102,7 +102,7 @@ struct Ram_command : Command
|
||||
/* lookup child by its unique name */
|
||||
Child *child = _children.first();
|
||||
for (; child; child = child->next())
|
||||
if (strcmp(child->name(), label) == 0)
|
||||
if (child->name() == label)
|
||||
break;
|
||||
|
||||
if (!child) {
|
||||
|
@ -28,14 +28,16 @@ class Start_command : public Command
|
||||
typedef Genode::Signal_context_capability Signal_context_capability;
|
||||
typedef Genode::Dataspace_capability Dataspace_capability;
|
||||
|
||||
Ram &_ram;
|
||||
Child_registry &_children;
|
||||
Genode::Cap_session &_cap;
|
||||
Subsystem_config_registry &_subsystem_configs;
|
||||
List<Argument> _arguments;
|
||||
Signal_context_capability _yield_response_sigh_cap;
|
||||
Signal_context_capability _exit_sig_cap;
|
||||
Dataspace_capability _ldso_ds;
|
||||
Ram &_ram;
|
||||
Child_registry &_children;
|
||||
Genode::Pd_session &_pd;
|
||||
Genode::Ram_session &_ref_ram;
|
||||
Genode::Ram_session_capability _ref_ram_cap;
|
||||
Genode::Region_map &_local_rm;
|
||||
Subsystem_config_registry &_subsystem_configs;
|
||||
List<Argument> _arguments;
|
||||
Signal_context_capability _yield_response_sigh_cap;
|
||||
Signal_context_capability _exit_sig_cap;
|
||||
|
||||
void _execute_subsystem(char const *name, Command_line &cmd,
|
||||
Terminal::Session &terminal,
|
||||
@ -107,11 +109,12 @@ class Start_command : public Command
|
||||
Child *child = 0;
|
||||
try {
|
||||
child = new (Genode::env()->heap())
|
||||
Child(_ram, label, binary_name, _cap, ram, ram_limit,
|
||||
_yield_response_sigh_cap, _exit_sig_cap, _ldso_ds);
|
||||
Child(_ram, label, binary_name, _pd, _ref_ram, _ref_ram_cap,
|
||||
_local_rm, ram, ram_limit,
|
||||
_yield_response_sigh_cap, _exit_sig_cap);
|
||||
}
|
||||
catch (Genode::Rom_connection::Rom_connection_failed) {
|
||||
tprintf(terminal, "Error: could not obtain ROM module \"%s\"\n",
|
||||
catch (Genode::Parent::Service_denied) {
|
||||
tprintf(terminal, "Error: could not start child \"%s\"\n",
|
||||
binary_name);
|
||||
return;
|
||||
}
|
||||
@ -146,18 +149,22 @@ class Start_command : public Command
|
||||
|
||||
public:
|
||||
|
||||
Start_command(Ram &ram, Genode::Cap_session &cap, Child_registry &children,
|
||||
Subsystem_config_registry &subsustem_configs,
|
||||
Signal_context_capability yield_response_sigh_cap,
|
||||
Signal_context_capability exit_sig_cap,
|
||||
Dataspace_capability ldso_ds)
|
||||
Start_command(Ram &ram,
|
||||
Genode::Pd_session &pd,
|
||||
Genode::Ram_session &ref_ram,
|
||||
Genode::Ram_session_capability ref_ram_cap,
|
||||
Genode::Region_map &local_rm,
|
||||
Child_registry &children,
|
||||
Subsystem_config_registry &subsustem_configs,
|
||||
Signal_context_capability yield_response_sigh_cap,
|
||||
Signal_context_capability exit_sig_cap)
|
||||
:
|
||||
Command("start", "create new subsystem"),
|
||||
_ram(ram), _children(children), _cap(cap),
|
||||
_ram(ram), _children(children), _pd(pd),
|
||||
_ref_ram(ref_ram), _ref_ram_cap(ref_ram_cap), _local_rm(local_rm),
|
||||
_subsystem_configs(subsustem_configs),
|
||||
_yield_response_sigh_cap(yield_response_sigh_cap),
|
||||
_exit_sig_cap(exit_sig_cap),
|
||||
_ldso_ds(ldso_ds)
|
||||
_exit_sig_cap(exit_sig_cap)
|
||||
{
|
||||
add_parameter(new Parameter("--count", Parameter::NUMBER, "number of instances"));
|
||||
add_parameter(new Parameter("--ram", Parameter::NUMBER, "initial RAM quota"));
|
||||
|
@ -139,7 +139,7 @@ struct Status_command : Command
|
||||
Child_info child_info[num_children];
|
||||
unsigned i = 0;
|
||||
for (Child *c = _children.first(); c && i < num_children; c = c->next(), i++)
|
||||
child_info[i] = Child_info(c->name(), c->ram_status());
|
||||
child_info[i] = Child_info(c->name().string(), c->ram_status());
|
||||
|
||||
/*
|
||||
* Print table
|
||||
|
@ -32,8 +32,8 @@ struct Yield_command : Command
|
||||
|
||||
void _for_each_argument(Argument_fn const &fn) const override
|
||||
{
|
||||
auto child_name_fn = [&] (char const *child_name) {
|
||||
Argument arg(child_name, "");
|
||||
auto child_name_fn = [&] (Child_base::Name const &child_name) {
|
||||
Argument arg(child_name.string(), "");
|
||||
fn(arg);
|
||||
};
|
||||
|
||||
@ -57,7 +57,7 @@ struct Yield_command : Command
|
||||
/* lookup child by its unique name */
|
||||
Child *child = _children.first();
|
||||
for (; child; child = child->next())
|
||||
if (strcmp(child->name(), label) == 0)
|
||||
if (child->name() == label)
|
||||
break;
|
||||
|
||||
if (!child) {
|
||||
@ -67,7 +67,7 @@ struct Yield_command : Command
|
||||
|
||||
child->yield(ram, greedy);
|
||||
|
||||
tprintf(terminal, "requesting '%s' to yield ", child->name());
|
||||
tprintf(terminal, "requesting '%s' to yield ", child->name().string());
|
||||
tprint_bytes(terminal, ram);
|
||||
tprintf(terminal, "\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user