proc.c File Reference

Simple realtime multitasking scheduler. More...

#include "proc_p.h"
#include "proc.h"
#include <mware/event.h>
#include <cpu/irq.h>
#include <cpu/types.h>
#include <cpu/attr.h>
#include <cfg/debug.h>
#include <cfg/module.h>
#include <cfg/arch_config.h>
#include <cfg/macros.h>
#include <string.h>

Go to the source code of this file.


Functions

EXTERN_C void asm_switch_context (cpustack_t **new_sp, cpustack_t **save_sp)
 CPU dependent context switching routines.
struct Process * proc_new_with_name (UNUSED(const char *, name), void(*entry)(void), iptr_t data, size_t stacksize, cpustack_t *stack_base)
 Create a new process, starting at the provided entry point.
void proc_rename (struct Process *proc, const char *name)
 Rename a process.
void proc_schedule (void)
 System scheduler: pass CPU control to the next process in the ready queue.
void proc_exit (void)
 Terminate the current process.
void proc_switch (void)
 Co-operative context switch.
struct Process * proc_current (void)
 Get the pointer to the current process.
iptr_t proc_current_user_data (void)
 Get the pointer to the user data of the current process.

Variables

REGISTER Process * CurrentProcess
 Track running processes.
REGISTER List ProcReadyList
 Track ready processes.
struct Process MainProcess
 The main process (the one that executes main()).

Detailed Description

Simple realtime multitasking scheduler.

Context switching is only done cooperatively.

Version:
Id
proc.c 1230 2008-04-09 16:17:58Z batt

Author:
Bernardo Innocenti <bernie@develer.com>

Stefano Fedrigo <aleph@develer.com>

Definition in file proc.c.


Function Documentation

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

CPU dependent context switching routines.

Note:
This function *MUST* preserve also the status of the interrupts.

struct Process* proc_new_with_name ( UNUSED(const char *, name)  ,
void(*)(void)  entry,
iptr_t  data,
size_t  stacksize,
cpustack_t *  stack_base 
) [read]

Create a new process, starting at the provided entry point.

Returns:
Process structure of new created process if successful, NULL otherwise.

Definition at line 142 of file proc.c.

void proc_schedule ( void   ) 

System scheduler: pass CPU control to the next process in the ready queue.

Schedule to another process *without* adding the current to the ready list.

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

Definition at line 244 of file proc.c.


Variable Documentation

REGISTER Process* CurrentProcess

Track running processes.

Definition at line 73 of file proc.c.

struct Process MainProcess

The main process (the one that executes main()).

Definition at line 92 of file proc.c.

REGISTER List ProcReadyList

Track ready processes.

Definition at line 74 of file proc.c.