Subversion Repositories shark

Rev

Rev 1235 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <kernel/kern.h>

#include "fsf_contract.h"
#include "fsf_server.h"
#include "func.h"
#include "event_header.h"

/* Activate task output */
#define TASK_OUTPUT

int cal_cycles=0;
struct timespec zero_time;                                        

/* Soft and hard Task */
TASK test_task(void *arg)
{
  long long i,exec_cycles = 0;
  int act = 0;
  struct loader_task *l = (struct loader_task *)(arg);
  char tmp[20];

  #ifdef TASK_OUTPUT
    sprintf(tmp,"X[%06d]",act);
    printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task()  / 5 + 5, GREEN, tmp);
  #endif

  if (l->act_number > act+1) generic_set_next_activation(&l->act[act+1]);

  exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles;
 
  for (i=0;i<exec_cycles;i++) calibration_func();
 
  generic_task_endcycle();
   
  act++;
                                                                                                                       
  return NULL;
                                                                                                                             
}

/* Task create */
void loader_task_create()
{

  struct loader_task *current = loader_task_list;
  int i=0, k=0, total_task;
  int total_group = 0;

  total_task = sizeof(loader_task_list)/sizeof(struct loader_task);

  cprintf("Created 1 %d loader tasks\n",total_task);

  while (k < total_task) {
    k++;
    total_group++;
    current->group = total_group;

    for (i=0; i < current->number; i++) {
     
      pthread_t j;
      int err;
     
      err = generic_create_thread(current->server,&j,NULL,test_task,(void *)current,generic_get_task_model(current));
      if (err) {
        cprintf("Error fsf task creating\n");
        sys_end();
      }
     
    }

    current = &loader_task_list[k];

  }
   
  cprintf("Created %d loader tasks\n",total_task);

 
}


int main()
{

  struct timespec total = {20,0};
 
  generic_calibrate_cycle();

  kern_gettime(&zero_time);

  generic_fsfinit();

  loader_task_create();

  generic_set_simulation_time(&total);

  return 0;

}