Subversion Repositories shark

Rev

Rev 253 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
241 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
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2002 Paolo Gai
23
 *
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License as published by
26
 * the Free Software Foundation; either version 2 of the License, or
27
 * (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
 *
38
 */
39
 
40
#include "cbsstar.h"
41
 
42
/*
43
 * DEBUG stuffs begin
44
 */
45
//#define CBSSTAR_DEBUG
46
#ifdef CBSSTAR_DEBUG
47
 
48
static __inline__ void fake_printf(char *fmt, ...) {}
49
 
50
#define cbsstar_printf kern_printf
51
#define cbsstar_printf2 kern_printf
52
#define cbsstar_printf3 kern_printf
53
 
54
//#define cbsstar_printf fake_printf
55
//#define cbsstar_printf2 fake_printf
56
//#define cbsstar_printf3 fake_printf
57
 
58
#endif
59
/*
60
 * DEBUG stuffs end
61
 */
62
 
63
/* this structure contains the status for a single budget */
64
struct budget_struct {
65
  TIME Q;                 /* budget */
66
  TIME T;                 /* period */
67
 
68
  struct timespec dline;  /* deadline */
69
  int dline_timer;        /* oslib event for budget reactivation*/
70
  int vtimer;
71
  int avail;              /* current budget */
72
 
73
  LEVEL l;                /* Current CBSSTAR level */
74
  int loc_sched_id;       /* Local scheduler id */
75
  LEVEL loc_sched_level;  /* Local scheduler level */
76
 
77
  PID current;            /* the task currently put in execution */
78
  int flags;
79
 
80
  IQUEUE tasks;           /* a FIFO queue for the tasks handled
81
                             using the budget */
82
 
83
};
84
 
85
#define CBSSTAR_NOACTIVE   0
86
#define CBSSTAR_ACTIVE     1
87
#define CBSSTAR_RECLAIMING 2
88
 
89
typedef struct {
90
  level_des l;               /* the standard level descriptor */
91
 
92
  struct budget_struct *b;   /* the budgets! */
93
  int n;                     /* the maximum index for the budgets */
94
  int freebudgets;           /* number of free budgets; starts from n */
95
 
96
  int tb[MAX_PROC];          /* link task->budget (used in guest_end) */
97
 
98
  bandwidth_t U;   /*+ the used bandwidth by the server       +*/
99
  bandwidth_t Uf;   /*+ the actual used bandwidth by the server       +*/
100
 
101
  int cap_lev;
102
 
103
  LEVEL scheduling_level;
104
 
105
} CBSSTAR_level_des;
106
 
107
 
108
static void CBSSTAR_deadline_timer_hardreservation(void *a)
109
{
110
  struct budget_struct *b = a;
111
  PID p;
112
 
113
  #ifdef CBSSTAR_DEBUG
114
    cbsstar_printf("(CS:HrdRes:");  
115
  #endif
116
 
117
  b->dline_timer = NIL;
118
 
119
  /* we modify the deadline according to rule 4 ... */
120
  /* there is a while because if the wcet is << than the system tick
121
     we need to postpone the deadline many times */
122
 
123
  b->avail += b->Q;
124
  if (b->avail > b->Q) b->avail = b->Q;
125
 
126
  if (b->avail > 0) b->flags = CBSSTAR_ACTIVE;
127
 
128
  /* avail may be <0 because a task executed via a shadow fo many time
129
     b->current == NIL only if the prec task was finished and there
130
     was not any other task to be put in the ready queue
131
     ... we are now activating the next task */
132
  if (b->current == NIL && b->flags) {
133
      if (iq_query_first(&(b->tasks)) != NIL) {
134
        CBSSTAR_level_des *lev;
135
        JOB_TASK_MODEL job;
136
 
137
        p = iq_getfirst(&b->tasks);
138
 
139
        #ifdef CBSSTAR_DEBUG
140
          cbsstar_printf("%d",p);
141
        #endif
142
 
143
        kern_gettime(&b->dline);
144
        ADDUSEC2TIMESPEC(b->T, &b->dline);
145
 
146
        b->current = p;
147
 
148
        lev = (CBSSTAR_level_des *)(level_table[b->l]);
149
 
150
        job_task_default_model(job, b->dline);
151
        job_task_def_noexc(job);
152
        level_table[ lev->scheduling_level ]->
153
          private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
154
 
155
        event_need_reschedule();
156
 
157
    }
158
  }
159
 
160
  if (b->flags == CBSSTAR_NOACTIVE) {
161
    kern_gettime(&b->dline);
162
    ADDUSEC2TIMESPEC(b->T, &b->dline);
163
 
164
    b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b);
165
  }
166
 
167
  #ifdef CBSSTAR_DEBUG
168
    cbsstar_printf(")");
169
  #endif
170
 
171
}
172
 
173
void CBSSTAR_ANC(void *arg)
174
{
175
  struct budget_struct *b = arg;
176
  CBSSTAR_level_des *lev=(CBSSTAR_level_des *)level_table[b->l];
177
 
178
  #ifdef CBSSTAR_DEBUG
179
    cbsstar_printf("(CS:Rec:");
180
  #endif
181
 
182
  b->vtimer = NIL;
183
  if (b->current != NIL && iq_query_first(&(b->tasks)) != NIL) {
184
     bandwidth_t bw;
185
 
186
     b->flags=CBSSTAR_RECLAIMING;
187
 
188
     bw = (MAX_BANDWIDTH / b->T) * b->Q;
189
 
190
     lev->Uf -= bw;
191
 
192
     #ifdef CBSSTAR_DEBUG
193
       cbsstar_printf("%ld",(long)bw);
194
     #endif
195
 
196
 
197
  }
198
 
199
  #ifdef CBSSTAR_DEBUG
200
    cbsstar_printf(")");
201
  #endif
202
 
203
 
204
}
205
 
206
static void CBSSTAR_activation(CBSSTAR_level_des *lev,
207
                           PID p,
208
                           struct timespec *acttime)
209
{
210
  JOB_TASK_MODEL job;
211
  struct budget_struct *b = &lev->b[lev->tb[p]];
212
  /* we have to check if the deadline and the wcet are correct before
213
     activating a new task or an old task... */
214
 
215
  /* we have to check if the deadline and the wcet are correct before
216
   *      activating a new task or an old task... */
217
 
218
   /* check 1: if the deadline is before than the actual scheduling time */
219
 
220
   /* check 2: if ( avail_time >= (cbs_dline - acttime)* (wcet/period) )
221
    *      (rule 7 in the CBS article!) */
222
   TIME t;
223
   struct timespec t2,t3;
224
 
225
   t = (b->T * b->avail) / b->Q;
226
   t3.tv_sec = t / 1000000;
227
   t3.tv_nsec = (t % 1000000) * 1000;
228
 
229
   SUBTIMESPEC(&b->dline, acttime, &t2);
230
   if (/* 1 */ TIMESPEC_A_LT_B(&b->dline, acttime) ||
231
       /* 2 */ TIMESPEC_A_GT_B(&t3, &t2) ) {
232
       TIMESPEC_ASSIGN(&b->dline, acttime);
233
       ADDUSEC2TIMESPEC(b->T, &b->dline);
234
       b->avail=b->Q;
235
       if (b->flags==CBSSTAR_RECLAIMING) {
236
         bandwidth_t bw;
237
 
238
         bw = (MAX_BANDWIDTH / b->T) * b->Q;
239
 
240
         lev->Uf += bw;
241
 
242
         #ifdef CBSSTAR_DEBUG
243
            cbsstar_printf("BW=%ld",(long)bw);
244
         #endif
245
       }
246
 
247
 
248
       b->flags=CBSSTAR_ACTIVE;
249
 
250
  }
251
  else {
252
    SUBTIMESPEC(&b->dline, &t3, &t2);
253
    b->vtimer = kern_event_post(&t2, CBSSTAR_ANC, (void *)&b);
254
  }
255
 
256
 
257
  /* record the current task inserted in the master module */
258
  b->current = p;
259
 
260
  job_task_default_model(job, b->dline);
261
  job_task_def_noexc(job);
262
  level_table[ lev->scheduling_level ]->
263
    private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
264
 
265
}
266
 
267
static void CBSSTAR_account_capacity(CBSSTAR_level_des *lev, PID p)
268
{
269
  struct timespec ty;
270
  TIME tx;
271
  struct budget_struct *b = &lev->b[lev->tb[p]];
272
 
273
  if (lev->cap_lev != NIL && b->current == p) {
274
    kern_event_delete(lev->cap_lev);
275
    lev->cap_lev = NIL;
276
  }
277
 
278
  SUBTIMESPEC(&schedule_time, &cap_lasttime, &ty);
279
  tx = TIMESPEC2USEC(&ty);
280
  b->avail -= tx;
281
 
282
  #ifdef CBSSTAR_DEBUG
283
    kern_printf("(CS:Cap p%d av=%d)", p, b->avail);
284
  #endif
285
 
286
  if (b->avail <= 0) b->flags = CBSSTAR_NOACTIVE;
287
 
288
  if (TIMESPEC_A_LT_B(&b->dline, &schedule_time)) {
289
    /* we modify the deadline ... */
290
    TIMESPEC_ASSIGN(&b->dline, &schedule_time);
291
    ADDUSEC2TIMESPEC(b->T, &b->dline);
292
  }
293
 
294
  if (b->flags == CBSSTAR_NOACTIVE && b->dline_timer == NIL)  {
295
    b->dline_timer=kern_event_post(&b->dline, CBSSTAR_deadline_timer_hardreservation, b);
296
  }
297
 
298
}
299
 
300
 
301
/* The on-line guarantee is enabled only if the appropriate flag is set... */
302
static int CBSSTAR_public_guarantee(LEVEL l, bandwidth_t *freebandwidth)
303
{
304
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
305
 
306
  #ifdef CBSSTAR_DEBUG
307
    cbsstar_printf("(CS:Gua)");
308
  #endif
309
 
310
  if (*freebandwidth >= lev->U) {
311
    *freebandwidth -= lev->U;
312
    return 1;
313
  }
314
  else
315
    return 0;
316
}
317
 
318
static void capacity_handler(void *l)
319
{
320
 
321
  CBSSTAR_level_des *lev = l;
322
  lev->cap_lev = NIL;
323
  event_need_reschedule();
324
 
325
}
326
 
327
static int CBSSTAR_private_eligible(LEVEL l, PID p)
328
{
329
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
330
  struct budget_struct *b = &lev->b[lev->tb[p]];
331
  JOB_TASK_MODEL job;
332
 
333
  /* we have to check if the deadline and the wcet are correct...
334
     if the CBSSTAR level schedules in background with respect to others
335
     levels, there can be the case in witch a task is scheduled by
336
     schedule_time > CBSSTAR_deadline; in this case (not covered in the
337
     article because if there is only the standard scheduling policy
338
     this never apply) we reassign the deadline */
339
  if (b->current == p) {
340
    if ( TIMESPEC_A_LT_B(&b->dline, &schedule_time)) {
341
      if (lev->cap_lev!=NIL) {
342
        kern_event_delete(lev->cap_lev);
343
        lev->cap_lev=NIL;
344
      }
345
 
346
      /* we kill the current activation */
347
      level_table[ lev->scheduling_level ]->
348
        private_extract(lev->scheduling_level, p);
349
      /* we modify the deadline ... */
350
      TIMESPEC_ASSIGN(&b->dline, &schedule_time);
351
      ADDUSEC2TIMESPEC(b->T, &b->dline);
352
 
353
      /* and the capacity */
354
      b->avail = b->Q;
355
      b->flags = CBSSTAR_ACTIVE;
356
 
357
      if (b->dline_timer!=NIL)  {
358
        kern_event_delete(b->dline_timer);
359
        b->dline_timer=NIL;
360
      }
361
 
362
      /* and, finally, we reinsert the task in the master level */
363
      job_task_default_model(job, b->dline);
364
      job_task_def_noexc(job);
365
      level_table[ lev->scheduling_level ]->
366
        private_insert(lev->scheduling_level, p, (TASK_MODEL *)&job);
367
 
368
      return -1;
369
 
370
    }  
371
  }
372
 
373
  return 0;
374
 
375
}
376
 
377
static void CBSSTAR_private_insert(LEVEL l, PID p, TASK_MODEL *m)
378
{
379
  /* A task has been activated for some reason. Basically, the task is
380
  inserted in the queue if the queue is empty, otherwise the task is
381
  inserted into the master module, and an oslib event is posted. */
382
 
383
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
384
  BUDGET_TASK_MODEL *budget;
385
 
386
  if (m->pclass != BUDGET_PCLASS ||
387
      (m->level != 0 && m->level != l)) {
388
    kern_raise(XINVALID_TASK, p);
389
    return;
390
  }
391
  budget = (BUDGET_TASK_MODEL *)m;
392
 
393
  #ifdef CBSSTAR_DEBUG
394
    cbsstar_printf("(CS:PriIns:%d:%d", p, budget->b);
395
  #endif
396
 
397
  if (budget->b == -1)
398
    return;
399
 
400
  lev->tb[p] = budget->b;
401
 
402
  if (lev->b[budget->b].current == NIL && lev->b[budget->b].flags ) {
403
    /* This is the first task in the budget,
404
       the task have to be inserted into the master module */
405
    struct timespec t;
406
    kern_gettime(&t);
407
    CBSSTAR_activation(lev,p,&t);
408
  } else {
409
    /* The budget is not empty, another task is already into the
410
       master module, so the task is inserted at the end of the budget
411
       queue */
412
    iq_insertlast(p,&lev->b[budget->b].tasks);
413
  }
414
 
415
  #ifdef CBSSTAR_DEBUG
416
    cbsstar_printf(")");
417
  #endif
418
 
419
}
420
 
421
static void CBSSTAR_private_extract(LEVEL l, PID p)
422
{
423
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
424
 
425
  #ifdef CBSSTAR_DEBUG
426
    kern_printf("(CS:Ext:%d)", p);
427
  #endif
428
 
429
  /* a task is removed from execution for some reasons. It must be
430
     that it is the first in its budget queue (only the first task in
431
     a budget queue is put into execution!) */
432
 
433
  /* remove the task from execution (or from the ready queue) */
434
  if (lev->b[lev->tb[p]].current == p) {
435
 
436
   CBSSTAR_account_capacity(lev,p);
437
    /* remove the task from the master module */
438
    level_table[ lev->scheduling_level ]->
439
      private_extract(lev->scheduling_level, p);
440
 
441
    /* check if the buffer has someone else to schedule */
442
    if (iq_query_first(&lev->b[lev->tb[p]].tasks) == NIL) {
443
      /* the buffer has no tasks! */
444
      lev->b[lev->tb[p]].current = NIL;
445
    }
446
    else if (lev->b[lev->tb[p]].flags) {
447
      /* if so, insert the new task into the master module */
448
      PID n;
449
      struct timespec t;
450
 
451
      kern_gettime(&t);
452
      n = iq_getfirst(&lev->b[lev->tb[p]].tasks);
453
      CBSSTAR_activation(lev,n,&t);  // it modifies b[lev->tb[p]].current
454
    }
455
    else
456
      lev->b[lev->tb[p]].current=NIL;
457
 
458
  }
459
  else  {
460
    iq_extract(p, &lev->b[lev->tb[p]].tasks);
461
  }
462
}
463
 
464
static void CBSSTAR_private_dispatch(LEVEL l, PID p, int nostop)
465
{
466
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
467
  struct timespec ty;
468
 
469
  #ifdef CBSSTAR_DEBUG
470
    kern_printf("(CS:Dsp:%d)", p);
471
  #endif
472
 
473
  /* the current task (that is the only one inserted in the master module
474
     for the corresponding budget) is dispatched. Note that the current
475
     task is not inserted in any FIFO queue, so the task does not have to
476
     be extracted! */
477
 
478
  /* ... then, we dispatch it to the master level */
479
  level_table[ lev->scheduling_level ]->
480
    private_dispatch(lev->scheduling_level,p,nostop);
481
 
482
  /* ...and finally, we have to post a capacity event */
483
  if (!nostop) {
484
    TIMESPEC_ASSIGN(&ty, &schedule_time);
485
    ADDUSEC2TIMESPEC(lev->b[lev->tb[p]].avail,&ty);
486
    lev->cap_lev = kern_event_post(&ty,capacity_handler, lev);
487
  }
488
 
489
}
490
 
491
static void CBSSTAR_private_epilogue(LEVEL l, PID p)
492
{
493
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
494
  struct budget_struct *b = &lev->b[lev->tb[p]];
495
 
496
  #ifdef CBSSTAR_DEBUG
497
    kern_printf("(CS:Epi:%d)",p);
498
  #endif
499
 
500
  if (p==b->current)  {
501
 
502
    CBSSTAR_account_capacity(lev,p);
503
 
504
    // L'evento di capacità va cancellato perchè sarà ripristinato nella successiva dispatch
505
    /* we have to check if the capacity is still available */
506
    if (b->flags)  {
507
      /* there is capacity available, maybe it is simply a preemption;
508
         the task have to return to the ready queue */
509
      level_table[ lev->scheduling_level ]->
510
        private_epilogue(lev->scheduling_level,p);
511
 
512
    } else {
513
      /* we kill the current activation */
514
      level_table[ lev->scheduling_level ]->
515
        private_extract(lev->scheduling_level, p);    
516
 
517
      iq_insertfirst(p, &b->tasks);
518
      b->current = NIL;
519
 
520
    }
521
 
522
  }
523
 
524
}
525
 
526
/* Registration functions }*/
527
 
528
/*+ Registration function:
529
    int flags                 the init flags ... see CBSSTAR.h +*/
530
LEVEL CBSSTAR_register_level(int n, LEVEL master)
531
{
532
  LEVEL l;            /* the level that we register */
533
  CBSSTAR_level_des *lev;  /* for readableness only */
534
  PID i;              /* a counter */
535
 
536
  kern_printf("CBSSTAR_register_level\n");
537
 
538
  /* request an entry in the level_table */
539
  l = level_alloc_descriptor(sizeof(CBSSTAR_level_des));
540
 
541
  lev = (CBSSTAR_level_des *)level_table[l];
542
 
543
  /* fill the standard descriptor */
544
  lev->l.private_insert   = CBSSTAR_private_insert;
545
  lev->l.private_extract  = CBSSTAR_private_extract;
546
  lev->l.private_eligible = CBSSTAR_private_eligible;
547
  lev->l.private_dispatch = CBSSTAR_private_dispatch;
548
  lev->l.private_epilogue = CBSSTAR_private_epilogue;
549
 
550
  lev->l.public_guarantee = CBSSTAR_public_guarantee;
551
 
552
  /* fill the CBSSTAR descriptor part */
553
  lev->b = (struct budget_struct *)kern_alloc(sizeof(struct budget_struct)*n);
554
 
555
  for (i=0; i<n; i++) {
556
    lev->b[i].Q = 0;
557
    lev->b[i].T = 0;
558
    NULL_TIMESPEC(&lev->b[i].dline);
559
    lev->b[i].dline_timer = NIL;
560
    lev->b[i].avail = 0;
561
    lev->b[i].current = -1;
562
    lev->b[i].flags = CBSSTAR_ACTIVE;
563
    lev->b[i].l=l;
564
    iq_init(&lev->b[i].tasks, /* &freedesc */NULL, 0);
565
  }
566
 
567
  lev->n = n;
568
  lev->freebudgets = 0;
569
 
570
  for (i=0; i<MAX_PROC; i++)
571
    lev->tb[i] = NIL;
572
 
573
  lev->U = 0;
574
  lev->Uf = 0;
575
  lev->cap_lev = NIL;
576
  lev->scheduling_level = master;
577
 
578
  return l;
579
 
580
}
581
 
582
int CBSSTAR_setbudget(LEVEL l, TIME Q, TIME T, LEVEL local_scheduler_level, int scheduler_id)
583
{
584
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
585
  int r;
586
 
587
  #ifdef CBSSTAR_DEBUG
588
    cbsstar_printf("(CS:SetBud)");
589
  #endif
590
 
591
  for (r = 0; r < lev->n; r++)
592
    if (lev->b[r].Q == 0) break;
593
 
594
  if (r != lev->n) {
595
    bandwidth_t b;
596
    b = (MAX_BANDWIDTH / T) * Q;
597
 
598
    /* really update lev->U, checking an overflow... */
599
    if (Q< T && MAX_BANDWIDTH - lev->U > b) {
600
 
601
      lev->U += b;
602
      lev->Uf += b;
603
      lev->freebudgets++;
604
 
605
      lev->b[r].Q = Q;
606
      lev->b[r].T = T;
607
      lev->b[r].avail = Q;
608
      lev->b[r].flags = CBSSTAR_ACTIVE;
609
      lev->b[r].loc_sched_id = scheduler_id;
610
      lev->b[r].loc_sched_level = local_scheduler_level;
611
 
612
      return r;
613
    }
614
    else
615
      return -2;
616
  }
617
  else
618
    return -1;
619
}
620
 
621
int CBSSTAR_removebudget(LEVEL l, int budget)
622
{
623
 
624
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
625
 
626
  bandwidth_t b;
627
 
628
  b = (MAX_BANDWIDTH / lev->b[budget].T) * lev->b[budget].Q;
629
 
630
  lev->U -= b;
631
 
632
  lev->b[budget].Q = 0;
633
  lev->b[budget].T = 0;
634
  NULL_TIMESPEC(&lev->b[budget].dline);
635
  lev->b[budget].dline_timer = NIL;
636
  lev->b[budget].avail = 0;
637
  lev->b[budget].current = -1;
638
  lev->b[budget].flags = CBSSTAR_ACTIVE;
639
 
640
  return 0;
641
 
642
}
643
 
644
int CBSSTAR_adjust_budget(LEVEL l, TIME Q, TIME T, int budget)
645
{
646
 
647
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
648
 
649
  lev->b[budget].Q = Q;
650
  lev->b[budget].T = T;
651
 
652
  return 0;
653
 
654
}
655
 
656
int CBSSTAR_getbudgetinfo(LEVEL l, TIME *Q, TIME *T, int budget)
657
{
658
 
659
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
660
 
661
  *Q = lev->b[budget].Q;
662
  *T = lev->b[budget].T;
663
 
664
  return 0;
665
 
666
}
667
 
668
int CBSSTAR_is_active(LEVEL l, int budget)
669
{
670
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
671
 
672
  return lev->b[budget].flags;
673
 
674
}
675
 
676
int CBSSTAR_get_local_scheduler_level_from_budget(LEVEL l, int budget)
677
{
678
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
679
 
680
  return lev->b[budget].loc_sched_level;
681
 
682
}
683
 
684
int CBSSTAR_get_local_scheduler_level_from_pid(LEVEL l, PID p)
685
{
686
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
687
 
688
  return lev->b[lev->tb[p]].loc_sched_level;
689
 
690
}
691
 
692
int CBSSTAR_get_local_scheduler_id_from_budget(LEVEL l, int budget)
693
{
694
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
695
 
696
  return lev->b[budget].loc_sched_id;
697
 
698
}
699
 
700
int CBSSTAR_get_local_scheduler_id_from_pid(LEVEL l, PID p)
701
{
702
  CBSSTAR_level_des *lev = (CBSSTAR_level_des *)(level_table[l]);
703
 
704
  return lev->b[lev->tb[p]].loc_sched_id;
705
 
706
}
707