diff --git a/base-hw/include/kernel/interface.h b/base-hw/include/kernel/interface.h index d5a7252a8..17d974c77 100644 --- a/base-hw/include/kernel/interface.h +++ b/base-hw/include/kernel/interface.h @@ -35,18 +35,18 @@ namespace Kernel /** * Kernel names of the kernel calls */ - constexpr Call_arg call_id_pause_thread() { return 0; } - constexpr Call_arg call_id_resume_thread() { return 1; } - constexpr Call_arg call_id_yield_thread() { return 2; } - constexpr Call_arg call_id_send_request_msg() { return 3; } - constexpr Call_arg call_id_send_reply_msg() { return 4; } - constexpr Call_arg call_id_await_request_msg() { return 5; } - constexpr Call_arg call_id_kill_signal_context() { return 6; } - constexpr Call_arg call_id_submit_signal() { return 7; } - constexpr Call_arg call_id_await_signal() { return 8; } - constexpr Call_arg call_id_signal_pending() { return 9; } - constexpr Call_arg call_id_ack_signal() { return 10; } - constexpr Call_arg call_id_print_char() { return 11; } + constexpr Call_arg call_id_pause_current_thread() { return 0; } + constexpr Call_arg call_id_resume_thread() { return 1; } + constexpr Call_arg call_id_yield_thread() { return 2; } + constexpr Call_arg call_id_send_request_msg() { return 3; } + constexpr Call_arg call_id_send_reply_msg() { return 4; } + constexpr Call_arg call_id_await_request_msg() { return 5; } + constexpr Call_arg call_id_kill_signal_context() { return 6; } + constexpr Call_arg call_id_submit_signal() { return 7; } + constexpr Call_arg call_id_await_signal() { return 8; } + constexpr Call_arg call_id_signal_pending() { return 9; } + constexpr Call_arg call_id_ack_signal() { return 10; } + constexpr Call_arg call_id_print_char() { return 11; } /***************************************************************** @@ -86,16 +86,11 @@ namespace Kernel /** - * Prevent thread from participating in CPU scheduling - * - * \param thread_id kernel name of the targeted thread or 0 - * - * If thread_id is set to 0 the caller targets itself. If the caller - * doesn't target itself, the call is restricted to core threads. + * Pause execution of calling thread */ - inline void pause_thread(unsigned const thread_id) + inline void pause_current_thread() { - call(call_id_pause_thread(), thread_id); + call(call_id_pause_current_thread()); } diff --git a/base-hw/src/base/ipc.cc b/base-hw/src/base/ipc.cc index ede94f725..1de92fdcb 100644 --- a/base-hw/src/base/ipc.cc +++ b/base-hw/src/base/ipc.cc @@ -55,7 +55,7 @@ Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) void Ipc_istream::_wait() { /* FIXME: this shall be not supported */ - Kernel::pause_thread(0); + Kernel::pause_current_thread(); } diff --git a/base-hw/src/base/lock/lock_helper.h b/base-hw/src/base/lock/lock_helper.h index 4798a183c..6b2032cb4 100644 --- a/base-hw/src/base/lock/lock_helper.h +++ b/base-hw/src/base/lock/lock_helper.h @@ -59,7 +59,7 @@ thread_check_stopped_and_restart(Genode::Thread_base * const t) /** * Pause execution of current thread */ -static inline void thread_stop_myself() { Kernel::pause_thread(0); } +static inline void thread_stop_myself() { Kernel::pause_current_thread(); } #endif /* _LOCK_HELPER_H_ */ diff --git a/base-hw/src/core/include/platform.h b/base-hw/src/core/include/platform.h index 8efd942dc..cb272a587 100644 --- a/base-hw/src/core/include/platform.h +++ b/base-hw/src/core/include/platform.h @@ -109,7 +109,7 @@ namespace Genode { inline void wait_for_exit() { - while (1) { Kernel::pause_thread(0); } + while (1) { Kernel::pause_current_thread(); } }; bool supports_direct_unmap() const { return 1; } diff --git a/base-hw/src/core/kernel/core_interface.h b/base-hw/src/core/kernel/core_interface.h index 6f29262f1..3ce98dd76 100644 --- a/base-hw/src/core/kernel/core_interface.h +++ b/base-hw/src/core/kernel/core_interface.h @@ -47,6 +47,7 @@ namespace Kernel constexpr Call_arg call_id_new_vm() { return 25; } constexpr Call_arg call_id_run_vm() { return 26; } constexpr Call_arg call_id_pause_vm() { return 27; } + constexpr Call_arg call_id_pause_thread() { return 28; } /** * Create a domain @@ -122,6 +123,17 @@ namespace Kernel } + /** + * Pause execution of a specific thread + * + * \param thread_id kernel name of the targeted thread + */ + inline void pause_thread(unsigned const thread_id) + { + call(call_id_pause_thread(), thread_id); + } + + /** * Destruct a thread * diff --git a/base-hw/src/core/kernel/thread.cc b/base-hw/src/core/kernel/thread.cc index 8c57d1f89..743544e06 100644 --- a/base-hw/src/core/kernel/thread.cc +++ b/base-hw/src/core/kernel/thread.cc @@ -380,25 +380,20 @@ void Thread::_call_start_thread() } +void Thread::_call_pause_current_thread() { _pause(); } + + void Thread::_call_pause_thread() { - /* take a shortcut if a thread wants to pause itself */ - unsigned const thread_id = user_arg_1(); - if (!thread_id || thread_id == id()) { - _pause(); - return; - } /* check permissions */ if (!_core()) { PWRN("not entitled to pause thread"); - _stop(); return; } /* lookup thread */ - Thread * const thread = Thread::pool()->object(thread_id); + Thread * const thread = Thread::pool()->object(user_arg_1()); if (!thread) { PWRN("failed to lookup thread"); - _stop(); return; } /* pause thread */ @@ -949,6 +944,7 @@ void Thread::_call(unsigned const processor_id) case call_id_new_thread(): _call_new_thread(); return; case call_id_bin_thread(): _call_bin_thread(); return; case call_id_start_thread(): _call_start_thread(); return; + case call_id_pause_current_thread(): _call_pause_current_thread(); return; case call_id_pause_thread(): _call_pause_thread(); return; case call_id_resume_thread(): _call_resume_thread(); return; case call_id_yield_thread(): _call_yield_thread(); return; diff --git a/base-hw/src/core/kernel/thread.h b/base-hw/src/core/kernel/thread.h index ab55deae1..4cfd61ba9 100644 --- a/base-hw/src/core/kernel/thread.h +++ b/base-hw/src/core/kernel/thread.h @@ -236,6 +236,7 @@ class Kernel::Thread void _call_new_thread(); void _call_bin_thread(); void _call_start_thread(); + void _call_pause_current_thread(); void _call_pause_thread(); void _call_resume_thread(); void _call_yield_thread();