mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
hw: split pause_current_thread from pause_thread
Kernel::pause_current_thread can be implemented much simpler and is not restricted to core threads, in contrast to Kernel::pause_thread which also benefits from the split and can be moved to core_interface.h. ref #1101
This commit is contained in:
parent
abd55fda9a
commit
fba4f54571
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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_ */
|
||||
|
@ -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; }
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user