Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1232 giacomo 1
#include <kernel/kern.h>
2
 
3
#include "fsf_contract.h"
4
#include "fsf_server.h"
1233 giacomo 5
#include "func.h"
1232 giacomo 6
#include "event_header.h"
7
 
8
/* Activate task output */
9
#define TASK_OUTPUT
10
 
1233 giacomo 11
int cal_cycles=0;
12
struct timespec zero_time;                                        
1232 giacomo 13
 
14
/* Soft and hard Task */
15
TASK test_task(void *arg)
16
{
17
  long long i,exec_cycles = 0;
18
  int act = 0;
1234 giacomo 19
  struct loader_task *l = (struct loader_task *)(arg);
1232 giacomo 20
  char tmp[20];
21
 
1234 giacomo 22
  while((l->act_number) > act) {
1232 giacomo 23
 
24
    act++;
25
 
26
    #ifdef TASK_OUTPUT
27
      sprintf(tmp,"X[%06d]",act);
28
      printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task()  / 5 + 5, GREEN, tmp);
29
    #endif
30
 
1233 giacomo 31
    generic_set_next_activation(&l->act[act]);
1232 giacomo 32
 
1233 giacomo 33
    exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles;
1232 giacomo 34
 
1234 giacomo 35
    #ifdef TASK_OUTPUT
36
      sprintf(tmp,"X[%06d]",act);
37
      printf_xy((get_current_exec_task() % 5) * 9 + 34, get_current_exec_task() / 5 + 5, GREEN, tmp);
38
    #endif
39
 
1232 giacomo 40
    for (i=0;i<exec_cycles;i++) calibration_func();
41
 
42
 
1234 giacomo 43
    generic_task_endcycle();
1232 giacomo 44
 
45
  }
46
 
47
  return NULL;
48
 
49
}
50
 
51
/* Task create */
1234 giacomo 52
void loader_task_create()
1232 giacomo 53
{
54
 
1234 giacomo 55
  struct loader_task *current = loader_task_list;
56
  int i=0, k=0, total_task;
1232 giacomo 57
  int total_group = 0;
58
 
1233 giacomo 59
  total_task = sizeof(loader_task_list)/sizeof(struct loader_task);
1232 giacomo 60
 
1234 giacomo 61
  while (k < total_task) {
1232 giacomo 62
    k++;
63
    total_group++;
64
    current->group = total_group;
65
 
66
    for (i=0; i < current->number; i++) {
67
 
68
      pthread_t j;
69
      int err;
70
 
71
      err = generic_create_thread(current->server,&j,NULL,test_task,(void *)current,generic_get_task_model(current));
72
      if (err) {
73
        cprintf("Error fsf task creating\n");
74
        sys_end();
75
      }
76
 
77
    }
78
 
1234 giacomo 79
    current = &loader_task_list[k];
80
 
1232 giacomo 81
  }
82
 
1234 giacomo 83
  cprintf("Created %d loader tasks\n",total_task);
84
 
1232 giacomo 85
 
86
}
87
 
88
 
89
int main()
90
{
91
 
1234 giacomo 92
  struct timespec total = {20,0};
1233 giacomo 93
 
1232 giacomo 94
  generic_calibrate_cycle();
1234 giacomo 95
 
1233 giacomo 96
  kern_gettime(&zero_time);
1232 giacomo 97
 
98
  generic_fsfinit();
99
 
1234 giacomo 100
  loader_task_create();
1232 giacomo 101
 
1233 giacomo 102
  generic_set_simulation_time(&total);
1232 giacomo 103
 
104
  return 0;
105
 
106
}