● LOW_TIMER.C contains timer enable/disable/pause functions and Unix timer implementation. The following are the Unix-destined routines and data:
●
Signal mask sets (the alarm_set and the pause_set).
●
The pointer to the SIGALARM signal handler routine (the timer_handler).
●
start_time variable to save the time shift for model time calculation.
●
handler() of the SIGALARM signal.
●
OS_timer_set() sets the new interval timer according the closest started time-out event.
●
OS_timer_reset() initializes the interval timer by zero value.
●
OS_timer_init() sets SIGALARM signal handler.
●
OS_timer_pause() suspends the main program until delivery of a SIGALARM signal.
●
OS_timer_disable() calls the function that blocks SIGALARM and, as a result, timeout events cannot happen.
●
OS_timer_enable() calls the function that unblocks SIGALARM.
●
OS_timer_get_time() returns current model time value.
● VXTIMER.C contains VxWorks timer implementation. All of its routines and data items are VxWorks-dependent.
● DOSTIMER.C contains Windows timer implementation. All of its routines and data items are Windows-dependent.
These files (vxtimer.c and dostimer.c) should not be touched and may be used as a pattern.
● SCHEDULER.H contains the task_entry data structure, which depends on the target OS. This data structure contains the target dependent fields for every OS and the same savearea field but with the different length. Declare this field correctly and define (if it is needed) some additional OS-specific fields. The RTL part of this file is located under the “#ifdef prt” definition.
● CONTEXT_SWITCH.C implements context switching between different threads. This operation is completely OS-dependent, so it should be rewritten for each new target OS.
● SCHEDULER.C supports initialization and execution of the tasks. The OS–dependent parts are the task_entry data structure initialization and context switching implementation. In addition, there are some task manipulation functions. They use target OS services and should be changed when porting to a new target OS. The following routines should be changed for the porting purpose:
●
Init_task_entry() initiates the task_entry data structure.
●
sched_init() initiates the main task and a set of the pointers for the using by other libraries.
● stack_overflow() checks the status of the task.
● scheduler() controls context_switching between the tasks.
● create_task() allocates the new task_entry data structure and initiates it
● terminate_tasks() (currently it exists for VxWorks only).
● create_VxWorks_task() (for VxWorks only).