Subversion Repositories shark

Rev

Rev 1264 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef __FUNC_H__
#define __FUNC_H__

#include "kernel/kern.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_create_thread fsf_create_thread
/* Create a task/thread inside a specific server.
 * it's very similar to fsf_create_thread, but we need a parameter
 * to set the local scheduler task and actually it's outside
 * the framework
 *
 * generic_task_create(
 *           server number,
 *           pthread_t of created task (-1 if failed),
 *           pthread_attr_t,
 *           task_body,
 *           arg of the body (must be "(void *)current"),
 *           arg for real-time task specification)
 */


#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() sys_end()
/* Exit from simulation */

#define printf cprintf
/* Printf standard function */

/* 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