mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
parent
ce9e43ae51
commit
3a4f7128fd
@ -38,7 +38,7 @@ void Kernel::Execution_context::_interrupt(unsigned const processor_id)
|
||||
if (timer()->interrupt_id(processor_id) == irq_id)
|
||||
{
|
||||
/* handle scheduling timeout */
|
||||
_processor->scheduler()->yield();
|
||||
__processor->scheduler()->yield();
|
||||
timer()->clear_interrupt(processor_id);
|
||||
reset_lap_time(processor_id);
|
||||
} else {
|
||||
@ -50,3 +50,21 @@ void Kernel::Execution_context::_interrupt(unsigned const processor_id)
|
||||
/* end interrupt request at controller */
|
||||
pic()->finish_request();
|
||||
}
|
||||
|
||||
|
||||
void Kernel::Execution_context::_schedule()
|
||||
{
|
||||
__processor->scheduler()->insert(this);
|
||||
}
|
||||
|
||||
|
||||
void Kernel::Execution_context::_unschedule()
|
||||
{
|
||||
__processor->scheduler()->remove(this);
|
||||
}
|
||||
|
||||
|
||||
void Kernel::Execution_context::_yield()
|
||||
{
|
||||
__processor->scheduler()->yield();
|
||||
}
|
||||
|
@ -297,9 +297,11 @@ class Kernel::Scheduler
|
||||
|
||||
class Kernel::Execution_context : public Cpu_scheduler::Item
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
Processor * _processor;
|
||||
Processor * __processor;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Handle an interrupt exception that occured during execution
|
||||
@ -308,6 +310,31 @@ class Kernel::Execution_context : public Cpu_scheduler::Item
|
||||
*/
|
||||
void _interrupt(unsigned const processor_id);
|
||||
|
||||
/**
|
||||
* Insert context into the processor scheduling
|
||||
*/
|
||||
void _schedule();
|
||||
|
||||
/**
|
||||
* Remove context from the processor scheduling
|
||||
*/
|
||||
void _unschedule();
|
||||
|
||||
/**
|
||||
* Yield currently scheduled processor share of the context
|
||||
*/
|
||||
void _yield();
|
||||
|
||||
|
||||
/***************
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
void _processor(Processor * const processor)
|
||||
{
|
||||
__processor = processor;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -327,9 +354,14 @@ class Kernel::Execution_context : public Cpu_scheduler::Item
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param p scheduling priority
|
||||
* \param processor kernel object of targeted processor
|
||||
* \param priority scheduling priority
|
||||
*/
|
||||
Execution_context(Priority const p) : Cpu_scheduler::Item(p) { }
|
||||
Execution_context(Processor * const processor, Priority const priority)
|
||||
:
|
||||
Cpu_scheduler::Item(priority),
|
||||
__processor(processor)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -166,21 +166,21 @@ void Thread::_pause()
|
||||
void Thread::_schedule()
|
||||
{
|
||||
if (_state == SCHEDULED) { return; }
|
||||
_processor->scheduler()->insert(this);
|
||||
Execution_context::_schedule();
|
||||
_state = SCHEDULED;
|
||||
}
|
||||
|
||||
|
||||
void Thread::_unschedule(State const s)
|
||||
{
|
||||
if (_state == SCHEDULED) { _processor->scheduler()->remove(this); }
|
||||
if (_state == SCHEDULED) { Execution_context::_unschedule(); }
|
||||
_state = s;
|
||||
}
|
||||
|
||||
|
||||
Thread::Thread(unsigned const priority, char const * const label)
|
||||
:
|
||||
Execution_context(priority),
|
||||
Execution_context(0, priority),
|
||||
Thread_cpu_support(this),
|
||||
_state(AWAITS_START),
|
||||
_pd(0),
|
||||
@ -201,7 +201,7 @@ Thread::init(Processor * const processor, unsigned const pd_id_arg,
|
||||
assert(_state == AWAITS_START)
|
||||
|
||||
/* store thread parameters */
|
||||
_processor = processor;
|
||||
Execution_context::_processor(processor);
|
||||
_utcb_phys = utcb_phys;
|
||||
|
||||
/* join protection domain */
|
||||
@ -446,7 +446,7 @@ void Thread::_call_yield_thread()
|
||||
{
|
||||
Thread * const t = Thread::pool()->object(user_arg_1());
|
||||
if (t) { t->_receive_yielded_cpu(); }
|
||||
_processor->scheduler()->yield();
|
||||
Execution_context::_yield();
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,21 +63,19 @@ class Kernel::Vm : public Object<Vm, MAX_VMS, Vm_ids, vm_ids, vm_pool>,
|
||||
Vm(void * const state,
|
||||
Signal_context * const context)
|
||||
:
|
||||
Execution_context(Priority::MIN),
|
||||
Execution_context(multiprocessor()->primary(), Priority::MIN),
|
||||
_state((Vm_state * const)state),
|
||||
_context(context)
|
||||
{
|
||||
_processor = multiprocessor()->primary();
|
||||
}
|
||||
{ }
|
||||
|
||||
|
||||
/****************
|
||||
** Vm_session **
|
||||
****************/
|
||||
|
||||
void run() { _processor->scheduler()->insert(this); }
|
||||
void run() { Execution_context::_schedule(); }
|
||||
|
||||
void pause() { _processor->scheduler()->remove(this); }
|
||||
void pause() { Execution_context::_unschedule(); }
|
||||
|
||||
|
||||
/***********************
|
||||
@ -94,7 +92,7 @@ class Kernel::Vm : public Object<Vm, MAX_VMS, Vm_ids, vm_ids, vm_pool>,
|
||||
case Genode::Cpu_state::DATA_ABORT:
|
||||
_state->dfar = Genode::Cpu::Dfar::read();
|
||||
default:
|
||||
_processor->scheduler()->remove(this);
|
||||
Execution_context::_unschedule();
|
||||
_context->submit(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user