Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1232 giacomo 1
#include <func.h>
2
 
3
/* Delay Calibration */
4
int calibrate_cycle()
5
{
6
  long long i;
7
  struct timespec start,end,diff;
8
 
9
  kern_cli();
10
  kern_gettime(&start);
11
  for (i=0;i<CALIBRATION_DELTA;i++) kern_gettime(NULL);
12
  kern_gettime(&end);
13
  kern_sti();
14
 
15
  SUBTIMESPEC(&end,&start,&diff);
16
  cal_cycles = TIMESPEC2USEC(&diff);
17
  cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles);
18
 
19
  return 0;
20
 
21
}
22
 
23
void *get_task_model(task_loader *current) {
24
  if (current->local_scheduler == LOADER_POSIX_SCHEDULER) {
25
    static NRT_TASK_MODEL nrt;
26
 
27
    nrt_task_default_model(nrt);
28
    nrt_task_def_save_arrivals(nrt);
29
    nrt_task_def_ctrl_jet(nrt);
30
    nrt_task_def_usemath(nrt);
31
 
32
    return &nrt;
33
 
34
  }  
35
 
36
  if (current->local_scheduler == LOADER_EDF_SCHEDULER) {
37
    static HARD_TASK_MODEL ht;
38
 
39
    hard_task_default_model(ht);
40
    hard_task_def_ctrl_jet(ht);          
41
    hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
42
    hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
43
    hard_task_def_usemath(ht);
44
    return &ht;
45
  }  
46
 
47
 
48
  if (current->local_scheduler == LOADER_RM_SCHEDULER) {
49
    static HARD_TASK_MODEL ht;
50
 
51
    hard_task_default_model(ht);
52
    hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
53
    hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
54
    hard_task_def_ctrl_jet(ht);
55
    hard_task_def_usemath(ht);
56
    return &ht;
57
  }  
58
 
59
}  
60
 
61
void set_simulation_time (struct timespec *total) {
62
  struct timespec end_time;
63
  kern_gettime(&zero_time);
64
 
65
  loader_first_execution(start_loader_task);
66
 
67
  ADDTIMESPEC(&zero_time,total,&end_time);
68
  kern_event_post(&end_time,(void *)((void *)(sys_end)),NULL);
69
 
70
}
71
 
72
void set_next_activation(struct timespec *next) {
73
  struct timespec end_time;
74
 ADDTIMESPEC(&zero_time,next,&end_time);
75
 kern_event_post(&end_time,(void *)((void *)(task_activate(exec_shadow))),NULL);
76
}