Subversion Repositories shark

Rev

Rev 236 | Rev 293 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
221 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 2001 Paolo Gai
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 */
37
 
38
#include "edfstar.h"
39
#include <ll/stdio.h>
40
#include <ll/string.h>
41
#include <kernel/model.h>
42
#include <kernel/descr.h>
43
#include <kernel/var.h>
44
#include <kernel/func.h>
45
#include <kernel/trace.h>
46
 
47
 
48
#define EDFSTAR_CHANGE_LEVEL 1
49
 
50
/* for iqueues */
51
/* #include "iqueue.h" Now iqueues are the only queue type available
52
   into the kernel */
53
#include <kernel/iqueue.h>
54
 
55
/* for BUDGET_TASK_MODEL */
241 giacomo 56
#include "fsf_server.h"
221 giacomo 57
 
58
/*
59
 * DEBUG stuffs begin
60
 */
61
 
224 giacomo 62
//#define EDFSTAR_DEBUG
221 giacomo 63
 
64
#ifdef EDFSTAR_DEBUG
65
 
66
static __inline__ fake_printf(char *fmt, ...) {}
67
 
68
//#define edfstar_printf fake_printf
69
//#define edfstar_printf2 fake_printf
70
//#define edfstar_printf3 fake_printf
71
 
72
#define edfstar_printf kern_printf
73
#define edfstar_printf2 kern_printf
74
#define edfstar_printf3 kern_printf
75
#endif
76
 
77
/*
78
 * DEBUG stuffs end
79
 */
80
 
81
/* Status used in the level */
82
#define EDFSTAR_READY         MODULE_STATUS_BASE    /* - Ready status        */
83
#define EDFSTAR_IDLE          MODULE_STATUS_BASE+4  /* to wait the deadline  */
84
 
85
/* flags */
86
#define EDFSTAR_FLAG_NORAISEEXC  2
87
 
88
/* the level redefinition for the Earliest Deadline First level */
89
typedef struct {
90
  level_des l;     /* the standard level descriptor          */
91
 
92
  TIME period[MAX_PROC]; /* The task periods; the deadlines are
93
                       stored in the priority field           */
94
  int deadline_timer[MAX_PROC];
95
                   /* The task deadline timers               */
96
 
97
  struct timespec deadline_timespec[MAX_PROC];
98
 
99
  int dline_miss[MAX_PROC]; /* Deadline miss counter */
100
  int wcet_miss[MAX_PROC];  /* Wcet miss counter */
101
 
102
  int nact[MAX_PROC];       /* Wcet miss counter */
103
 
104
  int flag[MAX_PROC];
105
                   /* used to manage the JOB_TASK_MODEL and the
106
                       periodicity                            */
107
 
108
  IQUEUE ready;     /* the ready queue                        */
109
 
110
  PID activated;   /* the task that has been inserted into the
111
                       master module */
112
 
113
  int budget[MAX_PROC];
114
 
115
  int scheduling_level;
116
 
117
  int new_level[MAX_PROC];
118
  int wcet[MAX_PROC]; /* save the wcet fields */
119
 
120
} EDFSTAR_level_des;
121
 
122
static void EDFSTAR_check_preemption(EDFSTAR_level_des *lev)
123
{
124
  PID first;
125
 
126
#ifdef EDFSTAR_DEBUG
127
  edfstar_printf("(E:chk)");
128
#endif
129
 
130
  if ((first = iq_query_first(&lev->ready)) != lev->activated) {
131
    if (lev->activated != NIL)
132
      level_table[ lev->scheduling_level ]->
133
        private_extract(lev->scheduling_level, lev->activated);
134
 
135
    lev->activated = first;
136
 
137
    if (first != NIL) {
138
      BUDGET_TASK_MODEL b;
139
      budget_task_default_model(b, lev->budget[first]);
140
 
141
      level_table[ lev->scheduling_level ]->
142
        private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b);
143
    }
144
  }
145
}
146
 
147
static void EDFSTAR_timer_deadline(void *par);
148
 
149
static void EDFSTAR_internal_activate(EDFSTAR_level_des *lev, PID p,
150
                                      struct timespec *t)
151
{
152
#ifdef EDFSTAR_DEBUG
153
  edfstar_printf("(E:iact)");
154
#endif
155
 
156
  ADDUSEC2TIMESPEC(lev->period[p], t);
157
 
158
  *iq_query_timespec(p, &lev->ready) = *t;
159
  lev->deadline_timespec[p] = *t;
160
 
161
  /* Insert task in the correct position */
162
  proc_table[p].status = EDFSTAR_READY;
163
  iq_timespec_insert(p,&lev->ready);
164
 
165
  /* needed because when there is a wcet miss I disable CONTROL_CAP */
166
  proc_table[p].control |= CONTROL_CAP;
167
 
168
  /* check for preemption */
169
  EDFSTAR_check_preemption(lev);
170
}
171
 
172
static void EDFSTAR_timer_deadline(void *par)
173
{
174
  PID p = (PID) par;
175
  EDFSTAR_level_des *lev;
176
 
177
#ifdef EDFSTAR_DEBUG
178
//  edfstar_printf("(E:tdl ");
179
#endif
180
 
181
  lev = (EDFSTAR_level_des *)level_table[proc_table[p].task_level];
182
 
183
  switch (proc_table[p].status) {
184
    case EDFSTAR_IDLE:
185
#ifdef EDFSTAR_DEBUG
186
//      edfstar_printf2("I%d",p);
187
#endif
188
      /* set the request time */
189
      EDFSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready));
190
 
191
      event_need_reschedule();
192
      break;
193
 
194
    default:
224 giacomo 195
  #ifdef EDFSTAR_DEBUG
221 giacomo 196
      kern_printf("(E:Dl:%d)",p);
224 giacomo 197
  #endif
221 giacomo 198
      /* else, a deadline miss occurred!!! */
199
      lev->dline_miss[p]++;
200
 
201
      /* the task is into another state */
202
      lev->nact[p]++;
203
 
204
      /* Set the deadline timer */
205
      ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]);
206
  }
207
 
208
  /* Set the deadline timer */
209
  lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
210
                                           EDFSTAR_timer_deadline,
211
                                           (void *)p);
212
 
213
#ifdef EDFSTAR_DEBUG
214
//  edfstar_printf(")");
215
#endif
216
}
217
 
218
static void EDFSTAR_timer_guest_deadline(void *par)
219
{
220
  PID p = (PID) par;
221
 
222
#ifdef EDFSTAR_DEBUG
223
  edfstar_printf("(E:gdl)");
224
#endif
225
 
226
  kern_raise(XDEADLINE_MISS,p);
227
}
228
 
229
static int EDFSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m)
230
{
231
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
232
 
233
  /* if the EDFSTAR_task_create is called, then the pclass must be a
234
     valid pclass. */
235
  HARD_TASK_MODEL *h;
236
 
237
  if (m->pclass != HARD_PCLASS) return -1;
238
  if (m->level != 0 && m->level != l) return -1;
239
  h = (HARD_TASK_MODEL *)m;
240
  if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1;
241
  /* now we know that m is a valid model */
242
 
243
 
244
#ifdef EDFSTAR_DEBUG
245
  edfstar_printf("(E:tcr)");
246
#endif
247
 
248
  lev->period[p] = h->mit;
249
 
250
  lev->flag[p] = 0;
251
  lev->deadline_timer[p] = -1;
252
  lev->dline_miss[p]     = 0;
253
  lev->wcet_miss[p]      = 0;
254
  lev->nact[p]           = 0;
255
 
256
  /* Enable wcet check */
257
  proc_table[p].avail_time = h->wcet;
258
  proc_table[p].wcet       = h->wcet;
259
  proc_table[p].control |= CONTROL_CAP;
260
 
261
  return 0; /* OK, also if the task cannot be guaranteed... */
262
}
263
 
264
static int EDFSTAR_public_eligible(LEVEL l, PID p)
265
{
266
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
267
 
268
#ifdef EDFSTAR_DEBUG
269
  edfstar_printf2("(E:eli)");
270
#endif
271
 
272
  return level_table[ lev->scheduling_level ]->
273
    private_eligible(lev->scheduling_level,p);
274
}
275
 
276
static void EDFSTAR_public_dispatch(LEVEL l, PID p, int nostop)
277
{
278
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
279
 
280
#ifdef EDFSTAR_DEBUG
281
  edfstar_printf("(E:dis)");
282
 
283
  edfstar_printf3("(%d %d)",
284
                  iq_query_timespec(p, &lev->ready)->tv_nsec/1000000,
285
                  schedule_time.tv_nsec/1000000);
286
#endif
287
 
288
  level_table[ lev->scheduling_level ]->
289
    private_dispatch(lev->scheduling_level,p,nostop);
290
}
291
 
292
static void EDFSTAR_public_epilogue(LEVEL l, PID p)
293
{
294
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
295
 
296
#ifdef EDFSTAR_DEBUG
297
  edfstar_printf("(E:epi ");
298
#endif
299
 
300
  /* check if the wcet is finished... */
301
  if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) {
302
    /* wcet finished: disable wcet event and count wcet miss */
303
#ifdef EDFSTAR_DEBUG
304
    edfstar_printf2("W%d",p);
305
#endif
306
    proc_table[p].control &= ~CONTROL_CAP;
307
    lev->wcet_miss[p]++;
308
  }
309
#ifdef EDFSTAR_DEBUG
310
  edfstar_printf(")");
311
#endif
312
 
313
  level_table[ lev->scheduling_level ]->
314
    private_epilogue(lev->scheduling_level,p);
315
 
316
  proc_table[p].status = EDFSTAR_READY;
317
}
318
 
319
static void EDFSTAR_public_activate(LEVEL l, PID p)
320
{
321
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
322
  struct timespec t;
323
 
324
  #ifdef EDFSTAR_DEBUG
325
    edfstar_printf("(E:act:%d)",p);
326
  #endif
327
 
328
  /* Test if we are trying to activate a non sleeping task    */
329
  /* save activation (only if needed... */
330
  if (proc_table[p].status != SLEEP) {
331
    /* a periodic task cannot be activated when it is already active */
332
    kern_raise(XACTIVATION,p);
333
    return;
334
  }
335
 
336
  kern_gettime(&t);
337
 
338
  EDFSTAR_internal_activate(lev,p, &t);
339
 
340
  /* Set the deadline timer */
341
  lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
342
                                           EDFSTAR_timer_deadline,
343
                                           (void *)p);
344
 
345
}
346
 
347
static void EDFSTAR_public_unblock(LEVEL l, PID p)
348
{
349
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
350
 
351
#ifdef EDFSTAR_DEBUG
352
  edfstar_printf("(E:ins)");
353
#endif
354
 
355
  /* Insert task in the correct position */
356
  proc_table[p].status = EDFSTAR_READY;
357
  iq_timespec_insert(p,&lev->ready);
358
 
359
  /* and check for preemption! */
360
  EDFSTAR_check_preemption(lev);
361
}
362
 
363
static void EDFSTAR_public_block(LEVEL l, PID p)
364
{
365
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
366
 
367
#ifdef EDFSTAR_DEBUG
368
  edfstar_printf("(E:ext)");
369
#endif
370
 
371
  /* the task is blocked on a synchronization primitive. we have to
372
     remove it from the master module -and- from the local queue! */
373
  iq_extract(p,&lev->ready);
374
 
375
  /* and finally, a preemption check! (it will also call guest_end) */
376
  EDFSTAR_check_preemption(lev);
377
}
378
 
379
static int EDFSTAR_public_message(LEVEL l, PID p, void *m)
380
{
381
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
382
  struct timespec temp;
383
 
384
#ifdef EDFSTAR_DEBUG
385
  edfstar_printf("(E:ecy ");
386
#endif
387
 
388
  switch ((long)(m)) {
389
 
390
    /* Task EndCycle */
391
  case (long)(NULL):
392
 
393
    /* we call guest_end directly here because the same task may
394
       be reinserted in the queue before calling the preemption check! */
395
    level_table[ lev->scheduling_level ]->
396
      private_extract(lev->scheduling_level,p);
397
    lev->activated = NIL;
398
 
399
    iq_extract(p,&lev->ready);
400
 
401
    /* we reset the capacity counters... */
402
    proc_table[p].avail_time = proc_table[p].wcet;
403
 
404
    if (lev->nact[p] > 0) {
405
 
406
      #ifdef EDFSTAR_DEBUG
407
        edfstar_printf2("E%d",p);
408
      #endif
409
 
410
      /* Pending activation: reactivate the thread!!! */
411
      lev->nact[p]--;
412
 
413
      /* see also EDFSTAR_timer_deadline */
414
      kern_gettime(&temp);
415
 
416
      EDFSTAR_internal_activate(lev,p, &temp);
417
 
418
      /* check if the deadline has already expired */
419
      temp = *iq_query_timespec(p, &lev->ready);
420
      if (TIMESPEC_A_LT_B(&temp, &schedule_time)) {
421
          /* count the deadline miss */
422
          lev->dline_miss[p]++;
423
          kern_event_delete(lev->deadline_timer[p]);
424
      }
425
 
426
    } else {
427
 
428
      #ifdef EDFSTAR_DEBUG
429
        edfstar_printf("e%d",p);
430
      #endif
431
 
432
      /* the task has terminated his job before it consume the wcet. All OK! */
433
      proc_table[p].status = EDFSTAR_IDLE;
434
 
435
      /* and finally, a preemption check! */
436
      EDFSTAR_check_preemption(lev);
437
 
438
      /* when the deadline timer fire, it recognize the situation and set
439
         correctly all the stuffs (like reactivation, etc... ) */
440
    }
441
#ifdef EDFSTAR_DEBUG
442
    edfstar_printf(")");
443
#endif
444
 
445
    jet_update_endcycle(); /* Update the Jet data... */
446
    trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
447
    break;
448
 
449
  default:
450
 
241 giacomo 451
    break;
221 giacomo 452
 
453
  }
454
  return 0;
455
}
456
 
457
static void EDFSTAR_public_end(LEVEL l, PID p)
458
{
459
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
460
 
461
#ifdef EDFSTAR_DEBUG
462
  edfstar_printf("(E:end)");
463
#endif
464
 
465
  iq_extract(p,&lev->ready);
466
 
467
  /* we finally put the task in the ready queue */
468
  proc_table[p].status = FREE;
469
 
470
  iq_insertfirst(p,&freedesc);
471
 
472
  if (lev->deadline_timer[p] != -1) {
473
    kern_event_delete(lev->deadline_timer[p]);
474
  }
475
 
476
  /* and finally, a preemption check! (it will also call guest_end) */
477
  EDFSTAR_check_preemption(lev);
478
}
479
 
480
/* Guest Functions
481
   These functions manages a JOB_TASK_MODEL, that is used to put
482
   a guest task in the EDFSTAR ready queue. */
483
 
484
static void EDFSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m)
485
{
486
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
487
  JOB_TASK_MODEL *job;
488
 
489
  if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) {
490
    kern_raise(XINVALID_TASK, p);
491
    return;
492
  }
493
 
494
  job = (JOB_TASK_MODEL *)m;
495
 
496
  /* if the EDFSTAR_guest_create is called, then the pclass must be a
497
     valid pclass. */
498
 
499
  *iq_query_timespec(p, &lev->ready) = job->deadline;
500
 
501
  lev->deadline_timer[p] = -1;
502
  lev->dline_miss[p]     = 0;
503
  lev->wcet_miss[p]      = 0;
504
  lev->nact[p]           = 0;
505
 
506
  if (job->noraiseexc)
507
    lev->flag[p] |= EDFSTAR_FLAG_NORAISEEXC;
508
  else {
509
    lev->flag[p] &= ~EDFSTAR_FLAG_NORAISEEXC;
510
    lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready),
511
                                             EDFSTAR_timer_guest_deadline,
512
                                             (void *)p);
513
  }
514
 
515
  lev->period[p] = job->period;
516
 
517
  /* Insert task in the correct position */
518
  iq_timespec_insert(p,&lev->ready);
519
  proc_table[p].status = EDFSTAR_READY;
520
 
521
  /* check for preemption */
522
  EDFSTAR_check_preemption(lev);
523
 
524
  /* there is no bandwidth guarantee at this level, it is performed
525
     by the level that inserts guest tasks... */
526
}
527
 
528
static void EDFSTAR_private_dispatch(LEVEL l, PID p, int nostop)
529
{
530
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
531
 
532
  level_table[ lev->scheduling_level ]->
533
    private_dispatch(lev->scheduling_level,p,nostop);
534
}
535
 
536
static void EDFSTAR_private_epilogue(LEVEL l, PID p)
537
{
538
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
539
 
540
  /* the task has been preempted. it returns into the ready queue... */
541
  level_table[ lev->scheduling_level ]->
542
    private_epilogue(lev->scheduling_level,p);
543
 
544
  proc_table[p].status = EDFSTAR_READY;
545
}
546
 
547
static void EDFSTAR_private_extract(LEVEL l, PID p)
548
{
549
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
550
 
551
#ifdef EDFSTAR_DEBUG
552
  //kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]);
553
#endif
554
 
555
  iq_extract(p, &lev->ready);
556
 
557
  /* we remove the deadline timer, because the slice is finished */
558
  if (lev->deadline_timer[p] != NIL) {
559
#ifdef EDFSTAR_DEBUG
560
//    kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]);
561
#endif
562
    kern_event_delete(lev->deadline_timer[p]);
563
    lev->deadline_timer[p] = NIL;
564
  }
565
 
566
  /* and finally, a preemption check! (it will also call guest_end() */
567
  EDFSTAR_check_preemption(lev);
568
}
569
 
570
/* Registration functions */
571
 
572
/* Registration function:
573
    int flags                 the init flags ... see EDFSTAR.h */
574
 
575
LEVEL EDFSTAR_register_level(int master)
576
{
577
  LEVEL l;            /* the level that we register */
578
  EDFSTAR_level_des *lev;  /* for readableness only */
579
  PID i;              /* a counter */
580
 
581
#ifdef EDFSTAR_DEBUG
582
  printk("EDFSTAR_register_level\n");
583
#endif
584
 
585
  /* request an entry in the level_table */
586
  l = level_alloc_descriptor(sizeof(EDFSTAR_level_des));
587
 
588
  lev = (EDFSTAR_level_des *)level_table[l];
589
 
590
  printk("    lev=%d\n",(int)lev);
591
 
592
  /* fill the standard descriptor */
593
  lev->l.private_insert   = EDFSTAR_private_insert;
594
  lev->l.private_extract  = EDFSTAR_private_extract;
595
  lev->l.private_dispatch = EDFSTAR_private_dispatch;
596
  lev->l.private_epilogue = EDFSTAR_private_epilogue;
597
 
598
  lev->l.public_guarantee = NULL;
599
  lev->l.public_eligible  = EDFSTAR_public_eligible;
600
  lev->l.public_create    = EDFSTAR_public_create;
601
  lev->l.public_end       = EDFSTAR_public_end;
602
  lev->l.public_dispatch  = EDFSTAR_public_dispatch;
603
  lev->l.public_epilogue  = EDFSTAR_public_epilogue;
604
  lev->l.public_activate  = EDFSTAR_public_activate;
605
  lev->l.public_unblock   = EDFSTAR_public_unblock;
606
  lev->l.public_block     = EDFSTAR_public_block;
607
  lev->l.public_message   = EDFSTAR_public_message;
608
 
609
  /* fill the EDFSTAR descriptor part */
610
  for(i=0; i<MAX_PROC; i++) {
611
    lev->period[i]         = 0;
612
    lev->deadline_timer[i] = -1;
613
    lev->flag[i]           = 0;
614
    lev->dline_miss[i]     = 0;
615
    lev->wcet_miss[i]      = 0;
616
    lev->nact[i]           = 0;
617
    lev->budget[i]         = NIL;
618
    lev->wcet[i]           = 0;
619
  }
620
 
621
  iq_init(&lev->ready, NULL, IQUEUE_NO_PRIORITY);
622
  lev->activated = NIL;
623
 
624
  lev->scheduling_level = master;
625
 
626
  return l;
627
}
628
 
629
int EDFSTAR_get_dline_miss(PID p)
630
{
631
  LEVEL l = proc_table[p].task_level;
632
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
633
 
634
  return lev->dline_miss[p];
635
}
636
 
637
int EDFSTAR_get_wcet_miss(PID p)
638
{
639
  LEVEL l = proc_table[p].task_level;
640
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
641
 
642
  return lev->wcet_miss[p];
643
}
644
 
645
int EDFSTAR_get_nact(PID p)
646
{
647
  LEVEL l = proc_table[p].task_level;
648
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
649
 
650
  return lev->nact[p];
651
}
652
 
653
int EDFSTAR_reset_dline_miss(PID p)
654
{
655
  LEVEL l = proc_table[p].task_level;
656
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
657
 
658
  lev->dline_miss[p] = 0;
659
  return 0;
660
}
661
 
662
int EDFSTAR_reset_wcet_miss(PID p)
663
{
664
  LEVEL l = proc_table[p].task_level;
665
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
666
 
667
  lev->wcet_miss[p] = 0;
668
  return 0;
669
}
670
 
671
int EDFSTAR_setbudget(LEVEL l, PID p, int budget)
672
{
673
 
674
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
675
 
676
  lev->budget[p] = budget;
677
 
678
  return 0;
679
 
680
}
681
 
682
int EDFSTAR_getbudget(LEVEL l, PID p)
683
{
684
 
685
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
686
 
687
  return lev->budget[p];
688
 
689
}
236 giacomo 690
 
691
int EDFSTAR_budget_has_thread(LEVEL l, int budget)
692
{
693
 
694
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
695
  int i;
696
 
697
  for(i = 0; i< MAX_PROC; i++)
698
    if (lev->budget[i] == budget) return 1;
699
 
700
  return 0;
701
 
702
}