base-hw: distinguish core, idle, user threads

Do not only distinguish core and user threads, but the idle threads too.
Instead of a boolean value, introduce a new thread type.

Ref genodelabs/genode#4527
This commit is contained in:
Stefan Kalkowski 2022-06-14 11:22:50 +02:00 committed by Christian Helmuth
parent c74a8c9fa8
commit 5cfb9e3e9d
3 changed files with 17 additions and 11 deletions

View File

@ -109,7 +109,8 @@ Cpu::Idle_thread::Idle_thread(Board::Address_space_id_allocator &addr_space_id_a
Cpu &cpu, Cpu &cpu,
Pd &core_pd) Pd &core_pd)
: :
Thread { addr_space_id_alloc, user_irq_pool, cpu_pool, core_pd, "idle" } Thread { addr_space_id_alloc, user_irq_pool, cpu_pool, core_pd,
Cpu_priority::min(), 0, "idle", Thread::IDLE }
{ {
regs->ip = (addr_t)&idle_thread_main; regs->ip = (addr_t)&idle_thread_main;

View File

@ -369,7 +369,7 @@ void Thread::_call_restart_thread()
Thread &thread = *thread_ptr; Thread &thread = *thread_ptr;
if (!_core && (&pd() != &thread.pd())) { if (_type == USER && (&pd() != &thread.pd())) {
raw(*this, ": failed to lookup thread ", (unsigned)user_arg_1(), raw(*this, ": failed to lookup thread ", (unsigned)user_arg_1(),
" to restart it"); " to restart it");
_die(); _die();
@ -793,7 +793,7 @@ void Thread::_call()
case call_id_pause_vm(): _call_pause_vm(); return; case call_id_pause_vm(): _call_pause_vm(); return;
default: default:
/* check wether this is a core thread */ /* check wether this is a core thread */
if (!_core) { if (_type != CORE) {
Genode::raw(*this, ": not entitled to do kernel call"); Genode::raw(*this, ": not entitled to do kernel call");
_die(); _die();
return; return;
@ -805,7 +805,7 @@ void Thread::_call()
_call_new<Thread>(_addr_space_id_alloc, _user_irq_pool, _cpu_pool, _call_new<Thread>(_addr_space_id_alloc, _user_irq_pool, _cpu_pool,
_core_pd, (unsigned) user_arg_2(), _core_pd, (unsigned) user_arg_2(),
(unsigned) _core_to_kernel_quota(user_arg_3()), (unsigned) _core_to_kernel_quota(user_arg_3()),
(char const *) user_arg_4()); (char const *) user_arg_4(), USER);
return; return;
case call_id_new_core_thread(): case call_id_new_core_thread():
_call_new<Thread>(_addr_space_id_alloc, _user_irq_pool, _cpu_pool, _call_new<Thread>(_addr_space_id_alloc, _user_irq_pool, _cpu_pool,
@ -857,7 +857,7 @@ void Thread::_mmu_exception()
return; return;
} }
if (_core) if (_type != USER)
Genode::raw(*this, " raised a fault, which should never happen ", Genode::raw(*this, " raised a fault, which should never happen ",
_fault); _fault);
@ -874,7 +874,7 @@ Thread::Thread(Board::Address_space_id_allocator &addr_space_id_alloc,
unsigned const priority, unsigned const priority,
unsigned const quota, unsigned const quota,
char const *const label, char const *const label,
bool core) Type type)
: :
Kernel::Object { *this }, Kernel::Object { *this },
Cpu_job { priority, quota }, Cpu_job { priority, quota },
@ -885,8 +885,8 @@ Thread::Thread(Board::Address_space_id_allocator &addr_space_id_alloc,
_ipc_node { *this }, _ipc_node { *this },
_state { AWAITS_START }, _state { AWAITS_START },
_label { label }, _label { label },
_core { core }, _type { type },
regs { core } regs { type != USER }
{ } { }

View File

@ -57,6 +57,10 @@ struct Kernel::Thread_fault
*/ */
class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
{ {
public:
enum Type { USER, CORE, IDLE };
private: private:
/* /*
@ -149,7 +153,7 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
capid_t _timeout_sigid { 0 }; capid_t _timeout_sigid { 0 };
bool _paused { false }; bool _paused { false };
bool _cancel_next_await_signal { false }; bool _cancel_next_await_signal { false };
bool const _core { false }; Type const _type;
Genode::Constructible<Tlb_invalidation> _tlb_invalidation {}; Genode::Constructible<Tlb_invalidation> _tlb_invalidation {};
Genode::Constructible<Destroy> _destroy {}; Genode::Constructible<Destroy> _destroy {};
@ -301,7 +305,7 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
unsigned const priority, unsigned const priority,
unsigned const quota, unsigned const quota,
char const *const label, char const *const label,
bool core = false); Type const type);
/** /**
* Constructor for core/kernel thread * Constructor for core/kernel thread
@ -315,7 +319,7 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
char const *const label) char const *const label)
: :
Thread(addr_space_id_alloc, user_irq_pool, cpu_pool, core_pd, Thread(addr_space_id_alloc, user_irq_pool, cpu_pool, core_pd,
Cpu_priority::min(), 0, label, true) Cpu_priority::min(), 0, label, CORE)
{ } { }
~Thread(); ~Thread();
@ -432,6 +436,7 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
char const * label() const { return _label; } char const * label() const { return _label; }
Thread_fault fault() const { return _fault; } Thread_fault fault() const { return _fault; }
Genode::Native_utcb *utcb() { return _utcb; } Genode::Native_utcb *utcb() { return _utcb; }
Type type() const { return _type; }
Pd &pd() const Pd &pd() const
{ {