BeRTOS
Defines | Functions | Variables
proc_p.h File Reference

Internal scheduler structures and definitions for processes. More...

#include "cfg/cfg_proc.h"
#include "cfg/cfg_monitor.h"
#include <cfg/compiler.h>
#include <cpu/types.h>
#include <cpu/irq.h>
#include <kern/proc.h>

Go to the source code of this file.

Defines

#define SCHED_ENQUEUE(proc)
 Enqueue a process in the ready list.
Flags for Process.flags.
#define PF_FREESTACK   BV(0)
 Free the stack when process dies.

Functions

EXTERN_C void asm_switch_context (cpu_stack_t **new_sp, cpu_stack_t **save_sp)
 CPU dependent context switching routines.
void sched_reenqueue (struct Process *proc)
 Changes the priority of an already enqueued process.
void proc_entry (void)
 Entry point for all the processes.
void proc_switch (void)
 Give the control of the CPU to another process.
void proc_wakeup (Process *proc)
 Immediately wakeup a process, dispatching it to the CPU.

Variables

REGISTER Process * current_process
 Track running processes.
REGISTER List proc_ready_list
 Track ready processes.

Detailed Description

Internal scheduler structures and definitions for processes.

Author:
Bernie Innocenti <bernie@codewiz.org>

Definition in file proc_p.h.


Define Documentation

#define SCHED_ENQUEUE (   proc)
Value:
do { \
        IRQ_ASSERT_DISABLED(); \
        LIST_ASSERT_VALID(&proc_ready_list); \
        SCHED_ENQUEUE_INTERNAL(proc); \
    } while (0)

Enqueue a process in the ready list.

Always use this macro to instert a process in the ready list, as its might vary to implement a different scheduling algorithms.

Note:
Access to the scheduler ready list must be performed with interrupts disabled.

Definition at line 108 of file proc_p.h.


Function Documentation

EXTERN_C void asm_switch_context ( cpu_stack_t **  new_sp,
cpu_stack_t **  save_sp 
)

CPU dependent context switching routines.

Saving and restoring the context on the stack is done by a CPU-dependent support routine which usually needs to be written in assembly.

void proc_switch ( void  )

Give the control of the CPU to another process.

Note:
Assume the current process has been already added to a wait queue.
Warning:
This should be considered an internal kernel function, even if it is allowed, usage from application code is strongly discouraged.

Definition at line 604 of file proc.c.

void sched_reenqueue ( struct Process *  proc) [inline]

Changes the priority of an already enqueued process.

Searches and removes the process from the ready list, then uses LIST_ENQUEUE(() to insert again to fix priority.

No action is performed for processes that aren't in the ready list, eg. in semaphore queues.

Note:
Performance could be improved with a different implementation of priority list.

Definition at line 132 of file proc_p.h.


Variable Documentation

REGISTER Process* current_process

Track running processes.

Definition at line 127 of file proc.c.

Track ready processes.

Access to this list must be performed with interrupts disabled

Definition at line 120 of file proc.c.