Defines | |||
#define | fatal (a) | ||
Functions | |||
void | tm_switcher (void) | ||
the task switcher. More... | |||
__asm__ (" .text .align 1 .globl _tm_switcher _tm_switcher: ; r6 saved by ROM ; r0 saved by system timer handler mov.w r1,@-r7 ; save registers mov.w r2,@-r7 mov.w r3,@-r7 mov.w r4,@-r7 mov.w r5,@-r7 mov.w r7,r0 ; pass sp jsr _tm_scheduler ; call scheduler _tm_switcher_return: mov.w r0,r7 ; set new sp mov.w @r7+,r5 mov.w @r7+,r4 mov.w @r7+,r3 mov.w @r7+,r2 mov.w @r7+,r1 ; r0 will be restored by system timer handler ; r6 will be restored by ROM rts ; return to new task ") | |||
size_t* | tm_scheduler (size_t *old_sp) | ||
the process scheduler. More... | |||
void | yield (void) | ||
yield the rest of the current timeslice. More... | |||
__asm__ (" .text .globl _yield .align 1 _yield: stc ccr,r0h ; to fake an IRQ, we have to push r0 ; store the registers orc #0x80,ccr ; disable interrupts push r6 ; store r6 mov.w #0x04d4,r0 ; store rom return addr push r0 push r0 ; store r0 (destroyed by call.) mov.w #_systime_tm_return,r0 ; store systime return addr push r0 jmp @_tm_switcher ; call task switcher ") | |||
int | tm_idle_task (int argc,char **argv) __attribute__ ((noreturn)) | ||
the idle task. More... | |||
__asm__ (" .text .align 1 _tm_idle_task: sleep bra _tm_idle_task ") | |||
void | tm_init (void) | ||
init task management. More... | |||
void | tm_start (void) | ||
start task management. More... | |||
pid_t | execi (int (*code_start)(int,char**),int argc, char **argv, priority_t priority,size_t stack_size) | ||
execute a memory image. More... | |||
void | exit (int code) | ||
exit task, returning code. More... | |||
wakeup_t | wait_event (wakeup_t (*wakeup)(wakeup_t),wakeup_t data) | ||
suspend process until wakeup function is non-null. More... | |||
wakeup_t | tm_sleep_wakeup (wakeup_t data) | ||
wakeup function for sleep. More... | |||
unsigned int | msleep (unsigned int msec) | ||
delay execution allowing other tasks to run. More... | |||
unsigned int | sleep (unsigned int sec) | ||
delay execution allowing other tasks to run. More... | |||
void | kill (pid_t pid) | ||
kill a process. More... | |||
void | killall (priority_t prio) | ||
kill all processes with priority lower or equal than p, excluding self. | |||
Variables | |||
pchain_t* | priority_head | ||
head of process priority chain. | |||
pdata_t | pd_single | ||
single process process data. | |||
pdata_t* | pd_idle | ||
idle proces. | |||
pdata_t* | cpid | ||
ptr to current process data. | |||
unsigned | nb_tasks | ||
number of tasks. | |||
sem_t | task_sem | ||
task data structure protection. |
#define fatal (a) |
void tm_switcher (void) |
the task switcher.
saves active context and passes sp to scheduler then restores new context from returned sp
__asm__ (".text.align 1.globl _tm_switcher_tm_switcher:;r6 saved by ROM;r0 saved by system timer handler mov. w r1, @-r7;save registers mov. w r2, @-r7 mov. w r3, @-r7 mov. w r4, @-r7 mov. w r5, @-r7 mov. w r7, r0;pass sp jsr _tm_scheduler;call scheduler_tm_switcher_return:mov. w r0, r7;set new sp mov.w@r7+, r5 mov.w@r7+, r4 mov.w@r7+, r3 mov.w@r7+, r2 mov.w@r7+, r1;r0 will be restored by system timer handler;r6 will be restored by ROM rts;return to new task") |
size_t * tm_scheduler (size_t * old_sp) |
the process scheduler.
old_sp | current task's current stack pointer |
void yield (void) |
yield the rest of the current timeslice.
doesn't speed up the system clock.
__asm__ (".text.globl _yield.align 1_yield:stc ccr, r0h; to fake an IRQ, we have to push r0;store the registers orc# 0x80, ccr;disable interrupts push r6;store r6 mov.w# 0x04d4, r0;store rom return addr push r0 push r0;store r0(destroyed by call.)mov.w# _systime_tm_return, r0;store systime return addr push r0 jmp@_tm_switcher;call task switcher") |
int tm_idle_task (int argc, char ** argv) |
the idle task.
infinite sleep instruction to conserve power.
__asm__ (".text.align 1_tm_idle_task:sleep bra _tm_idle_task") |
void tm_init (void) |
init task management.
called in single tasking mode before task setup.
void tm_start (void) |
start task management.
called in single tasking mode after task setup
pid_t execi (int(* code_start)(int,char **), int argc, char ** argv, priority_t priority, size_t stack_size) |
execute a memory image.
code_start | start address of code to execute |
argc | first argument passed, normally number of strings in argv |
argv | second argument passed, normally pointer to argument pointers. |
priority | new task's priority |
stack_size | stack size for new process |
void exit (int code) |
exit task, returning code.
code |
The return code
|
wakeup_t wait_event (wakeup_t(* wakeup)(wakeup_t), wakeup_t data) |
suspend process until wakeup function is non-null.
wakeup | the wakeup function. called in task scheduler context. |
data | argument passed to wakeup function by scheduler |
wakeup_t tm_sleep_wakeup (wakeup_t data) [static]
|
wakeup function for sleep.
data | time to wakeup encoded as a wakeup_t |
unsigned int msleep (unsigned int msec) |
delay execution allowing other tasks to run.
msec | sleep duration in milliseconds |
unsigned int sleep (unsigned int sec) |
delay execution allowing other tasks to run.
sec | sleep duration in seconds |
void kill (pid_t pid) |
kill a process.
pid | must be valid process ID, or undefined behaviour will result! |
void killall (priority_t p) |
kill all processes with priority lower or equal than p, excluding self.
pchain_t* priority_head |
head of process priority chain.
pdata_t pd_single |
single process process data.
pdata_t* pd_idle |
idle proces.
pdata_t* cpid |
ptr to current process data.
unsigned nb_tasks |
number of tasks.
sem_t task_sem |
task data structure protection.