Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1255 giacomo 1
#ifndef __FUNC_H__
2
#define __FUNC_H__
1254 giacomo 3
 
1255 giacomo 4
#include "kernel/kern.h"
1254 giacomo 5
#include "shark.h"
6
 
1262 giacomo 7
#define OS_SHARK
8
 
1254 giacomo 9
#define get_current_exec_task() exec_shadow
1262 giacomo 10
/* Return the PID/pthread_t of calling task */
11
 
1254 giacomo 12
#define generic_get_server_from_contract get_server_from_contract 
1262 giacomo 13
/* Return the server_id from the contract number used
14
 * inside .fsf file to define contract parameters
15
 *
16
 * generic_get_server_from_contract(int contract_number) */
17
 
1254 giacomo 18
#define generic_create_thread fsf_create_thread
1262 giacomo 19
/* Create a task/thread inside a specific server.
20
 * it's very similar to fsf_create_thread, but we need a parameter
21
 * to set the local scheduler task and actually it's outside
22
 * the framework
23
 *
24
 * generic_task_create(
25
 *           server number,
26
 *           pthread_t of created task (-1 if failed),
27
 *           pthread_attr_t,
28
 *           task_body,
29
 *           arg of the body (must be "(void *)current"),
30
 *           arg for real-time task specification)
31
 */
32
 
1254 giacomo 33
#define generic_calibrate_cycle calibrate_cycle
1262 giacomo 34
/* Set the calibration parameter "cal_cycle"
35
 * only if it's initialized to 0. The calibration routine
36
 * calculates cal_cycle from CALIBRATION_DELTA.
37
 * This step can also be performed outside the demo.
38
 * Inside calibrate.h you can set the calibration parameters
39
 * for calibration step performed outside.
40
 *
41
 * cal_cycle is the number of cycles that are needed to
42
 * make CALIBRATION_DELTA number of iteration.
43
 *
44
 * kern_cli();
45
 * kern_gettime(&start);
46
 * for (i=0;i<CALIBRATION_DELTA;i++)
47
 *   __asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
48
 *                         "cpuid\n\t"
49
 *                         :::"eax","ebx","ecx","edx");
50
 * kern_gettime(&end);
51
 * kern_sti();
52
 *
53
 * SUBTIMESPEC(&end,&start,&diff);
54
 * cal_cycles = TIMESPEC2USEC(&diff);
55
 *
56
 */
57
 
1254 giacomo 58
#define generic_set_next_activation set_next_activation
1262 giacomo 59
/* Set the next activation time. It's like fsf_schedule_next_timed_job
60
 * but it don't return nothing
61
 */
62
 
1254 giacomo 63
#define generic_set_simulation_time set_simulation_time
1262 giacomo 64
/* Set the end time of simulation */
65
 
1254 giacomo 66
#define generic_get_task_model get_task_model
1262 giacomo 67
/* Return a pointer to the struct that contains the
68
 * local shceduler parameter */
69
 
1254 giacomo 70
#define generic_start_simulation start_simulation
1262 giacomo 71
/* Start the simulation */
72
 
1254 giacomo 73
#define generic_fsfinit() fsfinit()
1262 giacomo 74
/* Create the fsf_server */
75
 
1254 giacomo 76
#define generic_task_endcycle() task_endcycle()
1262 giacomo 77
/* The job is finished */
78
 
1254 giacomo 79
#define generic_end_simulation() sys_end()
1262 giacomo 80
/* Exit from simulation */
81
 
1254 giacomo 82
#define printf cprintf
1262 giacomo 83
/* Printf standard function */
1254 giacomo 84
 
1304 giacomo 85
/* Mutex */
86
extern __inline__ void generic_lock_mutex(int res) {
87
  extern mutex_t mutex_table[MAX_MUTEX];
88
 
89
  mutex_lock(&mutex_table[res]);
90
}
91
 
92
extern __inline__ void generic_unlock_mutex(int res) {
93
  extern mutex_t mutex_table[MAX_MUTEX];
94
 
95
  mutex_unlock(&mutex_table[res]);
96
}
97
 
1264 giacomo 98
/* TASK RUNTIME FUNCTIONS */
99
 
100
extern __inline__ void start_oneshot_task(void) {}
101
extern __inline__ void end_oneshot_task(void) {}
102
 
103
extern __inline__ void start_periodic_task(void) {}
1298 giacomo 104
extern __inline__ void start_job_periodic_task(void) {
105
   task_testcancel();
106
}
107
extern __inline__ void end_job_periodic_task(void) {
108
   task_testcancel();
109
}
1264 giacomo 110
extern __inline__ void end_periodic_task(void) {}
111
 
112
extern __inline__ void start_back_task(void) {}
1298 giacomo 113
extern __inline__ void start_job_back_task(void) {
114
  task_testcancel();
115
}
116
extern __inline__ void end_job_back_task(void) {
117
  task_testcancel();
118
}
1264 giacomo 119
extern __inline__ void end_back_task(void) {}
120
 
1254 giacomo 121
#endif
122
 
123