Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 342 → Rev 343

/shark/trunk/ports/first/include/mpegstar.h
51,7 → 51,8
 
int MPEGSTAR_rescale(int budget, TIME Q, TIME T);
int MPEGSTAR_get_remain_capacity(int budget);
int MPEGSTAR_get_last_reclaiming(void);
int MPEGSTAR_get_last_reclaiming(int budget);
int MPEGSTAR_is_frame_skipped(int budget);
 
#endif
 
/shark/trunk/ports/first/modules/mpegstar.c
51,7 → 51,10
/*+ Status used in the level +*/
#define MPEGSTAR_READY MODULE_STATUS_BASE
 
/*+ the level redefinition for the Round Robin level +*/
#define FRAME_IDLE 0
#define FRAME_DECODING 1
#define FRAME_SKIPPED 2
 
typedef struct {
level_des l; /*+ the standard level descriptor +*/
 
60,6 → 63,7
 
int budget;
int current;
int status;
int scheduling_level;
 
87,6 → 91,7
if (lev->current != NIL) return -1;
 
lev->current = p;
lev->status = FRAME_IDLE;
proc_table[p].avail_time = lev->server_Q;
proc_table[p].wcet = lev->server_Q;
114,6 → 119,7
static void MPEGSTAR_public_epilogue(LEVEL l, PID p)
{
MPEGSTAR_level_des *lev = (MPEGSTAR_level_des *)(level_table[l]);
int r;
 
#ifdef MPEGSTAR_DEBUG
kern_printf("(MS:Epi:%d)",p);
121,7 → 127,21
 
level_table[ lev->scheduling_level ] ->
private_epilogue(lev->scheduling_level,p);
 
r = SERVER_get_remain_capacity(lev->scheduling_level,lev->budget);
if (r < 0) {
 
#ifdef MPEGSTAR_DEBUG
kern_printf("(MS:FRAME SKIP %d)",p);
#endif
 
lev->status = FRAME_SKIPPED;
 
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
 
}
 
}
 
static void MPEGSTAR_public_activate(LEVEL l, PID p)
135,6 → 155,8
kern_printf("(MP:Act:%d:%d)",p,lev->budget);
#endif
 
lev->status = FRAME_DECODING;
 
level_table[ lev->scheduling_level ]->
private_insert(lev->scheduling_level, p, (TASK_MODEL *)&b);
 
165,6 → 187,8
kern_printf("(MS:EndCycle:%d)",p);
#endif
 
lev->status = FRAME_IDLE;
 
level_table[ lev->scheduling_level ]->
private_extract(lev->scheduling_level, p);
 
196,7 → 220,9
kern_printf("(MS:End:%d)", p);
#endif
 
lev->current = NIL; proc_table[p].status = FREE;
lev->current = NIL;
lev->status = FRAME_IDLE;
proc_table[p].status = FREE;
 
}
 
226,6 → 252,7
 
lev->budget = NIL;
lev->current = NIL;
lev->status = FRAME_IDLE;
lev->server_Q = 0;
lev->server_T = 0;
 
285,7 → 312,19
return SERVER_get_remain_capacity(fsf_get_server_level(),budget);
}
 
int MPEGSTAR_get_last_reclaiming()
int MPEGSTAR_get_last_reclaiming(int budget)
{
return SERVER_get_last_reclaiming(fsf_get_server_level(),exec_shadow);
}
 
int MPEGSTAR_is_frame_skipped(int budget)
{
LEVEL l = SERVER_get_local_scheduler_level_from_budget(fsf_get_server_level(),budget);
MPEGSTAR_level_des *lev = (MPEGSTAR_level_des *)(level_table[l]);
 
if (lev->status == FRAME_SKIPPED)
return 1;
else
return 0;
 
}
/shark/trunk/ports/first/modules/grubstar.c
36,6 → 36,7
*
*/
 
#include "ll/i386/64bit.h"
#include "grubstar.h"
 
//#define GRUBSTAR_DEBUG
154,7 → 155,7
GRUBSTAR_level_des *lev=(GRUBSTAR_level_des *)level_table[b->l];
#ifdef GRUBSTAR_DEBUG
//kern_printf("(GS:Rec:");
kern_printf("(GS:Rec:");
#endif
 
b->vtimer = NIL;
181,7 → 182,7
TIME t;
struct timespec t2,t3;
 
t = (b->T * b->avail) / b->Q;
mul32div32to32(b->T,b->avail,b->Q,t);
t3.tv_sec = t / 1000000;
t3.tv_nsec = (t % 1000000) * 1000;
 
235,8 → 236,13
SUBTIMESPEC(&schedule_time, &lev->cap_lasttime, &ty);
tx = TIMESPEC2USEC(&ty);
 
b->last_reclaiming = (unsigned int)((long long)(tx) * (long long)(lev->U - lev->Uf)/MAX_BANDWIDTH);
if ((lev->U - lev->Uf) < 0) {
kern_printf("Error (U - Uf) < 0\n");
sys_end();
}
 
mul32div32to32(tx,(lev->U - lev->Uf),MAX_BANDWIDTH,b->last_reclaiming);
 
b->avail -= tx - b->last_reclaiming;
 
#ifdef GRUBSTAR_DEBUG
254,7 → 260,7
if (b->flags == GRUBSTAR_NOACTIVE && b->dline_timer == NIL) {
b->dline_timer=kern_event_post(&b->dline, GRUBSTAR_deadline_timer_hardreservation, b);
} else {
t = (b->T * b->avail) / b->Q;
mul32div32to32(b->T,b->avail,b->Q,t);
t3.tv_sec = t / 1000000;
t3.tv_nsec = (t % 1000000) * 1000;
SUBTIMESPEC(&b->dline, &t3, &t2);
596,7 → 602,7
 
if (r != lev->n) {
bandwidth_t b;
b = (MAX_BANDWIDTH / T) * Q;
mul32div32to32(MAX_BANDWIDTH,Q,T,b);
/* really update lev->U, checking an overflow... */
if (Q< T && MAX_BANDWIDTH - lev->U > b) {
630,7 → 636,7
 
bandwidth_t b;
b = (MAX_BANDWIDTH / lev->b[budget].T) * lev->b[budget].Q;
mul32div32to32(MAX_BANDWIDTH,lev->b[budget].Q,lev->b[budget].T,b);
 
lev->U -= b;
lev->Uf -= b;
655,7 → 661,7
GRUBSTAR_level_des *lev = (GRUBSTAR_level_des *)(level_table[l]);
bandwidth_t b;
 
b = (MAX_BANDWIDTH / lev->b[budget].T) * lev->b[budget].Q;
mul32div32to32(MAX_BANDWIDTH,lev->b[budget].Q,lev->b[budget].T,b);
 
lev->U -= b;
lev->Uf -= b;
662,7 → 668,7
 
lev->b[budget].Q = Q;
lev->b[budget].T = T;
lev->b[budget].Ub = (MAX_BANDWIDTH / T) * Q;
mul32div32to32(MAX_BANDWIDTH,Q,T,lev->b[budget].Ub);
 
lev->U += lev->b[budget].Ub;
lev->Uf += lev->b[budget].Ub;