Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

#ifndef __FUNC_H__
#define __FUNC_H__

#include "kernel/kern.h"
#include "fsf_basic_types.h"
#include "fsf_core.h"
#include "fsf_server.h"
#include "shark.h"

#define OS_SHARK


#define get_current_exec_task() exec_shadow
/* Return the PID/pthread_t of calling task */

#define generic_get_server_from_contract get_server_from_contract
/* Return the server_id from the contract number used
 * inside .fsf file to define contract parameters
 *
 * generic_get_server_from_contract(int contract_number) */


#define generic_calibrate_cycle calibrate_cycle
/* Set the calibration parameter "cal_cycle"
 * only if it's initialized to 0. The calibration routine
 * calculates cal_cycle from CALIBRATION_DELTA.
 * This step can also be performed outside the demo.
 * Inside calibrate.h you can set the calibration parameters
 * for calibration step performed outside.
 *
 * cal_cycle is the number of cycles that are needed to
 * make CALIBRATION_DELTA number of iteration.
 *
 * kern_cli();
 * kern_gettime(&start);
 * for (i=0;i<CALIBRATION_DELTA;i++)
 *   __asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
 *                         "cpuid\n\t"
 *                         :::"eax","ebx","ecx","edx");
 * kern_gettime(&end);
 * kern_sti();
 *
 * SUBTIMESPEC(&end,&start,&diff);
 * cal_cycles = TIMESPEC2USEC(&diff);
 *
 */


#define generic_set_next_activation set_next_activation
/* Set the next activation time. It's like fsf_schedule_next_timed_job
 * but it don't return nothing
 */


#define generic_set_simulation_time set_simulation_time
/* Set the end time of simulation */

#define generic_get_task_model get_task_model
/* Return a pointer to the struct that contains the
 * local shceduler parameter */


#define generic_start_simulation start_simulation
/* Start the simulation */

#define generic_fsfinit() fsfinit()
/* Create the fsf_server */

#define generic_task_endcycle() task_endcycle()
/* The job is finished */

#define generic_end_simulation() exit(0)
/* Exit from simulation */

#define printf cprintf
/* Printf standard function */

/* Mutex */
extern __inline__ void generic_lock_mutex(int res) {
  extern mutex_t mutex_table[MAX_MUTEX];

  mutex_lock(&mutex_table[res]);
}

extern __inline__ void generic_unlock_mutex(int res) {
  extern mutex_t mutex_table[MAX_MUTEX];
                                                                                                                             
  mutex_unlock(&mutex_table[res]);
}

/* TASK RUNTIME FUNCTIONS */

extern __inline__ void start_oneshot_task(void) {}
extern __inline__ void end_oneshot_task(void) {}

extern __inline__ void start_periodic_task(void) {}
extern __inline__ void start_job_periodic_task(void) {
   task_testcancel();
}
extern __inline__ void end_job_periodic_task(void) {
   task_testcancel();
}
extern __inline__ void end_periodic_task(void) {}

extern __inline__ void start_back_task(void) {}
extern __inline__ void start_job_back_task(void) {
  task_testcancel();
}
extern __inline__ void end_job_back_task(void) {
  task_testcancel();
}
extern __inline__ void end_back_task(void) {}

#endif