Subversion Repositories shark

Rev

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

Rev Author Line No. Line
221 giacomo 1
//=====================================================================
2
//       FFFFFFIII   RRRRR      SSTTTTTTT
3
//      FF         IIR   RR    SS
4
//     FF           IR        SS
5
//    FFFFFF         RRRR    SSSSST      
6
//   FF       FI       RRR  SS
7
//  FF         II     RRR  SS
8
// FF           IIIIIR    RS 
9
//       
10
// Basic FSF(FIRST Scheduling Framework) contract management
11
// S.Ha.R.K. Implementation
12
//=====================================================================
13
 
405 trimarchi 14
#include "ll/i386/64bit.h"
15
 
221 giacomo 16
#include "fsf_contract.h"
241 giacomo 17
#include "fsf_server.h"
221 giacomo 18
 
19
#include <pthread.h>
20
#include <stdlib.h>
21
 
416 trimarchi 22
#define FSF_DEBUG
221 giacomo 23
 
410 trimarchi 24
int current_server=0;
407 giacomo 25
server_elem server_list[FSF_MAX_N_SERVERS];
406 giacomo 26
bandwidth_t fsf_max_bw = 0;
405 trimarchi 27
 
241 giacomo 28
int fsf_server_level;
221 giacomo 29
 
406 giacomo 30
int FSF_register_module(int server_level, bandwidth_t max_bw)
224 giacomo 31
{
32
  printk("FSF Module\n");
410 trimarchi 33
  current_server=0;
241 giacomo 34
  fsf_server_level = server_level;
406 giacomo 35
  fsf_max_bw = max_bw;
224 giacomo 36
 
37
  return 0;
38
 
39
}
40
 
221 giacomo 41
/* Convert the contract specification to
42
 * budget parameters
43
 */
241 giacomo 44
int set_SERVER_budget_from_contract
221 giacomo 45
  (const fsf_contract_parameters_t *contract,
46
   int *budget)
47
{
48
 
49
  int local_scheduler_level = 0;
50
 
51
   switch (contract->local_scheduler_id) {
52
     case FSF_SCHEDULER_POSIX:
241 giacomo 53
       local_scheduler_level = POSIXSTAR_register_level(fsf_server_level,5000,32);
221 giacomo 54
       break;
55
     case FSF_SCHEDULER_EDF:
241 giacomo 56
       local_scheduler_level = EDFSTAR_register_level(fsf_server_level);
221 giacomo 57
       break;
58
     case FSF_SCHEDULER_RM:
241 giacomo 59
       local_scheduler_level = RMSTAR_register_level(fsf_server_level);
221 giacomo 60
       break;
334 giacomo 61
     case FSF_SCHEDULER_MPEG:
62
       local_scheduler_level = MPEGSTAR_register_level(fsf_server_level);
63
       break;
221 giacomo 64
   }    
405 trimarchi 65
 
241 giacomo 66
  *budget = SERVER_setbudget(fsf_server_level,
221 giacomo 67
                              TIMESPEC2USEC(&(contract->budget_min)),
68
                              TIMESPEC2USEC(&(contract->period_max)),
69
                              local_scheduler_level,contract->local_scheduler_id);
70
 
71
  return 0;
72
 
73
}
74
 
405 trimarchi 75
int adjust_SERVER_budget
76
   (int budget, const TIME budget_actual,
77
    const TIME period_actual)
221 giacomo 78
{
79
 
241 giacomo 80
  SERVER_adjust_budget(fsf_server_level,
405 trimarchi 81
                       budget_actual,
82
                       period_actual,
241 giacomo 83
                       budget);
221 giacomo 84
 
85
  return 0;
86
 
87
}
88
 
89
/* Admission Test function */
90
int add_contract(const fsf_contract_parameters_t *contract)
91
{
92
  return 0;
93
 
94
}
95
 
410 trimarchi 96
int relink_contract_to_server(const fsf_contract_parameters_t *contract,
97
                              fsf_server_id_t server)
98
{
99
  TIME T,Q;
100
  int i=0;
101
#ifdef FSF_DEBUG
102
  int temp;
103
  kern_printf("(Relink Server %d)",server);
104
#endif
105
  // find contract
106
  while(i<current_server) {
107
    if (server_list[i].server==server) break;
108
    i++;
109
  }
110
 
111
  server_list[i].server=server;
112
  server_list[i].Qs=1;
113
 
114
  T=TIMESPEC2USEC(&contract->period_min);
115
  Q=TIMESPEC2USEC(&contract->budget_max);
116
  mul32div32to32(MAX_BANDWIDTH,Q,T,server_list[current_server].Umax);
117
 
118
  T=TIMESPEC2USEC(&contract->period_max);
119
  server_list[i].Tmax=T;
120
 
121
  Q=TIMESPEC2USEC(&contract->budget_min);
122
  server_list[i].Cmin=Q;
123
 
124
  mul32div32to32(MAX_BANDWIDTH,Q,T,server_list[i].Umin);
416 trimarchi 125
  server_list[i].U=server_list[i].Umin;
410 trimarchi 126
 
127
#ifdef FSF_DEBUG
128
  mul32div32to32(server_list[i].Umax,100, MAX_BANDWIDTH, temp);
129
  kern_printf("(Umax %d)",temp);
130
  mul32div32to32(server_list[i].Umin,100, MAX_BANDWIDTH, temp);
131
  kern_printf("(Umin %d)",temp);
132
#endif
133
 
134
 return 0;
135
 
136
}
137
 
221 giacomo 138
int link_contract_to_server(const fsf_contract_parameters_t *contract,
139
                            fsf_server_id_t server)
140
{
405 trimarchi 141
  TIME T,Q;
407 giacomo 142
#ifdef FSF_DEBUG
405 trimarchi 143
  int temp;
407 giacomo 144
 
405 trimarchi 145
  kern_printf("(Link Server %d)",server);
146
#endif
147
 
410 trimarchi 148
  server_list[current_server].server=server;
149
  server_list[current_server].Qs=1;
405 trimarchi 150
 
151
  T=TIMESPEC2USEC(&contract->period_min);
152
  Q=TIMESPEC2USEC(&contract->budget_max);
410 trimarchi 153
  mul32div32to32(MAX_BANDWIDTH,Q,T,server_list[current_server].Umax);
405 trimarchi 154
 
155
  T=TIMESPEC2USEC(&contract->period_max);
410 trimarchi 156
  server_list[current_server].Tmax=T;
405 trimarchi 157
 
158
  Q=TIMESPEC2USEC(&contract->budget_min);
410 trimarchi 159
  server_list[current_server].Cmin=Q;
405 trimarchi 160
 
410 trimarchi 161
  mul32div32to32(MAX_BANDWIDTH,Q,T,server_list[current_server].Umin);
416 trimarchi 162
  server_list[current_server].U=server_list[current_server].Umin;
221 giacomo 163
 
405 trimarchi 164
#ifdef FSF_DEBUG
410 trimarchi 165
  mul32div32to32(server_list[current_server].Umax,100, MAX_BANDWIDTH, temp);
405 trimarchi 166
  kern_printf("(Umax %d)",temp);
410 trimarchi 167
  mul32div32to32(server_list[current_server].Umin,100, MAX_BANDWIDTH, temp);
405 trimarchi 168
  kern_printf("(Umin %d)",temp);
169
#endif
170
 
171
 
410 trimarchi 172
  current_server++;
221 giacomo 173
  return 0;
174
 
175
}
176
 
177
int remove_contract(fsf_server_id_t server)
178
{
405 trimarchi 179
  int i=0;
180
  // find the contract
410 trimarchi 181
  while(i<current_server) {
405 trimarchi 182
     if (server_list[i].server==server) break;
183
     i++;
184
  }
221 giacomo 185
 
405 trimarchi 186
  // compress the array;
410 trimarchi 187
  while (i<(current_server-1)) {
405 trimarchi 188
     server_list[i].server=server_list[i+1].server;
189
     server_list[i].Umin=server_list[i+1].Umin;
416 trimarchi 190
     server_list[i].U=server_list[i+1].Umin;    
405 trimarchi 191
     server_list[i].Umax=server_list[i+1].Umax;
192
     server_list[i].Cmin=server_list[i+1].Cmin;
193
     server_list[i].Tmax=server_list[i+1].Tmax;
194
     server_list[i].Qs=server_list[i+1].Qs;
195
     i++;
196
  }
410 trimarchi 197
  current_server--;
405 trimarchi 198
 
199
 
221 giacomo 200
  return 0;
201
 
202
}
203
 
204
 
205
int fsf_negotiate_contract
206
  (const fsf_contract_parameters_t *contract,
207
   fsf_server_id_t                 *server)
208
{
405 trimarchi 209
  SYS_FLAGS f;
210
  int i=0;
211
  TIME T;
212
  TIME Q;
221 giacomo 213
  /* Check if contract is initialized */
214
  if (!contract) return FSF_ERR_NOT_INITIALIZED;
215
 
216
  /* Admission Test */
217
  if (FSF_ADMISSION_TEST_IS_ENABLED)
218
    if (add_contract(contract))
219
      return FSF_ERR_CONTRACT_REJECTED;
405 trimarchi 220
  f = kern_fsave();
221 giacomo 221
 
241 giacomo 222
  /* SERVER => BUDGET */    
223
  set_SERVER_budget_from_contract(contract,server);
221 giacomo 224
 
225
  #ifdef FSF_DEBUG
226
    kern_printf("(New Server %d)",*server);
227
  #endif
228
 
405 trimarchi 229
  if (*server >= 0) {
221 giacomo 230
    link_contract_to_server(contract,*server);
406 giacomo 231
    if (recalculate_contract(fsf_max_bw)==-1)  {
405 trimarchi 232
       kern_frestore(f);
233
       return FSF_ERR_CREATE_SERVER;
234
    }
235
#ifdef  FSF_DEBUG
236
    kern_printf("(Adjust budget)");
237
#endif    
410 trimarchi 238
    for (i=0; i<current_server; i++) {
405 trimarchi 239
       mul32div32to32(MAX_BANDWIDTH,server_list[i].Cmin,server_list[i].U,T);
240
       #ifdef FSF_DEBUG
241
       kern_printf("(T %ld)", T);
242
       #endif
407 giacomo 243
       if (T<=server_list[i].Tmax) {
244
          server_list[i].actual_budget = server_list[i].Cmin;
245
          server_list[i].actual_period = T;
405 trimarchi 246
          adjust_SERVER_budget(server_list[i].server,server_list[i].Cmin, T);
407 giacomo 247
       } else {
405 trimarchi 248
         mul32div32to32(server_list[i].Tmax,server_list[i].U,MAX_BANDWIDTH,Q);
249
         #ifdef FSF_DEBUG
250
         kern_printf("(Q %ld)", Q);
251
         #endif
407 giacomo 252
         server_list[i].actual_budget = Q;
253
         server_list[i].actual_period = server_list[i].Tmax;
405 trimarchi 254
         adjust_SERVER_budget(server_list[i].server,Q, server_list[i].Tmax);
255
       }
416 trimarchi 256
         server_list[i].U=server_list[i].Umin;
405 trimarchi 257
 
258
    }
259
  }
260
  else  {
261
    kern_frestore(f);
221 giacomo 262
    return FSF_ERR_CREATE_SERVER;
405 trimarchi 263
  }
264
  kern_frestore(f);
265
 
221 giacomo 266
  return 0;
267
 
268
}
269
 
241 giacomo 270
int fsf_create_thread
271
  (fsf_server_id_t    server,
272
   pthread_t         *thread,
273
   pthread_attr_t    *attr,
274
   fsf_thread_code_t  thread_code,
275
   void              *arg,
276
   void              *local_scheduler_arg)
221 giacomo 277
{
278
 
279
  int local_scheduler_level,scheduler_id;
280
 
281
  #ifdef FSF_DEBUG 
267 giacomo 282
    kern_printf("(FSF:Insert thread = %d to Server = %d)",*thread,server);
221 giacomo 283
  #endif
284
 
285
  /* Check if server and thread exsist */
241 giacomo 286
  if (server == NIL)
287
    return FSF_ERR_INVALID_SERVER;
221 giacomo 288
 
241 giacomo 289
  local_scheduler_level = SERVER_get_local_scheduler_level_from_budget(fsf_server_level,server);
290
  scheduler_id = SERVER_get_local_scheduler_id_from_budget(fsf_server_level,server);
221 giacomo 291
 
292
  /* Check if thread is already bind */
293
  switch (scheduler_id) {
294
    case FSF_SCHEDULER_POSIX:
295
 
298 giacomo 296
      nrt_task_def_arg(*(NRT_TASK_MODEL *)(local_scheduler_arg),arg);
297
      nrt_task_def_level(*(NRT_TASK_MODEL *)(local_scheduler_arg),local_scheduler_level);
221 giacomo 298
 
298 giacomo 299
      *thread = task_create("POSIXSTAR", thread_code, local_scheduler_arg, NULL);
267 giacomo 300
      if (*thread == NIL) {
301
        #ifdef FSF_DEBUG
302
          kern_printf("(FSF:Error creating thread)");
303
        #endif
241 giacomo 304
        return FSF_ERR_CREATE_THREAD;
267 giacomo 305
      }
221 giacomo 306
 
241 giacomo 307
      POSIXSTAR_setbudget(local_scheduler_level, *thread, (int)(server));
234 giacomo 308
 
221 giacomo 309
    break;
310
    case FSF_SCHEDULER_EDF:
311
 
250 giacomo 312
      hard_task_def_arg(*(HARD_TASK_MODEL *)(local_scheduler_arg),arg);
313
      hard_task_def_level(*(HARD_TASK_MODEL *)(local_scheduler_arg),local_scheduler_level);
314
 
315
      *thread = task_create("EDFSTAR", thread_code, local_scheduler_arg, NULL);
316
      if (*thread == NIL)
317
        return FSF_ERR_CREATE_THREAD;
318
 
319
      EDFSTAR_setbudget(local_scheduler_level, *thread, (int)(server));
320
 
221 giacomo 321
      break;
235 giacomo 322
 
221 giacomo 323
    case FSF_SCHEDULER_RM:
235 giacomo 324
 
273 giacomo 325
      hard_task_def_arg(*(HARD_TASK_MODEL *)(local_scheduler_arg),arg);
326
      hard_task_def_level(*(HARD_TASK_MODEL *)(local_scheduler_arg),local_scheduler_level);
327
 
328
      *thread = task_create("RMSTAR", thread_code, local_scheduler_arg, NULL);
329
      if (*thread == NIL)
330
        return FSF_ERR_CREATE_THREAD;
331
 
332
      RMSTAR_setbudget(local_scheduler_level, *thread, (int)(server));
333
 
334
      break;
334 giacomo 335
    case FSF_SCHEDULER_MPEG:
336
 
337
      hard_task_def_arg(*(HARD_TASK_MODEL *)(local_scheduler_arg),arg);
338
      hard_task_def_level(*(HARD_TASK_MODEL *)(local_scheduler_arg),local_scheduler_level);
339
 
338 giacomo 340
      *thread = task_create("MPEGSTAR", thread_code, local_scheduler_arg, NULL);
334 giacomo 341
      if (*thread == NIL)
342
        return FSF_ERR_CREATE_THREAD;
343
 
344
      MPEGSTAR_setbudget(local_scheduler_level, *thread, (int)(server));
345
 
346
      break;
347
 
221 giacomo 348
    default:
241 giacomo 349
      return FSF_ERR_INVALID_SERVER;
221 giacomo 350
      break;
351
  }
352
 
353
  return 0;
354
 
355
}
356
 
357
int fsf_get_server
358
  (fsf_server_id_t *server,
359
   pthread_t       thread)
360
{
361
  int local_scheduler_level, scheduler_id;
362
 
241 giacomo 363
  local_scheduler_level = SERVER_get_local_scheduler_level_from_pid(fsf_server_level,thread);
364
  scheduler_id = SERVER_get_local_scheduler_id_from_pid(fsf_server_level, thread);
221 giacomo 365
 
366
  switch (scheduler_id) {
367
    case FSF_SCHEDULER_POSIX:  
368
      return POSIXSTAR_getbudget(local_scheduler_level,thread);
369
    case FSF_SCHEDULER_EDF:
235 giacomo 370
      return EDFSTAR_getbudget(local_scheduler_level,thread);
221 giacomo 371
    case FSF_SCHEDULER_RM:
235 giacomo 372
      return RMSTAR_getbudget(local_scheduler_level,thread);
334 giacomo 373
    case FSF_SCHEDULER_MPEG:
374
      return MPEGSTAR_getbudget(local_scheduler_level,thread);
235 giacomo 375
    default:
221 giacomo 376
      return -1;
377
  }
378
 
379
  return -1;
380
 
381
}
382
 
339 giacomo 383
int fsf_get_server_level(void)
384
{
385
 
386
  return fsf_server_level;
387
 
388
}
389
 
221 giacomo 390
int fsf_cancel_contract
391
  (fsf_server_id_t *server)
392
{
393
 
394
  int local_scheduler_level, scheduler_id;
411 trimarchi 395
  SYS_FLAGS f;
396
  TIME T,Q;
397
  int i=0;
221 giacomo 398
 
399
  #ifdef FSF_DEBUG
400
    kern_printf("(Remove server %d)",*server);
401
  #endif
402
 
403
  /* Check server id */
404
  if (*server < 0)
405
    return FSF_ERR_INVALID_SERVER;
406
 
241 giacomo 407
  local_scheduler_level = SERVER_get_local_scheduler_level_from_budget(fsf_server_level,*server);
408
  scheduler_id = SERVER_get_local_scheduler_id_from_budget(fsf_server_level,*server);
221 giacomo 409
 
410
  switch (scheduler_id) {
411
    case FSF_SCHEDULER_POSIX:
412
 
413
      /* Check if some thread use the server */
414
      if(POSIXSTAR_budget_has_thread(local_scheduler_level,*server))
415
        return FSF_ERR_SERVER_USED;
416
 
417
      break;
418
    case FSF_SCHEDULER_EDF:
235 giacomo 419
      /* Check if some thread use the server */
420
      if(EDFSTAR_budget_has_thread(local_scheduler_level,*server))
421
        return FSF_ERR_SERVER_USED;
422
      break;
423
 
221 giacomo 424
    case FSF_SCHEDULER_RM:
235 giacomo 425
      /* Check if some thread use the server */
426
      if(RMSTAR_budget_has_thread(local_scheduler_level,*server))
427
        return FSF_ERR_SERVER_USED;
428
 
221 giacomo 429
      break;
334 giacomo 430
 
431
    case FSF_SCHEDULER_MPEG:
432
      /* Check if some thread use the server */
433
      if(MPEGSTAR_budget_has_thread(local_scheduler_level,*server))
434
        return FSF_ERR_SERVER_USED;
435
 
436
      break;
437
 
221 giacomo 438
  }
439
 
241 giacomo 440
  SERVER_removebudget(fsf_server_level,*server);
221 giacomo 441
 
442
  level_free_descriptor(local_scheduler_level);
405 trimarchi 443
 
221 giacomo 444
  remove_contract(*server);
411 trimarchi 445
 
446
  f=kern_fsave();              
447
  if (recalculate_contract(fsf_max_bw)==-1)  {
448
       kern_frestore(f);
449
       return FSF_ERR_CREATE_SERVER;
450
  }
451
#ifdef  FSF_DEBUG
452
  kern_printf("(Adjust budget)");
453
#endif    
454
  for (i=0; i<current_server; i++) {
455
    mul32div32to32(MAX_BANDWIDTH,server_list[i].Cmin,server_list[i].U,T);
456
#ifdef FSF_DEBUG
457
    kern_printf("(T %ld)", T);
458
#endif
459
    if (T<=server_list[i].Tmax) {
460
      server_list[i].actual_budget = server_list[i].Cmin;
461
      server_list[i].actual_period = T;
462
      adjust_SERVER_budget(server_list[i].server,server_list[i].Cmin, T);
463
    } else {
464
      mul32div32to32(server_list[i].Tmax,server_list[i].U,MAX_BANDWIDTH,Q);
465
#ifdef FSF_DEBUG
466
      kern_printf("(Q %ld)", Q);
467
#endif
468
      server_list[i].actual_budget = Q;
469
      server_list[i].actual_period = server_list[i].Tmax;
470
      adjust_SERVER_budget(server_list[i].server,Q, server_list[i].Tmax);
471
    }
416 trimarchi 472
    server_list[i].U=server_list[i].Umin;
411 trimarchi 473
 
474
  }                                          
221 giacomo 475
 
405 trimarchi 476
 
221 giacomo 477
  *server = -1;
411 trimarchi 478
  kern_frestore(f);
221 giacomo 479
 
480
  return 0;
411 trimarchi 481
 
221 giacomo 482
}
483
 
405 trimarchi 484
int recalculate_contract(bandwidth_t U) {
416 trimarchi 485
  bandwidth_t current_bandwidth;
486
  long int temp_U;
487
  int        Qt;
405 trimarchi 488
  int isok=0;
489
  int i=0;
490
 
407 giacomo 491
  #ifdef FSF_DEBUG
492
    int temp;
493
 
494
    kern_printf("(Recalculate contract)");
495
  #endif
405 trimarchi 496
 
497
  /* The current bandwidth is the min bandwidth */
498
  //current_bandwidth=SERVER_return_bandwidth(fsf_server_level);
499
  #ifdef FSF_DEBUG
410 trimarchi 500
     kern_printf("(nserver %d)", current_server);
405 trimarchi 501
  #endif  
502
 
503
  do  {
504
    current_bandwidth=0;
505
    Qt=0;
410 trimarchi 506
    for (i=0; i<current_server; i++) {
416 trimarchi 507
      if (server_list[i].Qs!=0 && server_list[i].U<server_list[i].Umax)
405 trimarchi 508
         Qt+=server_list[i].Qs;
416 trimarchi 509
       current_bandwidth+=server_list[i].U;
405 trimarchi 510
    }
413 trimarchi 511
 
405 trimarchi 512
    #ifdef FSF_DEBUG
513
    kern_printf("(Total Quality %d)", Qt);
514
    #endif
515
    isok=1;
410 trimarchi 516
    for (i=0; i<current_server; i++) {
416 trimarchi 517
      if (server_list[i].Qs!=0 && server_list[i].U<server_list[i].Umax) {
518
        temp_U=server_list[i].U;
519
        server_list[i].U=U-current_bandwidth;
520
        mul32div32to32(server_list[i].U, server_list[i].Qs, Qt, server_list[i].U);
521
        temp_U+=server_list[i].U;
522
 
523
        if (temp_U<=server_list[i].Umin) {
405 trimarchi 524
           server_list[i].U=server_list[i].Umin;
416 trimarchi 525
        } else if (temp_U>server_list[i].Umax)  {
526
           server_list[i].U=server_list[i].Umax;
405 trimarchi 527
           isok=0;
528
        } else server_list[i].U=temp_U;
529
 
530
#ifdef FSF_DEBUG
531
        mul32div32to32(server_list[i].U,100, MAX_BANDWIDTH, temp);
532
        kern_printf("(Server %d bw %d)", server_list[i].server, temp);
533
#endif 
534
      }
535
    }  
536
 
537
  } while (!isok);
538
 
539
 return 0;
540
}
541
 
542
 
221 giacomo 543
int fsf_renegotiate_contract
544
  (const fsf_contract_parameters_t *new_contract,
545
   fsf_server_id_t server)
546
{
410 trimarchi 547
  SYS_FLAGS f;
548
  TIME T,Q;
549
  int i;
550
 
221 giacomo 551
  #ifdef FSF_DEBUG
552
    kern_printf("(Renegotiate for server %d)",server);
553
  #endif
554
 
555
  if (!new_contract)
556
    return FSF_ERR_NOT_INITIALIZED;
557
 
558
  if (server < 0)
559
    return FSF_ERR_INVALID_SERVER;
405 trimarchi 560
  // compute the new value
561
   f = kern_fsave();
410 trimarchi 562
   // change the parameter
563
   relink_contract_to_server(new_contract, server);
406 giacomo 564
   if (recalculate_contract(fsf_max_bw)==-1)  {
405 trimarchi 565
       kern_frestore(f);
566
       return FSF_ERR_CREATE_SERVER;
567
   }
406 giacomo 568
 
410 trimarchi 569
   for (i=0; i<current_server; i++) {
570
     mul32div32to32(MAX_BANDWIDTH,server_list[i].Cmin,server_list[i].U,T);
571
     #ifdef FSF_DEBUG
572
        kern_printf("(T %ld)", T);
573
     #endif
574
     if (T<=server_list[i].Tmax) {
575
       server_list[i].actual_budget = server_list[i].Cmin;
576
       server_list[i].actual_period = T;
577
       adjust_SERVER_budget(server_list[i].server,server_list[i].Cmin, T);
578
     } else {
579
       mul32div32to32(server_list[i].Tmax,server_list[i].U,MAX_BANDWIDTH,Q);
580
       #ifdef FSF_DEBUG
581
         kern_printf("(Q %ld)", Q);
582
       #endif
583
       server_list[i].actual_budget = Q;
584
       server_list[i].actual_period = server_list[i].Tmax;
585
       adjust_SERVER_budget(server_list[i].server,Q, server_list[i].Tmax);
586
     }
416 trimarchi 587
     server_list[i].U=server_list[i].Umin;
410 trimarchi 588
   }
405 trimarchi 589
   kern_frestore(f);
590
   return 0;
221 giacomo 591
}
241 giacomo 592
 
407 giacomo 593
void print_server_list()
594
{
595
 
596
  int i;
597
 
598
  kern_printf("Server List\n");
599
 
410 trimarchi 600
  for(i=0;i<current_server;i++) {
407 giacomo 601
 
602
    kern_printf("[%d] Q:%d T:%d\n",server_list[i].server,(int)server_list[i].actual_budget,(int)server_list[i].actual_period);
603
 
604
  }
605
 
606
}