20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: conditio.c,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $ |
CVS : $Id: conditio.c,v 1.2 2002-11-11 08:34:08 pj Exp $ |
|
File: $File$ |
Revision: $Revision: 1.1.1.1 $ |
Last update: $Date: 2002-03-29 14:12:51 $ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2002-11-11 08:34:08 $ |
------------ |
|
This file contains the condition variables handling functions. |
59,6 → 59,7 |
#include <kernel/var.h> |
#include <kernel/func.h> |
#include <errno.h> |
#include <kernel/iqueue.h> |
|
/*---------------------------------------------------------------------*/ |
/* Condition variables */ |
76,8 → 77,8 |
/* if the task is waiting on a condition variable, we have to extract it |
from the waiters queue, then set the KILL_REQUEST flag, and reinsert |
the task into the ready queue so it can reaquire the mutex and die */ |
q_extract(i,&proc_table[i].cond_waiting->waiters); |
if (proc_table[i].cond_waiting->waiters == NIL) |
iq_extract(i,&proc_table[i].cond_waiting->waiters); |
if (iq_isempty(&proc_table[i].cond_waiting->waiters)) |
proc_table[i].cond_waiting->used_for_waiting = NULL; |
proc_table[i].cond_waiting = NULL; |
|
102,7 → 103,8 |
register_cancellation_point(condition_cancellation_point, NULL); |
} |
|
cond->waiters = NIL; |
iq_init (&cond->waiters, &freedesc, 0); |
|
cond->used_for_waiting = NULL; |
|
return 0; |
110,7 → 112,7 |
|
int cond_destroy(cond_t *cond) |
{ |
if (cond->waiters != NIL) |
if (!iq_isempty(&cond->waiters)) |
return (EBUSY); |
|
return 0; |
123,8 → 125,8 |
|
proc_table[exec_shadow].context = kern_context_save(); |
|
if (cond->waiters != NIL) { |
p = q_getfirst(&cond->waiters); |
if (!iq_isempty(&cond->waiters)) { |
p = iq_getfirst(&cond->waiters); |
|
l = proc_table[p].task_level; |
level_table[l]->task_insert(l,p); |
143,13 → 145,13 |
|
proc_table[exec_shadow].context = kern_context_save(); |
|
if (cond->waiters != NIL) { |
if (!iq_isempty(&cond->waiters)) { |
do { |
p = q_getfirst(&cond->waiters); |
p = iq_getfirst(&cond->waiters); |
|
l = proc_table[p].task_level; |
level_table[l]->task_insert(l,p); |
} while(cond->waiters != NIL); |
} while(!iq_isempty(&cond->waiters)); |
|
scheduler(); |
} |
214,7 → 216,7 |
|
/* we insert the task in the condition queue */ |
proc_table[exec_shadow].status = WAIT_COND; |
q_insert(exec_shadow,&cond->waiters); |
iq_priority_insert(exec_shadow,&cond->waiters); |
|
/* then, we set into the processor descriptor the condition on that |
the task is blocked... (if the task is killed while it is waiting |
242,7 → 244,7 |
if (proc_table[exec_shadow].cond_waiting != NULL) { |
proc_table[exec_shadow].cond_waiting = NULL; |
|
if (cond->waiters == NIL) cond->used_for_waiting = NULL; |
if (iq_isempty(&cond->waiters)) cond->used_for_waiting = NULL; |
} |
task_preempt(); |
|
268,8 → 270,8 |
PID p = (PID)arg; |
LEVEL l; |
|
q_extract(p,&proc_table[p].cond_waiting->waiters); |
if (proc_table[p].cond_waiting->waiters == NIL) |
iq_extract(p,&proc_table[p].cond_waiting->waiters); |
if (iq_isempty(&proc_table[p].cond_waiting->waiters)) |
proc_table[p].cond_waiting->used_for_waiting = NULL; |
proc_table[p].cond_waiting = NULL; |
|
340,7 → 342,7 |
|
/* we insert the task in the condition queue */ |
proc_table[exec_shadow].status = WAIT_COND; |
q_insert(exec_shadow,&cond->waiters); |
iq_priority_insert(exec_shadow,&cond->waiters); |
|
/* then, we set into the processor descriptor the condition on that |
the task is blocked... (if the task is killed while it is waiting |
379,7 → 381,7 |
if (proc_table[exec_shadow].cond_waiting != NULL) { |
proc_table[exec_shadow].cond_waiting = NULL; |
|
if (cond->waiters == NIL) cond->used_for_waiting = NULL; |
if (iq_isempty(&cond->waiters)) cond->used_for_waiting = NULL; |
} |
else |
/* cond_waiting == NULL if the task is killed or the timer has fired */ |