mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 15:32:25 +00:00
Add resource-balancing support to parent interface
This is just the interface. The implementation is still missing. Issue #887
This commit is contained in:
parent
5befab7f3d
commit
f65606f179
@ -286,6 +286,11 @@ namespace Genode {
|
||||
void close(Session_capability);
|
||||
void exit(int);
|
||||
Thread_capability main_thread_cap() const;
|
||||
void resource_avail_sigh(Signal_context_capability);
|
||||
void resource_request(Resource_args const &);
|
||||
void yield_sigh(Signal_context_capability);
|
||||
Resource_args yield_request();
|
||||
void yield_response();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,19 @@ namespace Genode {
|
||||
|
||||
Thread_capability main_thread_cap() const {
|
||||
return call<Rpc_main_thread>(); }
|
||||
|
||||
void resource_avail_sigh(Signal_context_capability sigh) {
|
||||
call<Rpc_resource_avail_sigh>(sigh); }
|
||||
|
||||
void resource_request(Resource_args const &args) {
|
||||
call<Rpc_resource_request>(args); }
|
||||
|
||||
void yield_sigh(Signal_context_capability sigh) {
|
||||
call<Rpc_yield_sigh>(sigh); }
|
||||
|
||||
Resource_args yield_request() { return call<Rpc_yield_request>(); }
|
||||
|
||||
void yield_response() { call<Rpc_yield_response>(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,12 @@ namespace Genode {
|
||||
typedef Rpc_in_buffer<160> Session_args;
|
||||
typedef Rpc_in_buffer<160> Upgrade_args;
|
||||
|
||||
/**
|
||||
* Use 'String' instead of 'Rpc_in_buffer' because 'Resource_args'
|
||||
* is used as both in and out parameter.
|
||||
*/
|
||||
typedef String<160> Resource_args;
|
||||
|
||||
|
||||
virtual ~Parent() { }
|
||||
|
||||
@ -172,6 +178,54 @@ namespace Genode {
|
||||
*/
|
||||
virtual Thread_capability main_thread_cap() const = 0;
|
||||
|
||||
/**
|
||||
* Register signal handler for resource notifications
|
||||
*/
|
||||
virtual void resource_avail_sigh(Signal_context_capability sigh) = 0;
|
||||
|
||||
/**
|
||||
* Request additional resources
|
||||
*
|
||||
* By invoking this function, a process is able to inform its
|
||||
* parent about the need for additional resources. The argument
|
||||
* string contains a resource description in the same format as
|
||||
* used for session-construction arguments. In particular, for
|
||||
* requesting additional RAM quota, the argument looks like
|
||||
* "ram_quota=<amount>" where 'amount' is the amount of additional
|
||||
* resources expected from the parent. If the parent complies with
|
||||
* the request, it submits a resource-available signal to the
|
||||
* handler registered via 'resource_avail_sigh()'. On the reception
|
||||
* of such a signal, the process can re-evaluate its resource quota
|
||||
* and resume execution.
|
||||
*/
|
||||
virtual void resource_request(Resource_args const &args) = 0;
|
||||
|
||||
/**
|
||||
* Register signal handler for resource yield notifications
|
||||
*
|
||||
* Using the yield signal, the parent is able to inform the process
|
||||
* about its wish to regain resources.
|
||||
*/
|
||||
virtual void yield_sigh(Signal_context_capability sigh) = 0;
|
||||
|
||||
/**
|
||||
* Obtain information about the amount of resources to free
|
||||
*
|
||||
* The amount of resources returned by this function is the
|
||||
* goal set by the parent. It is not commanded but merely meant
|
||||
* as a friendly beg to cooperate. The process is not obligated
|
||||
* to comply. If the process decides to take action to free
|
||||
* resources, it can inform its parent about the availability
|
||||
* of freed up resources by calling 'yield_response()'.
|
||||
*/
|
||||
virtual Resource_args yield_request() = 0;
|
||||
|
||||
/**
|
||||
* Notify the parent about a response to a yield request
|
||||
*/
|
||||
virtual void yield_response() = 0;
|
||||
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
@ -187,9 +241,27 @@ namespace Genode {
|
||||
Session_capability, Upgrade_args const &);
|
||||
GENODE_RPC(Rpc_close, void, close, Session_capability);
|
||||
GENODE_RPC(Rpc_main_thread, Thread_capability, main_thread_cap);
|
||||
GENODE_RPC(Rpc_resource_avail_sigh, void, resource_avail_sigh,
|
||||
Signal_context_capability);
|
||||
GENODE_RPC(Rpc_resource_request, void, resource_request,
|
||||
Resource_args const &);
|
||||
GENODE_RPC(Rpc_yield_sigh, void, yield_sigh, Signal_context_capability);
|
||||
GENODE_RPC(Rpc_yield_request, Resource_args, yield_request);
|
||||
GENODE_RPC(Rpc_yield_response, void, yield_response);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_exit, Rpc_announce, Rpc_session, Rpc_upgrade,
|
||||
Rpc_close, Rpc_main_thread);
|
||||
typedef Meta::Type_tuple<Rpc_exit,
|
||||
Meta::Type_tuple<Rpc_announce,
|
||||
Meta::Type_tuple<Rpc_session,
|
||||
Meta::Type_tuple<Rpc_upgrade,
|
||||
Meta::Type_tuple<Rpc_close,
|
||||
Meta::Type_tuple<Rpc_main_thread,
|
||||
Meta::Type_tuple<Rpc_resource_avail_sigh,
|
||||
Meta::Type_tuple<Rpc_resource_request,
|
||||
Meta::Type_tuple<Rpc_yield_sigh,
|
||||
Meta::Type_tuple<Rpc_yield_request,
|
||||
Meta::Type_tuple<Rpc_yield_response,
|
||||
Meta::Empty>
|
||||
> > > > > > > > > > Rpc_functions;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -417,6 +417,21 @@ Thread_capability Child::main_thread_cap() const
|
||||
}
|
||||
|
||||
|
||||
void Child::resource_avail_sigh(Signal_context_capability) { }
|
||||
|
||||
|
||||
void Child::resource_request(Resource_args const &) { }
|
||||
|
||||
|
||||
void Child::yield_sigh(Signal_context_capability) { }
|
||||
|
||||
|
||||
Parent::Resource_args Child::yield_request() { return Resource_args(); }
|
||||
|
||||
|
||||
void Child::yield_response() { }
|
||||
|
||||
|
||||
Child::Child(Dataspace_capability elf_ds,
|
||||
Ram_session_capability ram,
|
||||
Cpu_session_capability cpu,
|
||||
|
@ -18,53 +18,37 @@
|
||||
#include <base/printf.h>
|
||||
#include <parent/parent.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* In fact, Core has _no_ parent. But most of our libraries could work
|
||||
* seamlessly inside Core too, if it had one. Core_parent fills this gap.
|
||||
*/
|
||||
class Core_parent : public Parent
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Core_parent() { }
|
||||
namespace Genode { struct Core_parent; }
|
||||
|
||||
|
||||
/**********************
|
||||
** Parent interface **
|
||||
**********************/
|
||||
/**
|
||||
* In fact, Core has _no_ parent. But most of our libraries could work
|
||||
* seamlessly inside Core too, if it had one. Core_parent fills this gap.
|
||||
*/
|
||||
struct Genode::Core_parent : Parent
|
||||
{
|
||||
void exit(int);
|
||||
|
||||
void exit(int);
|
||||
void announce(Service_name const &, Root_capability) { }
|
||||
|
||||
void announce(Service_name const &, Root_capability)
|
||||
{
|
||||
PDBG("implement me, please");
|
||||
}
|
||||
Session_capability session(Service_name const &, Session_args const &,
|
||||
Affinity const &);
|
||||
|
||||
Session_capability session(Service_name const &, Session_args const &,
|
||||
Affinity const &);
|
||||
void upgrade(Session_capability, Upgrade_args const &) { throw Quota_exceeded(); }
|
||||
|
||||
void upgrade(Session_capability, Upgrade_args const &)
|
||||
{
|
||||
PDBG("implement me, please");
|
||||
throw Quota_exceeded();
|
||||
}
|
||||
void close(Session_capability) { }
|
||||
|
||||
void close(Session_capability)
|
||||
{
|
||||
PDBG("implement me, please");
|
||||
}
|
||||
Thread_capability main_thread_cap() const { return Thread_capability(); }
|
||||
|
||||
Thread_capability main_thread_cap() const
|
||||
{
|
||||
PDBG("implement me, please");
|
||||
return Thread_capability();
|
||||
}
|
||||
};
|
||||
}
|
||||
void resource_avail_sigh(Signal_context_capability) { }
|
||||
|
||||
void resource_request(Resource_args const &) { }
|
||||
|
||||
void yield_sigh(Signal_context_capability) { }
|
||||
|
||||
Resource_args yield_request() { return Resource_args(); }
|
||||
|
||||
void yield_response() { }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_PARENT_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user