hw: make _processor private to Execution_context

ref #1078
This commit is contained in:
Martin Stein 2014-02-28 15:43:59 +01:00 committed by Norman Feske
parent ce9e43ae51
commit 3a4f7128fd
4 changed files with 65 additions and 17 deletions

View File

@ -38,7 +38,7 @@ void Kernel::Execution_context::_interrupt(unsigned const processor_id)
if (timer()->interrupt_id(processor_id) == irq_id) if (timer()->interrupt_id(processor_id) == irq_id)
{ {
/* handle scheduling timeout */ /* handle scheduling timeout */
_processor->scheduler()->yield(); __processor->scheduler()->yield();
timer()->clear_interrupt(processor_id); timer()->clear_interrupt(processor_id);
reset_lap_time(processor_id); reset_lap_time(processor_id);
} else { } else {
@ -50,3 +50,21 @@ void Kernel::Execution_context::_interrupt(unsigned const processor_id)
/* end interrupt request at controller */ /* end interrupt request at controller */
pic()->finish_request(); 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();
}

View File

@ -297,9 +297,11 @@ class Kernel::Scheduler
class Kernel::Execution_context : public Cpu_scheduler::Item class Kernel::Execution_context : public Cpu_scheduler::Item
{ {
protected: private:
Processor * _processor; Processor * __processor;
protected:
/** /**
* Handle an interrupt exception that occured during execution * 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); 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: public:
/** /**
@ -327,9 +354,14 @@ class Kernel::Execution_context : public Cpu_scheduler::Item
/** /**
* Constructor * 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 * Destructor

View File

@ -166,21 +166,21 @@ void Thread::_pause()
void Thread::_schedule() void Thread::_schedule()
{ {
if (_state == SCHEDULED) { return; } if (_state == SCHEDULED) { return; }
_processor->scheduler()->insert(this); Execution_context::_schedule();
_state = SCHEDULED; _state = SCHEDULED;
} }
void Thread::_unschedule(State const s) void Thread::_unschedule(State const s)
{ {
if (_state == SCHEDULED) { _processor->scheduler()->remove(this); } if (_state == SCHEDULED) { Execution_context::_unschedule(); }
_state = s; _state = s;
} }
Thread::Thread(unsigned const priority, char const * const label) Thread::Thread(unsigned const priority, char const * const label)
: :
Execution_context(priority), Execution_context(0, priority),
Thread_cpu_support(this), Thread_cpu_support(this),
_state(AWAITS_START), _state(AWAITS_START),
_pd(0), _pd(0),
@ -201,7 +201,7 @@ Thread::init(Processor * const processor, unsigned const pd_id_arg,
assert(_state == AWAITS_START) assert(_state == AWAITS_START)
/* store thread parameters */ /* store thread parameters */
_processor = processor; Execution_context::_processor(processor);
_utcb_phys = utcb_phys; _utcb_phys = utcb_phys;
/* join protection domain */ /* join protection domain */
@ -446,7 +446,7 @@ void Thread::_call_yield_thread()
{ {
Thread * const t = Thread::pool()->object(user_arg_1()); Thread * const t = Thread::pool()->object(user_arg_1());
if (t) { t->_receive_yielded_cpu(); } if (t) { t->_receive_yielded_cpu(); }
_processor->scheduler()->yield(); Execution_context::_yield();
} }

View File

@ -63,21 +63,19 @@ class Kernel::Vm : public Object<Vm, MAX_VMS, Vm_ids, vm_ids, vm_pool>,
Vm(void * const state, Vm(void * const state,
Signal_context * const context) Signal_context * const context)
: :
Execution_context(Priority::MIN), Execution_context(multiprocessor()->primary(), Priority::MIN),
_state((Vm_state * const)state), _state((Vm_state * const)state),
_context(context) _context(context)
{ { }
_processor = multiprocessor()->primary();
}
/**************** /****************
** Vm_session ** ** 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: case Genode::Cpu_state::DATA_ABORT:
_state->dfar = Genode::Cpu::Dfar::read(); _state->dfar = Genode::Cpu::Dfar::read();
default: default:
_processor->scheduler()->remove(this); Execution_context::_unschedule();
_context->submit(1); _context->submit(1);
} }
} }