Subversion Repositories shark

Rev

Rev 241 | Rev 296 | 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
} EDFSTAR_level_des;
118
 
119
static void EDFSTAR_check_preemption(EDFSTAR_level_des *lev)
120
{
121
  PID first;
122
 
123
#ifdef EDFSTAR_DEBUG
124
  edfstar_printf("(E:chk)");
125
#endif
126
 
127
  if ((first = iq_query_first(&lev->ready)) != lev->activated) {
128
    if (lev->activated != NIL)
129
      level_table[ lev->scheduling_level ]->
130
        private_extract(lev->scheduling_level, lev->activated);
131
 
132
    lev->activated = first;
133
 
134
    if (first != NIL) {
135
      BUDGET_TASK_MODEL b;
136
      budget_task_default_model(b, lev->budget[first]);
137
 
138
      level_table[ lev->scheduling_level ]->
139
        private_insert(lev->scheduling_level, first, (TASK_MODEL *)&b);
140
    }
141
  }
142
}
143
 
144
static void EDFSTAR_timer_deadline(void *par);
145
 
146
static void EDFSTAR_internal_activate(EDFSTAR_level_des *lev, PID p,
147
                                      struct timespec *t)
148
{
149
#ifdef EDFSTAR_DEBUG
150
  edfstar_printf("(E:iact)");
151
#endif
152
 
153
  ADDUSEC2TIMESPEC(lev->period[p], t);
154
 
155
  *iq_query_timespec(p, &lev->ready) = *t;
156
  lev->deadline_timespec[p] = *t;
157
 
158
  /* Insert task in the correct position */
159
  proc_table[p].status = EDFSTAR_READY;
160
  iq_timespec_insert(p,&lev->ready);
161
 
162
  /* needed because when there is a wcet miss I disable CONTROL_CAP */
163
  proc_table[p].control |= CONTROL_CAP;
164
 
165
  /* check for preemption */
166
  EDFSTAR_check_preemption(lev);
167
}
168
 
169
static void EDFSTAR_timer_deadline(void *par)
170
{
171
  PID p = (PID) par;
172
  EDFSTAR_level_des *lev;
173
 
174
#ifdef EDFSTAR_DEBUG
175
//  edfstar_printf("(E:tdl ");
176
#endif
177
 
178
  lev = (EDFSTAR_level_des *)level_table[proc_table[p].task_level];
179
 
180
  switch (proc_table[p].status) {
181
    case EDFSTAR_IDLE:
182
#ifdef EDFSTAR_DEBUG
183
//      edfstar_printf2("I%d",p);
184
#endif
185
      /* set the request time */
186
      EDFSTAR_internal_activate(lev,p,iq_query_timespec(p, &lev->ready));
187
 
188
      event_need_reschedule();
189
      break;
190
 
191
    default:
224 giacomo 192
  #ifdef EDFSTAR_DEBUG
221 giacomo 193
      kern_printf("(E:Dl:%d)",p);
224 giacomo 194
  #endif
221 giacomo 195
      /* else, a deadline miss occurred!!! */
196
      lev->dline_miss[p]++;
197
 
198
      /* the task is into another state */
199
      lev->nact[p]++;
200
 
201
      /* Set the deadline timer */
202
      ADDUSEC2TIMESPEC(lev->period[p], &lev->deadline_timespec[p]);
203
  }
204
 
205
  /* Set the deadline timer */
206
  lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
207
                                           EDFSTAR_timer_deadline,
208
                                           (void *)p);
209
 
210
#ifdef EDFSTAR_DEBUG
211
//  edfstar_printf(")");
212
#endif
213
}
214
 
215
static void EDFSTAR_timer_guest_deadline(void *par)
216
{
217
  PID p = (PID) par;
218
 
219
#ifdef EDFSTAR_DEBUG
220
  edfstar_printf("(E:gdl)");
221
#endif
222
 
223
  kern_raise(XDEADLINE_MISS,p);
224
}
225
 
226
static int EDFSTAR_public_create(LEVEL l, PID p, TASK_MODEL *m)
227
{
228
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
229
 
230
  /* if the EDFSTAR_task_create is called, then the pclass must be a
231
     valid pclass. */
232
  HARD_TASK_MODEL *h;
233
 
234
  if (m->pclass != HARD_PCLASS) return -1;
235
  if (m->level != 0 && m->level != l) return -1;
236
  h = (HARD_TASK_MODEL *)m;
237
  if (!h->wcet || !h->mit || h->periodicity != PERIODIC) return -1;
238
  /* now we know that m is a valid model */
239
 
240
 
241
#ifdef EDFSTAR_DEBUG
242
  edfstar_printf("(E:tcr)");
243
#endif
244
 
245
  lev->period[p] = h->mit;
246
 
247
  lev->flag[p] = 0;
248
  lev->deadline_timer[p] = -1;
249
  lev->dline_miss[p]     = 0;
250
  lev->wcet_miss[p]      = 0;
251
  lev->nact[p]           = 0;
252
 
253
  /* Enable wcet check */
254
  proc_table[p].avail_time = h->wcet;
255
  proc_table[p].wcet       = h->wcet;
256
  proc_table[p].control |= CONTROL_CAP;
257
 
258
  return 0; /* OK, also if the task cannot be guaranteed... */
259
}
260
 
261
static int EDFSTAR_public_eligible(LEVEL l, PID p)
262
{
263
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
264
 
265
#ifdef EDFSTAR_DEBUG
266
  edfstar_printf2("(E:eli)");
267
#endif
268
 
269
  return level_table[ lev->scheduling_level ]->
270
    private_eligible(lev->scheduling_level,p);
271
}
272
 
273
static void EDFSTAR_public_dispatch(LEVEL l, PID p, int nostop)
274
{
275
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
276
 
277
#ifdef EDFSTAR_DEBUG
278
  edfstar_printf("(E:dis)");
279
 
280
  edfstar_printf3("(%d %d)",
281
                  iq_query_timespec(p, &lev->ready)->tv_nsec/1000000,
282
                  schedule_time.tv_nsec/1000000);
283
#endif
284
 
285
  level_table[ lev->scheduling_level ]->
286
    private_dispatch(lev->scheduling_level,p,nostop);
287
}
288
 
289
static void EDFSTAR_public_epilogue(LEVEL l, PID p)
290
{
291
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
292
 
293
#ifdef EDFSTAR_DEBUG
294
  edfstar_printf("(E:epi ");
295
#endif
296
 
297
  /* check if the wcet is finished... */
298
  if (proc_table[p].avail_time <= 0 && proc_table[p].control&CONTROL_CAP) {
299
    /* wcet finished: disable wcet event and count wcet miss */
300
#ifdef EDFSTAR_DEBUG
301
    edfstar_printf2("W%d",p);
302
#endif
303
    proc_table[p].control &= ~CONTROL_CAP;
304
    lev->wcet_miss[p]++;
305
  }
306
#ifdef EDFSTAR_DEBUG
307
  edfstar_printf(")");
308
#endif
309
 
310
  level_table[ lev->scheduling_level ]->
311
    private_epilogue(lev->scheduling_level,p);
312
 
313
  proc_table[p].status = EDFSTAR_READY;
314
}
315
 
316
static void EDFSTAR_public_activate(LEVEL l, PID p)
317
{
318
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
319
  struct timespec t;
320
 
321
  #ifdef EDFSTAR_DEBUG
322
    edfstar_printf("(E:act:%d)",p);
323
  #endif
324
 
325
  /* Test if we are trying to activate a non sleeping task    */
326
  /* save activation (only if needed... */
327
  if (proc_table[p].status != SLEEP) {
328
    /* a periodic task cannot be activated when it is already active */
329
    kern_raise(XACTIVATION,p);
330
    return;
331
  }
332
 
333
  kern_gettime(&t);
334
 
335
  EDFSTAR_internal_activate(lev,p, &t);
336
 
337
  /* Set the deadline timer */
338
  lev->deadline_timer[p] = kern_event_post(&lev->deadline_timespec[p],
339
                                           EDFSTAR_timer_deadline,
340
                                           (void *)p);
341
 
342
}
343
 
344
static void EDFSTAR_public_unblock(LEVEL l, PID p)
345
{
346
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
347
 
348
#ifdef EDFSTAR_DEBUG
349
  edfstar_printf("(E:ins)");
350
#endif
351
 
352
  /* Insert task in the correct position */
353
  proc_table[p].status = EDFSTAR_READY;
354
  iq_timespec_insert(p,&lev->ready);
355
 
356
  /* and check for preemption! */
357
  EDFSTAR_check_preemption(lev);
358
}
359
 
360
static void EDFSTAR_public_block(LEVEL l, PID p)
361
{
362
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
363
 
364
#ifdef EDFSTAR_DEBUG
365
  edfstar_printf("(E:ext)");
366
#endif
367
 
368
  /* the task is blocked on a synchronization primitive. we have to
369
     remove it from the master module -and- from the local queue! */
370
  iq_extract(p,&lev->ready);
371
 
372
  /* and finally, a preemption check! (it will also call guest_end) */
373
  EDFSTAR_check_preemption(lev);
374
}
375
 
376
static int EDFSTAR_public_message(LEVEL l, PID p, void *m)
377
{
378
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
379
  struct timespec temp;
380
 
381
#ifdef EDFSTAR_DEBUG
382
  edfstar_printf("(E:ecy ");
383
#endif
384
 
385
  switch ((long)(m)) {
386
 
387
    /* Task EndCycle */
388
  case (long)(NULL):
389
 
390
    /* we call guest_end directly here because the same task may
391
       be reinserted in the queue before calling the preemption check! */
392
    level_table[ lev->scheduling_level ]->
393
      private_extract(lev->scheduling_level,p);
394
    lev->activated = NIL;
395
 
396
    iq_extract(p,&lev->ready);
397
 
398
    /* we reset the capacity counters... */
399
    proc_table[p].avail_time = proc_table[p].wcet;
400
 
401
    if (lev->nact[p] > 0) {
402
 
403
      #ifdef EDFSTAR_DEBUG
404
        edfstar_printf2("E%d",p);
405
      #endif
406
 
407
      /* Pending activation: reactivate the thread!!! */
408
      lev->nact[p]--;
409
 
410
      /* see also EDFSTAR_timer_deadline */
411
      kern_gettime(&temp);
412
 
413
      EDFSTAR_internal_activate(lev,p, &temp);
414
 
415
      /* check if the deadline has already expired */
416
      temp = *iq_query_timespec(p, &lev->ready);
417
      if (TIMESPEC_A_LT_B(&temp, &schedule_time)) {
418
          /* count the deadline miss */
419
          lev->dline_miss[p]++;
420
          kern_event_delete(lev->deadline_timer[p]);
421
      }
422
 
423
    } else {
424
 
425
      #ifdef EDFSTAR_DEBUG
426
        edfstar_printf("e%d",p);
427
      #endif
428
 
429
      /* the task has terminated his job before it consume the wcet. All OK! */
430
      proc_table[p].status = EDFSTAR_IDLE;
431
 
432
      /* and finally, a preemption check! */
433
      EDFSTAR_check_preemption(lev);
434
 
435
      /* when the deadline timer fire, it recognize the situation and set
436
         correctly all the stuffs (like reactivation, etc... ) */
437
    }
438
#ifdef EDFSTAR_DEBUG
439
    edfstar_printf(")");
440
#endif
441
 
442
    jet_update_endcycle(); /* Update the Jet data... */
443
    trc_logevent(TRC_ENDCYCLE,&exec_shadow); /* tracer stuff */
444
    break;
445
 
446
  default:
447
 
241 giacomo 448
    break;
221 giacomo 449
 
450
  }
451
  return 0;
452
}
453
 
454
static void EDFSTAR_public_end(LEVEL l, PID p)
455
{
456
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
457
 
458
#ifdef EDFSTAR_DEBUG
459
  edfstar_printf("(E:end)");
460
#endif
461
 
462
  iq_extract(p,&lev->ready);
463
 
464
  /* we finally put the task in the ready queue */
465
  proc_table[p].status = FREE;
466
 
467
  iq_insertfirst(p,&freedesc);
468
 
469
  if (lev->deadline_timer[p] != -1) {
470
    kern_event_delete(lev->deadline_timer[p]);
471
  }
472
 
473
  /* and finally, a preemption check! (it will also call guest_end) */
474
  EDFSTAR_check_preemption(lev);
475
}
476
 
477
/* Guest Functions
478
   These functions manages a JOB_TASK_MODEL, that is used to put
479
   a guest task in the EDFSTAR ready queue. */
480
 
481
static void EDFSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m)
482
{
483
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
484
  JOB_TASK_MODEL *job;
485
 
486
  if (m->pclass != JOB_PCLASS || (m->level != 0 && m->level != l) ) {
487
    kern_raise(XINVALID_TASK, p);
488
    return;
489
  }
490
 
491
  job = (JOB_TASK_MODEL *)m;
492
 
493
  /* if the EDFSTAR_guest_create is called, then the pclass must be a
494
     valid pclass. */
495
 
496
  *iq_query_timespec(p, &lev->ready) = job->deadline;
497
 
498
  lev->deadline_timer[p] = -1;
499
  lev->dline_miss[p]     = 0;
500
  lev->wcet_miss[p]      = 0;
501
  lev->nact[p]           = 0;
502
 
503
  if (job->noraiseexc)
504
    lev->flag[p] |= EDFSTAR_FLAG_NORAISEEXC;
505
  else {
506
    lev->flag[p] &= ~EDFSTAR_FLAG_NORAISEEXC;
507
    lev->deadline_timer[p] = kern_event_post(iq_query_timespec(p, &lev->ready),
508
                                             EDFSTAR_timer_guest_deadline,
509
                                             (void *)p);
510
  }
511
 
512
  lev->period[p] = job->period;
513
 
514
  /* Insert task in the correct position */
515
  iq_timespec_insert(p,&lev->ready);
516
  proc_table[p].status = EDFSTAR_READY;
517
 
518
  /* check for preemption */
519
  EDFSTAR_check_preemption(lev);
520
 
521
  /* there is no bandwidth guarantee at this level, it is performed
522
     by the level that inserts guest tasks... */
523
}
524
 
525
static void EDFSTAR_private_dispatch(LEVEL l, PID p, int nostop)
526
{
527
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
528
 
529
  level_table[ lev->scheduling_level ]->
530
    private_dispatch(lev->scheduling_level,p,nostop);
531
}
532
 
533
static void EDFSTAR_private_epilogue(LEVEL l, PID p)
534
{
535
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
536
 
537
  /* the task has been preempted. it returns into the ready queue... */
538
  level_table[ lev->scheduling_level ]->
539
    private_epilogue(lev->scheduling_level,p);
540
 
541
  proc_table[p].status = EDFSTAR_READY;
542
}
543
 
544
static void EDFSTAR_private_extract(LEVEL l, PID p)
545
{
546
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
547
 
548
#ifdef EDFSTAR_DEBUG
549
  //kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]);
550
#endif
551
 
552
  iq_extract(p, &lev->ready);
553
 
554
  /* we remove the deadline timer, because the slice is finished */
555
  if (lev->deadline_timer[p] != NIL) {
556
#ifdef EDFSTAR_DEBUG
557
//    kern_printf("EDFSTAR_guest_end: dline timer %d\n",lev->deadline_timer[p]);
558
#endif
559
    kern_event_delete(lev->deadline_timer[p]);
560
    lev->deadline_timer[p] = NIL;
561
  }
562
 
563
  /* and finally, a preemption check! (it will also call guest_end() */
564
  EDFSTAR_check_preemption(lev);
565
}
566
 
567
/* Registration functions */
568
 
569
/* Registration function:
570
    int flags                 the init flags ... see EDFSTAR.h */
571
 
572
LEVEL EDFSTAR_register_level(int master)
573
{
574
  LEVEL l;            /* the level that we register */
575
  EDFSTAR_level_des *lev;  /* for readableness only */
576
  PID i;              /* a counter */
577
 
578
#ifdef EDFSTAR_DEBUG
579
  printk("EDFSTAR_register_level\n");
580
#endif
581
 
582
  /* request an entry in the level_table */
583
  l = level_alloc_descriptor(sizeof(EDFSTAR_level_des));
584
 
585
  lev = (EDFSTAR_level_des *)level_table[l];
586
 
587
  printk("    lev=%d\n",(int)lev);
588
 
589
  /* fill the standard descriptor */
590
  lev->l.private_insert   = EDFSTAR_private_insert;
591
  lev->l.private_extract  = EDFSTAR_private_extract;
592
  lev->l.private_dispatch = EDFSTAR_private_dispatch;
593
  lev->l.private_epilogue = EDFSTAR_private_epilogue;
594
 
595
  lev->l.public_guarantee = NULL;
596
  lev->l.public_eligible  = EDFSTAR_public_eligible;
597
  lev->l.public_create    = EDFSTAR_public_create;
598
  lev->l.public_end       = EDFSTAR_public_end;
599
  lev->l.public_dispatch  = EDFSTAR_public_dispatch;
600
  lev->l.public_epilogue  = EDFSTAR_public_epilogue;
601
  lev->l.public_activate  = EDFSTAR_public_activate;
602
  lev->l.public_unblock   = EDFSTAR_public_unblock;
603
  lev->l.public_block     = EDFSTAR_public_block;
604
  lev->l.public_message   = EDFSTAR_public_message;
605
 
606
  /* fill the EDFSTAR descriptor part */
607
  for(i=0; i<MAX_PROC; i++) {
608
    lev->period[i]         = 0;
609
    lev->deadline_timer[i] = -1;
610
    lev->flag[i]           = 0;
611
    lev->dline_miss[i]     = 0;
612
    lev->wcet_miss[i]      = 0;
613
    lev->nact[i]           = 0;
614
    lev->budget[i]         = NIL;
615
  }
616
 
617
  iq_init(&lev->ready, NULL, IQUEUE_NO_PRIORITY);
618
  lev->activated = NIL;
619
 
620
  lev->scheduling_level = master;
621
 
622
  return l;
623
}
624
 
625
int EDFSTAR_get_dline_miss(PID p)
626
{
627
  LEVEL l = proc_table[p].task_level;
628
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
629
 
630
  return lev->dline_miss[p];
631
}
632
 
633
int EDFSTAR_get_wcet_miss(PID p)
634
{
635
  LEVEL l = proc_table[p].task_level;
636
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
637
 
638
  return lev->wcet_miss[p];
639
}
640
 
641
int EDFSTAR_get_nact(PID p)
642
{
643
  LEVEL l = proc_table[p].task_level;
644
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
645
 
646
  return lev->nact[p];
647
}
648
 
649
int EDFSTAR_reset_dline_miss(PID p)
650
{
651
  LEVEL l = proc_table[p].task_level;
652
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
653
 
654
  lev->dline_miss[p] = 0;
655
  return 0;
656
}
657
 
658
int EDFSTAR_reset_wcet_miss(PID p)
659
{
660
  LEVEL l = proc_table[p].task_level;
661
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
662
 
663
  lev->wcet_miss[p] = 0;
664
  return 0;
665
}
666
 
667
int EDFSTAR_setbudget(LEVEL l, PID p, int budget)
668
{
669
 
670
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
671
 
672
  lev->budget[p] = budget;
673
 
674
  return 0;
675
 
676
}
677
 
678
int EDFSTAR_getbudget(LEVEL l, PID p)
679
{
680
 
681
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
682
 
683
  return lev->budget[p];
684
 
685
}
236 giacomo 686
 
687
int EDFSTAR_budget_has_thread(LEVEL l, int budget)
688
{
689
 
690
  EDFSTAR_level_des *lev = (EDFSTAR_level_des *)(level_table[l]);
691
  int i;
692
 
693
  for(i = 0; i< MAX_PROC; i++)
694
    if (lev->budget[i] == budget) return 1;
695
 
696
  return 0;
697
 
698
}