Hardware Reference
In-Depth Information
10.5.4
TASK MANAGEMENT
It concerns creation, activation, suspension, and termination of tasks. The create prim-
itive allocates and initializes all data structures needed by a task and puts the task in
SLEEP. A guarantee is performed for HARD tasks.
/*-----------------------------------------------------------*/
/* create -- creates a task and puts it in sleep state */
/*-----------------------------------------------------------*/
proc
create (
char
name[MAXLEN+1],
/* task name
*/
proc
(*addr)(),
/* task address
*/
int
type,
/* type (HARD, NRT)
*/
float
period,
/* period or priority */
float
wcet)
/* execution time
*/
proc p;
<disable cpu interrupts>
p = getfirst(&freetcb);
if (p == NIL) abort(NO TCB);
if (vdes[p].type == HARD)
if (!guarantee(p)) return(NO GUARANTEE);
vdes[p].name = name;
vdes[p].addr = addr;
vdes[p].type = type;
vdes[p].state = SLEEP;
vdes[p].period = (int)(period / time unit);
vdes[p].wcet = (int)(wcet / time unit);
vdes[p].util = wcet / period;
vdes[p].prt = (int)period;
vdes[p].dline = MAX LONG + (long)(period - PRT LEV);
<initialize process stack>
<enable cpu interrupts>
return(p);
}
Search WWH ::




Custom Search