|
Public Types |
enum | Sched_mode { Periodic = 0x1,
Nonstrict = 0x2
} |
| Definition of different scheduling modes. More...
|
enum | Helping_mode { Helping,
Not_Helping,
Ignore_Helping
} |
| Definition of different helping modes. More...
|
Public Member Functions |
void | init_switch_time () |
| Initialize cpu time of the idle thread.
|
Cpu_time | consumed_time () |
| Return consumed CPU time.
|
Utcb * | utcb () const |
| Get the kernel UTCB pointer.
|
| Context (Thread_lock *thread_lock, Space *space, unsigned short prio, unsigned short mcp, Unsigned64 quantum) |
| Initialize a context.
|
virtual | ~Context () |
| Destroy context.
|
Mword | state () const |
| State flags.
|
Mword | exists () const |
| Does the context exist? .
|
void | state_add (Mword const bits) |
| Atomically add bits to state flags.
|
void | state_del (Mword const bits) |
| Atomically delete bits from state flags.
|
Mword | state_change_safely (Mword const mask, Mword const bits) |
| Atomically delete and add bits in state flags, provided the following rules apply (otherwise state is not changed at all):
- Bits that are to be set must be clear in state or clear in mask
- Bits that are to be cleared must be set in state.
|
Mword | state_change (Mword const mask, Mword const bits) |
| Atomically delete and add bits in state flags.
|
void | state_change_dirty (Mword const mask, Mword const bits) |
| Delete and add bits in state flags.
|
Space * | space () const |
| Return the space context.
|
Thread_lock *const | thread_lock () const |
| Thread lock.
|
unsigned short const | mcp () const |
Entry_frame *const | regs () const |
| Registers used when iret'ing to user mode.
|
void | inc_lock_cnt () |
| Increment lock count.
|
void | dec_lock_cnt () |
| Decrement lock count.
|
int const | lock_cnt () const |
| Lock count.
|
void | switch_sched (Sched_context *const next) |
| Switch active timeslice of this Context.
|
void | schedule () |
| Select a different context for running and activate it.
|
Sched_context * | sched_context (unsigned short const id=0) |
| Return Context's Sched_context with id 'id'; return time slice 0 as default.
|
Sched_context * | sched () const |
| Return Context's currently active Sched_context.
|
Unsigned64 const | period () const |
| Return Context's real-time period length.
|
Context::Sched_mode const | mode () const |
| Return Context's scheduling mode.
|
void | set_mode (Context::Sched_mode const mode) |
| Set Context's scheduling mode.
|
Mword const | in_ready_list () const |
| Check if Context is in ready-list.
|
void | ready_enqueue () |
| Enqueue context in ready-list.
|
void | ready_dequeue () |
| Remove context from ready-list.
|
Context *const | helper () const |
| Helper.
|
void | set_helper (enum Helping_mode const mode) |
Context *const | donatee () const |
| Donatee.
|
void | set_donatee (Context *const donatee) |
Mword *const | get_kernel_sp () const |
void | set_kernel_sp (Mword *const esp) |
Fpu_state * | fpu_state () |
void | consume_time (Cpu_time const quantum) |
| Add to consumed CPU time.
|
void | switch_to (Context *t) |
| Switch to scheduling context and execution context while not running under CPU lock.
|
void | switch_to_locked (Context *t) |
| Switch scheduling context and execution context.
|
void | switch_exec (Context *t, enum Helping_mode mode) |
| Switch execution context while not running under CPU lock.
|
void | switch_exec_locked (Context *t, enum Helping_mode mode) |
| Switch to a specific different execution context.
|
GThread_num | gthread_calculated () |
LThread_num | lthread_calculated () |
LThread_num | task_calculated () |
void | update_kip_switch_time (Context *t) |
Static Public Member Functions |
static bool const | schedule_in_progress () |
| Return if there is currently a schedule() in progress.
|
static bool const | can_preempt_current (Sched_context const *const s) |
| Return true if s can preempt the current scheduling context, false otherwise.
|
static Sched_context *const | current_sched () |
| Return currently active global Sched_context.
|
Static Public Attributes |
static const size_t | size = Config::thread_block_size |
| Size of a Context (TCB + kernel stack).
|
Protected Member Functions |
void | update_consumed_time () |
| Update consumed CPU time during each context switch and when reading out the current thread's consumed CPU time.
|
void | send_activation (unsigned) |
void | set_sched (Sched_context *const sched) |
| Set Context's currently active Sched_context.
|
void | set_period (Unsigned64 const period) |
| Set Context's real-time period length.
|
void | switch_gdt_tls () |
void | load_segments () |
void | store_segments () |
Static Protected Member Functions |
static void | set_current_sched (Sched_context *const sched) |
| Set currently active global Sched_context.
|
static void | invalidate_sched () |
| Invalidate (expire) currently active global Sched_context.
|
Protected Attributes |
Mword | _state |
Mword * | _kernel_sp |
Private Member Functions |
void | switchin_context () asm("switchin_context_label") FIASCO_FASTCALL |
| low level page table switching stuff
|
void | switch_fpu (Context *t) |
| low level fpu switching stuff
|
void | switch_cpu (Context *t) |
| low level cpu switching stuff
|
void | update_ready_list () |
| Enqueue current() if ready to fix up ready-list invariant.
|
Static Private Member Functions |
static Sched_context *_current_sched | asm ("CONTEXT_CURRENT_SCHED") |
static Cpu_time _switch_time | asm ("CONTEXT_SWITCH_TIME") |
static unsigned _prio_highest | asm ("CONTEXT_PRIO_HIGHEST") |
static Context *_prio_next[256] | asm ("CONTEXT_PRIO_NEXT") |
Private Attributes |
Space * | _space |
Context * | _donatee |
Context * | _helper |
int | _lock_cnt |
Thread_lock *const | _thread_lock |
Sched_context | _sched_context |
Sched_context * | _sched |
Unsigned64 | _period |
Sched_mode | _mode |
unsigned short | _mcp |
Fpu_state | _fpu_state |
Cpu_time | _consumed_time |
Context * | _ready_next |
Context * | _ready_prev |
Static Private Attributes |
static bool | _schedule_in_progress |
Friends |
class | Jdb_thread_list |
class | Jdb |
class | Jdb_tcb |
Related Functions |
(Note that these are not member functions.)
|
void | thread_handle_fputrap () |
| A C interface for Context::handle_fpu_trap, callable from assembly code.
|
A context is a runnable, schedulable activity. It carries along some state used by other subsystems: A lock count, and stack-element forward/next pointers.