20,11 → 20,11 |
|
/** |
------------ |
CVS : $Id: pistar.c,v 1.8 2004-09-08 16:51:34 giacomo Exp $ |
CVS : $Id: pistar.c,v 1.9 2004-10-25 14:39:31 trimarchi Exp $ |
|
File: $File$ |
Revision: $Revision: 1.8 $ |
Last update: $Date: 2004-09-08 16:51:34 $ |
Revision: $Revision: 1.9 $ |
Last update: $Date: 2004-10-25 14:39:31 $ |
------------ |
|
Priority Inhertitance protocol. see pi.h for more details... |
61,8 → 61,9 |
#include <kernel/descr.h> |
#include <kernel/var.h> |
#include <kernel/func.h> |
#include <fsf_contract.h> |
#include <fsf_server.h> |
#include "fsf_configuration_parameters.h" |
#include "fsf_core.h" |
#include "fsf_server.h" |
#include <pistar.h> |
|
#include <tracer.h> |
158,7 → 159,7 |
|
return 0; |
} |
|
#if defined OLD_VERSION |
/* Note that in this approach, when unlocking we can't wake up only |
one thread, but we have to wake up all the blocked threads, because there |
is not a concept of priority between the task... Each woken thread have |
212,7 → 213,7 |
/* ... and reaquire the cli() before the test... */ |
kern_cli(); |
} |
fsf_get_server(&server, exec_shadow); |
fsf_get_server(exec_shadow, &server); |
if (fsf_get_remain_budget(server)>wcet) cond=0; |
else { |
SERVER_disable_server(fsf_get_server_level(),server); |
239,7 → 240,72 |
|
return 0; |
} |
#else |
|
int PISTAR_lock(RLEVEL l, mutex_t *m) |
{ |
PISTAR_mutex_resource_des *lev = (PISTAR_mutex_resource_des *)(resource_table[l]); |
PISTAR_mutex_t *p; |
SYS_FLAGS f; |
// return 0; |
int cond; |
cond = 1; |
fsf_server_id_t server; |
|
f = kern_fsave(); |
|
TRACER_LOGEVENT(FTrace_EVT_set_mutex_lock,(unsigned short int)proc_table[exec_shadow].context,(unsigned int)m); |
|
//kern_printf("(PISTAR lock)"); |
p = (PISTAR_mutex_t *)m->opt; |
if (!p) { |
/* if the mutex is not initialized, return an error! */ |
kern_frestore(f); |
return (EINVAL); |
} |
|
|
if (p->owner == exec_shadow) { |
/* the task already owns the mutex */ |
kern_frestore(f); |
return (EDEADLK); |
} |
|
while (p->owner != NIL) { |
/* the mutex is locked by someone, "block" the task ...*/ |
proc_table[exec_shadow].shadow = p->owner; |
lev->blocked[exec_shadow] = p->firstblocked; |
p->firstblocked = exec_shadow; |
p->nblocked++; |
// kern_printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); |
/* ... call the scheduler... */ |
scheduler(); |
TRACER_LOGEVENT(FTrace_EVT_inheritance,(unsigned short int)proc_table[exec_shadow].context,(unsigned int)proc_table[exec].context); |
kern_context_load(proc_table[exec_shadow].context); |
|
/* ... and reaquire the cli() before the test... */ |
kern_cli(); |
} |
|
|
/* if we are here, we have budget for critical section */ |
/* Set the task no preemptive for the localscheduler */ |
//kern_printf("(PISTAR NP %d", exec_shadow); |
fsf_get_server(exec_shadow, &server); |
fsf_settask_nopreemptive(&server, exec_shadow); |
|
/* the mutex is free, We can lock it! */ |
lev->nlocked[exec_shadow]++; |
|
p->owner = exec_shadow; |
|
kern_frestore(f); |
|
return 0; |
} |
#endif |
|
|
static int PISTAR_trylock(RLEVEL l, mutex_t *m) |
{ |
PISTAR_mutex_t *p; |
317,7 → 383,7 |
}*/ |
|
/* Set the task preemptive for the localscheduler */ |
fsf_get_server(&server, exec_shadow); |
fsf_get_server(exec_shadow, &server); |
fsf_settask_preemptive(&server, exec_shadow); |
|
scheduler(); |
352,7 → 418,7 |
/* fill the mutex_resource_des descriptor */ |
m->m.init = PISTAR_init; |
m->m.destroy = PISTAR_destroy; |
m->m.lock = NULL; |
m->m.lock = PISTAR_lock; |
m->m.trylock = PISTAR_trylock; |
m->m.unlock = PISTAR_unlock; |
|