1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #if !defined(SIM_TIMER_H_)
40 # define SIM_TIMER_H_ 0
41
42 # include <time.h>
43 # include <sys/types.h>
44 # include <unistd.h>
45 # include <pthread.h>
46
47 # define SIM_NTIMERS 8
48 # define SIM_TMAX 500
49 # define SIM_INITIAL_IPS 500000
50
51 # if !defined(PRIORITY_BELOW_NORMAL)
52 # define PRIORITY_BELOW_NORMAL -1
53 # endif
54 # if !defined(PRIORITY_NORMAL)
55 # define PRIORITY_NORMAL 0
56 # endif
57 # if !defined(PRIORITY_ABOVE_NORMAL)
58 # define PRIORITY_ABOVE_NORMAL 1
59 # endif
60
61 t_bool sim_timer_init (void);
62 void sim_timespec_diff (struct timespec *diff, const struct timespec *min, struct timespec *sub);
63 int32 sim_rtcn_init (int32 time, int32 tmr);
64 int32 sim_rtcn_init_unit (UNIT *uptr, int32 time, int32 tmr);
65 int sim_usleep(useconds_t tusleep);
66 void sim_rtcn_init_all (void);
67 int32 sim_rtcn_calb (uint32 ticksper, int32 tmr);
68 t_stat sim_show_timers (FILE* st, DEVICE *dptr, UNIT* uptr, int32 val, CONST char* desc);
69 t_stat sim_show_clock_queues (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
70 uint32 sim_os_msec (void);
71 void sim_os_sleep (unsigned int sec);
72 uint32 sim_os_ms_sleep (unsigned int msec);
73 uint32 sim_os_ms_sleep_init (void);
74 void sim_start_timer_services (void);
75 void sim_stop_timer_services (void);
76 t_stat sim_timer_change_asynch (void);
77 t_stat sim_timer_activate (UNIT *uptr, int32 interval);
78 t_stat sim_timer_activate_after (UNIT *uptr, uint32 usec_delay);
79 int32 sim_timer_activate_time (UNIT *uptr);
80 t_stat sim_register_clock_unit_tmr (UNIT *uptr, int32 tmr);
81 double sim_timer_inst_per_sec (void);
82 t_stat sim_os_set_thread_priority (int below_normal_above);
83 extern t_bool sim_asynch_timer;
84 extern DEVICE sim_timer_dev;
85 extern UNIT * volatile sim_clock_cosched_queue[SIM_NTIMERS+1];
86 extern const t_bool rtc_avail;
87 #endif