hw: rename functions of Ipc_node class signature

* Remove *request* in context of: wait, reply, send to shorten it.
* Use ready_to_* instead of can_*, which is regularily used in Genode's APIs
* Replace helping_sink with helping_destination, as destination is more common

Ref genodelabs/genode#4704
This commit is contained in:
Stefan Kalkowski 2022-12-16 12:07:47 +01:00 committed by Christian Helmuth
parent fd3c70ec5b
commit 1151706243
7 changed files with 48 additions and 43 deletions

View File

@ -172,7 +172,7 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout
* Returns the currently active job * Returns the currently active job
*/ */
Job & scheduled_job() const { Job & scheduled_job() const {
return *static_cast<Job *>(&_scheduler.head())->helping_sink(); } return *static_cast<Job *>(&_scheduler.head())->helping_destination(); }
unsigned id() const { return _id; } unsigned id() const { return _id; }
Cpu_scheduler &scheduler() { return _scheduler; } Cpu_scheduler &scheduler() { return _scheduler; }

View File

@ -88,7 +88,7 @@ class Kernel::Cpu_job : private Cpu_share
/** /**
* Return which job currently uses our CPU-share * Return which job currently uses our CPU-share
*/ */
virtual Cpu_job * helping_sink() = 0; virtual Cpu_job * helping_destination() = 0;
/** /**
* Construct a job with scheduling priority 'p' and time quota 'q' * Construct a job with scheduling priority 'p' and time quota 'q'

View File

@ -63,13 +63,13 @@ bool Ipc_node::_helping() const
} }
bool Ipc_node::can_send_request() const bool Ipc_node::ready_to_send() const
{ {
return _out.state == Out::READY && !_in.waiting(); return _out.state == Out::READY && !_in.waiting();
} }
void Ipc_node::send_request(Ipc_node &node, bool help) void Ipc_node::send(Ipc_node &node, bool help)
{ {
node._in.queue.enqueue(_queue_item); node._in.queue.enqueue(_queue_item);
@ -82,19 +82,19 @@ void Ipc_node::send_request(Ipc_node &node, bool help)
} }
Thread &Ipc_node::helping_sink() Thread &Ipc_node::helping_destination()
{ {
return _helping() ? _out.node->helping_sink() : _thread; return _helping() ? _out.node->helping_destination() : _thread;
} }
bool Ipc_node::can_await_request() const bool Ipc_node::ready_to_wait() const
{ {
return _in.state == In::READY; return _in.state == In::READY;
} }
void Ipc_node::await_request() void Ipc_node::wait()
{ {
_in.state = In::WAIT; _in.state = In::WAIT;
_in.queue.head([&] (Queue_item &item) { _in.queue.head([&] (Queue_item &item) {
@ -103,7 +103,7 @@ void Ipc_node::await_request()
} }
void Ipc_node::send_reply() void Ipc_node::reply()
{ {
if (_in.state == In::REPLY) if (_in.state == In::REPLY)
_in.queue.dequeue([&] (Queue_item &item) { _in.queue.dequeue([&] (Queue_item &item) {

View File

@ -89,30 +89,28 @@ class Kernel::Ipc_node
public: public:
/** Ipc_node(Thread &thread);
* Destructor
*/
~Ipc_node(); ~Ipc_node();
/** /**
* Constructor * Return whether this IPC node is ready to send a message
*/ */
Ipc_node(Thread &thread); bool ready_to_send() const;
/** /**
* Send a request and wait for the according reply * Send a message and wait for the according reply
* *
* \param node targeted IPC node * \param node targeted IPC node
* \param help wether the request implies a helping relationship * \param help wether the request implies a helping relationship
*/ */
bool can_send_request() const; void send(Ipc_node &node, bool help);
void send_request(Ipc_node &node,
bool help);
/** /**
* Return root destination of the helping-relation tree we are in * Return final destination of the helping-chain
* this IPC node is part of, or its own thread otherwise
*/ */
Thread &helping_sink(); Thread &helping_destination();
/** /**
* Call function 'f' of type 'void (Ipc_node *)' for each helper * Call function 'f' of type 'void (Ipc_node *)' for each helper
@ -128,24 +126,31 @@ class Kernel::Ipc_node
} }
/** /**
* Wait until a request has arrived and load it for handling * Return whether this IPC node is ready to wait for messages
*/
bool ready_to_wait() const;
/**
* Wait until a message has arrived, or handle it if one is available
* *
* \return wether a request could be received already * \return wether a message could be received already
*/ */
bool can_await_request() const; void wait();
void await_request();
/** /**
* Reply to last request if there's any * Reply to last message if there's any
*/ */
void send_reply(); void reply();
/** /**
* If IPC node waits, cancel '_outbuf' to stop waiting * If IPC node waits, cancel it
*/ */
void cancel_waiting(); void cancel_waiting();
bool awaits_request() const { return _in.waiting(); } /**
* Return whether this IPC node is waiting for messages
*/
bool waiting() const { return _in.waiting(); }
}; };
#endif /* _CORE__KERNEL__IPC_NODE_H_ */ #endif /* _CORE__KERNEL__IPC_NODE_H_ */

View File

@ -295,8 +295,8 @@ void Thread::_become_inactive(State const s)
void Thread::_die() { _become_inactive(DEAD); } void Thread::_die() { _become_inactive(DEAD); }
Cpu_job * Thread::helping_sink() { Cpu_job * Thread::helping_destination() {
return &_ipc_node.helping_sink(); } return &_ipc_node.helping_destination(); }
size_t Thread::_core_to_kernel_quota(size_t const quota) const size_t Thread::_core_to_kernel_quota(size_t const quota) const
@ -478,16 +478,16 @@ void Thread::_call_delete_pd()
void Thread::_call_await_request_msg() void Thread::_call_await_request_msg()
{ {
if (_ipc_node.can_await_request()) { if (_ipc_node.ready_to_wait()) {
_ipc_alloc_recv_caps((unsigned)user_arg_1()); _ipc_alloc_recv_caps((unsigned)user_arg_1());
_ipc_node.await_request(); _ipc_node.wait();
if (_ipc_node.awaits_request()) { if (_ipc_node.waiting()) {
_become_inactive(AWAITS_IPC); _become_inactive(AWAITS_IPC);
} else { } else {
user_arg_0(0); user_arg_0(0);
} }
} else { } else {
Genode::raw("IPC await request: bad state"); Genode::raw("IPC await request: bad state, will block");
_become_inactive(DEAD); _become_inactive(DEAD);
} }
} }
@ -539,12 +539,12 @@ void Thread::_call_send_request_msg()
bool const help = Cpu_job::_helping_possible(*dst); bool const help = Cpu_job::_helping_possible(*dst);
oir = oir->find(dst->pd()); oir = oir->find(dst->pd());
if (!_ipc_node.can_send_request()) { if (!_ipc_node.ready_to_send()) {
Genode::raw("IPC send request: bad state"); Genode::raw("IPC send request: bad state");
} else { } else {
_ipc_alloc_recv_caps((unsigned)user_arg_2()); _ipc_alloc_recv_caps((unsigned)user_arg_2());
_ipc_capid = oir ? oir->capid() : cap_id_invalid(); _ipc_capid = oir ? oir->capid() : cap_id_invalid();
_ipc_node.send_request(dst->_ipc_node, help); _ipc_node.send(dst->_ipc_node, help);
} }
_state = AWAITS_IPC; _state = AWAITS_IPC;
@ -554,7 +554,7 @@ void Thread::_call_send_request_msg()
void Thread::_call_send_reply_msg() void Thread::_call_send_reply_msg()
{ {
_ipc_node.send_reply(); _ipc_node.reply();
bool const await_request_msg = user_arg_2(); bool const await_request_msg = user_arg_2();
if (await_request_msg) { _call_await_request_msg(); } if (await_request_msg) { _call_await_request_msg(); }
else { user_arg_0(0); } else { user_arg_0(0); }

View File

@ -418,9 +418,9 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
** Cpu_job ** ** Cpu_job **
*************/ *************/
void exception(Cpu & cpu) override; void exception(Cpu & cpu) override;
void proceed(Cpu & cpu) override; void proceed(Cpu & cpu) override;
Cpu_job * helping_sink() override; Cpu_job * helping_destination() override;
/************* /*************

View File

@ -142,9 +142,9 @@ class Kernel::Vm : private Kernel::Object, public Cpu_job
** Cpu_job ** ** Cpu_job **
*************/ *************/
void exception(Cpu & cpu) override; void exception(Cpu & cpu) override;
void proceed(Cpu & cpu) override; void proceed(Cpu & cpu) override;
Cpu_job * helping_sink() override { return this; } Cpu_job * helping_destination() override { return this; }
}; };
#endif /* _CORE__KERNEL__VM_H_ */ #endif /* _CORE__KERNEL__VM_H_ */