Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 810 → Rev 811

/shark/trunk/ports/first/first-contract.c
19,7 → 19,7
 
struct hash_entry {
mutex_t mx;
fsf_shared_obj_id_t id;
int id;
};
 
 
35,7 → 35,18
return (*id % MAX_HASH_ENTRY);
}
 
void fsf_register_shared_object(void) {
int i=0;
// Init Hash table
//kern_printf("(IT SO)\n");
for (i=0; i<MAX_HASH_ENTRY; i++) {
htable[i].id=-1;
 
}
 
}
 
 
int fsf_initialize_contract
(fsf_contract_parameters_t *contract)
{
279,19 → 290,19
 
int fsf_lock_object(fsf_shared_operation_t *op) {
int index, oldindex;
index=hash_fun(&(op->obj_id));
//kern_printf("index %d, htableid %d, obj_op_id %d", index, htable[index].id,op->obj_id);
 
index=hash_fun(&op->obj_id);
 
if (htable[index].id!=op->obj_id) {
oldindex=index;
index = (index + 1) % MAX_HASH_ENTRY;
// find
for (;htable[index].id != op->obj_id, index!=oldindex; (index++) % MAX_HASH_ENTRY);
while (htable[index].id != op->obj_id && index!=oldindex) index=(index+1) % MAX_HASH_ENTRY;
if (index==oldindex) return -1;
}
 
//kern_printf("(SO LK)");
// we need a special implementation for mutex_lock ... additional parameter
 
return PISTAR_lock(FSF_get_shared_object_level(), &htable[index].mx,TIMESPEC2USEC(&op->wcet) );
 
}
306,9 → 317,11
oldindex=index;
index = (index + 1) % MAX_HASH_ENTRY;
// find
for (;htable[index].id != op->obj_id, index!=oldindex; (index++) % MAX_HASH_ENTRY);
while (htable[index].id != op->obj_id && index!=oldindex) index=(index+1) % MAX_HASH_ENTRY;
if (index==oldindex) return -1;
}
//kern_printf("UNLOCK index %d", index);
 
return mutex_unlock(&htable[index].mx);
 
320,22 → 333,27
int index;
int oldindex;
PISTAR_mutexattr_t a;
SYS_FLAGS f;
 
PISTAR_mutexattr_default(a);
 
//kern_printf("(SI SO)\n");
f=kern_fsave();
obj->size=0;
index=hash_fun(&id);
//kern_printf("Index %d Hash %d", index, htable[index].id);
if (htable[index].id>=0) {
oldindex=index;
index = (index + 1) % MAX_HASH_ENTRY;
// collision detection
for (;htable[index].id >=0, index!=oldindex; (index++) % MAX_HASH_ENTRY);
while (htable[index].id >=0 && index!=oldindex) index=(index+1) % MAX_HASH_ENTRY;
// table is full
if (index==oldindex) return;
}
mutex_init(&(htable[index]).mx, &a);
htable[index].id=id;
obj->obj_id=id;
 
kern_frestore(f);
//kern_printf("(EI SO)\n");
}
 
 
362,7 → 380,7
// fail if the object is full
if (obj->size>(FSF_MAX_SHARED_OPERATION-1))
return -1;
 
kern_printf("(DO SO)");
obj->size++;
obj->shared_op[i].op_id=op->op_id;
obj->shared_op[i].wcet=op->wcet;
/shark/trunk/ports/first/modules/pistar.c
20,11 → 20,11
 
/**
------------
CVS : $Id: pistar.c,v 1.4 2004-09-06 06:31:45 trimarchi Exp $
CVS : $Id: pistar.c,v 1.5 2004-09-06 08:58:05 trimarchi Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2004-09-06 06:31:45 $
Revision: $Revision: 1.5 $
Last update: $Date: 2004-09-06 08:58:05 $
------------
 
Priority Inhertitance protocol. see pi.h for more details...
179,7 → 179,7
fsf_server_id_t server;
 
f = kern_fsave();
 
//kern_printf("(PISTAR lock)");
p = (PISTAR_mutex_t *)m->opt;
if (!p) {
/* if the mutex is not initialized, return an error! */
223,6 → 223,7
/* 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_settask_nopreemptive(&server, exec_shadow);
/* the mutex is free, We can lock it! */
306,7 → 307,7
 
/* {
int xxx;
kern_printf("(PISTAR_unlock owner=%d ",p->owner);
//kern_printf("(PISTAR_unlock owner=%d ",p->owner);
for (xxx = 0; xxx<5; xxx++) kern_printf("p%d s%d|",xxx, proc_table[xxx].shadow);
kern_printf(")\n");
}*/
/shark/trunk/ports/first/modules/grubstar.c
820,6 → 820,7
int spare;
 
/* force a hard reservation event */
kern_printf("(GS DS)");
avail_budget=lev->b[lev->tb[exec_shadow]].avail;
lev->b[lev->tb[exec_shadow]].avail=0;
 
829,9 → 830,6
spare=avail_budget+lev->b[lev->tb[exec_shadow]].avail;
if (spare<=0) spare=0;
/* Force the server in the NOACTIVE state */
lev->b[lev->tb[exec_shadow]].flags=GRUBSTAR_NOACTIVE;
 
}
 
 
/shark/trunk/ports/first/first-server.c
41,6 → 41,7
PORT channel[2];
 
int FSF_register_shared_object_module(void) {
fsf_register_shared_object();
return PISTAR_register_module();
}
 
55,7 → 56,7
current_server=0;
fsf_server_level = server_level;
fsf_max_bw = max_bw;
// shared_object_level = FSF_register_shared_object_module();
shared_object_level = FSF_register_shared_object_module();
return 0;
 
365,6 → 366,10
return FSF_ERR_INVALID_SERVER;
break;
}
#ifdef FSF_DEBUG
kern_printf("(FSF:Insert thread = %d to Server = %d)",*thread,server);
#endif
 
return 0;