diff --git a/base/include/base/child.h b/base/include/base/child.h index a5e43c8e0b..3a35518289 100644 --- a/base/include/base/child.h +++ b/base/include/base/child.h @@ -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(); }; } diff --git a/base/include/parent/client.h b/base/include/parent/client.h index cfc53ec2d3..b69500601f 100644 --- a/base/include/parent/client.h +++ b/base/include/parent/client.h @@ -41,6 +41,19 @@ namespace Genode { Thread_capability main_thread_cap() const { return call(); } + + void resource_avail_sigh(Signal_context_capability sigh) { + call(sigh); } + + void resource_request(Resource_args const &args) { + call(args); } + + void yield_sigh(Signal_context_capability sigh) { + call(sigh); } + + Resource_args yield_request() { return call(); } + + void yield_response() { call(); } }; } diff --git a/base/include/parent/parent.h b/base/include/parent/parent.h index 448693c32a..0799eb8ec6 100644 --- a/base/include/parent/parent.h +++ b/base/include/parent/parent.h @@ -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=" 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_functions; }; } diff --git a/base/src/base/child/child.cc b/base/src/base/child/child.cc index 97b17bf3a7..fa26656956 100644 --- a/base/src/base/child/child.cc +++ b/base/src/base/child/child.cc @@ -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, diff --git a/base/src/core/include/core_parent.h b/base/src/core/include/core_parent.h index 4c0dadb866..33dfd9ec15 100644 --- a/base/src/core/include/core_parent.h +++ b/base/src/core/include/core_parent.h @@ -18,53 +18,37 @@ #include #include -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_ */