Main Page | Modules | Data Structures | File List | Data Fields | Globals

exec.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  regs_struct
struct  task_struct
struct  execbase_struct


typedef regs_struct regs_t
typedef task_struct task_t
typedef execbase_struct execbase_t


void bsleep (ushort sleeptime)
 Voluntarily give up CPU time, sleep for sleeptime ms.

void addtask (void(*func)(void), schar priority, ushort nextrun, ushort stacksize)
 Creates & inserts (@ sorted positions) a task into exec task list.

void execprep (void)
 Prepares the global execbase_t exec struct; creates idle task.


execbase_t exec

Typedef Documentation

typedef struct execbase_struct execbase_t

Definition at line 37 of file exec.h.

typedef struct regs_struct regs_t

Definition at line 8 of file exec.h.

Referenced by task_dumpinfo().

typedef struct task_struct task_t

Definition at line 23 of file exec.h.

Referenced by addtask(), bsleep(), context_restore2(), context_save2(), create_task(), find_imperative_task(), find_nextrun_lte(), find_priority_lte(), find_urgent_task(), insert_task_prior(), insert_task_time(), task_select(), unlink_prior(), and unlink_time().

Function Documentation

void addtask void(*  func)(void),
schar  priority,
ushort  nextrun,
ushort  stacksize

Creates & inserts (@ sorted positions) a task into exec task list.

After creating & initialising the new task, finds where the task should be inserted into in both the priorty and time exec list.

func Function pointer to task being added
priority A signed char value representing a unique priority, determines location in the exec priority list.
nextrun The first time this task should be scheduled to run, determines location in the exec time list.
stacksize The initial stack size for this task.
Does not check for func \== NULL. Also assumes that if exec.head_time is NULL, then so must be exec.head_prior.

Definition at line 277 of file exec.c.

References create_task(), exec, find_nextrun_lte(), find_priority_lte(), execbase_struct::head_prior, execbase_struct::head_time, insert_task_prior(), insert_task_time(), NULL, execbase_struct::numtasks, schar, task_t, and ushort.

00278 {
00279     task_t *new_task = create_task(func, priority, nextrun, stacksize);
00280     task_t *pPrior, *pTime;
00282     if (NULL != exec.head_time) {   /* Assume head_time reflects head_prior */ 
00283         pPrior = find_priority_lte(exec.head_prior, priority);  /* NULL state. */
00284         pTime = find_nextrun_lte(exec.head_time, nextrun);
00285     } else {
00286         pPrior = NULL;
00287         pTime = NULL;
00288     }
00289     insert_task_prior(pPrior, new_task);
00290     insert_task_time(pTime, new_task);
00292     exec.numtasks++;
00294     return;
00295 }

Here is the call graph for this function:

void bsleep ushort  sleeptime  ) 

Voluntarily give up CPU time, sleep for sleeptime ms.

Unlinks exec.current from the time list, then calculates nextrun using sleeptime. Finds new location in time list and inserts it there. Sets exec.idle, clears exec.blocked, and then invokes isr_exec with an SWI.

sleeptime The length of time to sleep for, relative to NOW. sleeptime is approx. millisecond units.
Blocking Tasks
Does not re-enable exec timer when called by tasks during blocked state; bsleep() clears exec.blocked flag and then invokes isr_exec() using an SWI. isr_exec() will enable the exec timer apon seeing that exec.blocked is false.

Definition at line 314 of file exec.c.

References ASM_CLI, ASM_SEI, ASM_SWI, execbase_struct::blocked, execbase_struct::current, exec, find_nextrun_lte(), execbase_struct::head_time, execbase_struct::idle, insert_task_time(), MSEC2TCNT, task_struct::nextrun, task_t, TCNT_H, TOUSHORT, unlink_time(), and ushort.

Referenced by btnscan_chk(), lbdrv_chg(), and misc().

00315 {
00316     task_t *pTime;
00318     exec.current->nextrun = TOUSHORT(TCNT_H) + (ushort) MSEC2TCNT(sleeptime);
00319     ASM_SEI;    /* Don't want other tasks mangling the list in mid-search. */
00320     unlink_time(exec.current);
00321     pTime = find_nextrun_lte(exec.head_time, exec.current->nextrun);
00322     insert_task_time(pTime, exec.current);
00323     ASM_CLI;
00324     exec.idle = true;
00325     exec.blocked = false;   /* If a blocking task just finished, */
00326                         /* clear flag so isr_exec() can re-enable exec timer. */
00327     ASM_SWI;    /* Trigger an INTR to enter isr_exec() */
00329     return;
00330 }

Here is the call graph for this function:

void execprep void   ) 

Prepares the global execbase_t exec struct; creates idle task.

MUST be called before isr_exec is first invoked.

See also:
isr_exec, task_select, add_task

Definition at line 561 of file exec.c.

References bfree(), bmemset(), create_task(), exec, exec_idle(), execbase_struct::idle_task, and task_struct::stack.

00562 {
00563     bmemset((char *)&exec, 0, sizeof(exec));
00564     exec.idle_task = create_task (exec_idle, -127, 0, 0);
00565     bfree(exec.idle_task->stack);
00566     exec.idle_task->stack = (void *)0x3FFF;
00568     return;
00569 }

Here is the call graph for this function:

Variable Documentation

execbase_t exec

Definition at line 40 of file exec.h.

Referenced by addtask(), bsleep(), exec_idle(), execprep(), find_urgent_task(), insert_task_prior(), insert_task_time(), isr_exec_stuff(), task_select(), unlink_prior(), and unlink_time().

Generated on Sat Apr 10 17:08:17 2004 for BeeOS by doxygen 1.3.6-20040222