Subversion Repositories shark

Rev

Rev 1235 | Rev 1239 | 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
 
1236 giacomo 22
  #ifdef TASK_OUTPUT
23
    sprintf(tmp,"X[%06d]",act);
24
    printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task()  / 5 + 5, GREEN, tmp);
25
  #endif
1232 giacomo 26
 
1236 giacomo 27
  if (l->act_number > act+1) generic_set_next_activation(&l->act[act+1]);
1232 giacomo 28
 
1236 giacomo 29
  exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles;
1232 giacomo 30
 
1236 giacomo 31
  for (i=0;i<exec_cycles;i++) calibration_func();
1232 giacomo 32
 
1236 giacomo 33
  generic_task_endcycle();
1235 giacomo 34
 
1236 giacomo 35
  act++;
1235 giacomo 36
 
1232 giacomo 37
  return NULL;
38
 
39
}
40
 
41
/* Task create */
1234 giacomo 42
void loader_task_create()
1232 giacomo 43
{
44
 
1234 giacomo 45
  struct loader_task *current = loader_task_list;
46
  int i=0, k=0, total_task;
1232 giacomo 47
  int total_group = 0;
48
 
1233 giacomo 49
  total_task = sizeof(loader_task_list)/sizeof(struct loader_task);
1232 giacomo 50
 
1235 giacomo 51
  cprintf("Created 1 %d loader tasks\n",total_task);
52
 
1234 giacomo 53
  while (k < total_task) {
1232 giacomo 54
    k++;
55
    total_group++;
56
    current->group = total_group;
57
 
58
    for (i=0; i < current->number; i++) {
59
 
60
      pthread_t j;
61
      int err;
62
 
63
      err = generic_create_thread(current->server,&j,NULL,test_task,(void *)current,generic_get_task_model(current));
64
      if (err) {
65
        cprintf("Error fsf task creating\n");
66
        sys_end();
67
      }
68
 
69
    }
70
 
1234 giacomo 71
    current = &loader_task_list[k];
72
 
1232 giacomo 73
  }
74
 
1234 giacomo 75
  cprintf("Created %d loader tasks\n",total_task);
76
 
1232 giacomo 77
 
78
}
79
 
80
 
81
int main()
82
{
83
 
1234 giacomo 84
  struct timespec total = {20,0};
1233 giacomo 85
 
1232 giacomo 86
  generic_calibrate_cycle();
1234 giacomo 87
 
1233 giacomo 88
  kern_gettime(&zero_time);
1232 giacomo 89
 
90
  generic_fsfinit();
91
 
1234 giacomo 92
  loader_task_create();
1232 giacomo 93
 
1233 giacomo 94
  generic_set_simulation_time(&total);
1232 giacomo 95
 
96
  return 0;
97
 
98
}