To switch between schedules during runtime, the user must create a Schedule Manager which resides in a single OS process and links to the shared library libstm_runtime.so. During system initialization, only one process can call stmScheduleManagerInit(). The Schedule Manager controls which schedule is executed at a certain point of time. It uses two APIs (present in stm_manager.h
) to control the execution of the schedule:
To exit gracefully, the process calling stmScheduleManagerInit() can call stmScheduleManagerExit(). For example, the application's SIGINT or SIGTERM handler can call stmScheduleManagerExit() to gracefully exit.
STM implements a synchronized schedule switch as depicted in the figure below. Upon receiving a request for stopping the current schedule, each hyperepoch finishes executing its current frame and does not start the execution of the next frame. Schedule execution comes to a halt after all the hyperepochs stop. After that, based on the input from the STM Schedule Manager, execution can restart with a different schedule.
STM implements a rollover schedule switch as depicted in the figure below. Upon receiving a request to rollover from schedule A to B, each hyperepoch in schedule A finishes executing its current frame. As soon as a hyperepoch in schedule A finishes its current frame, the corresponding hyperepoch in schedule B begins execution. This allows individual hyperepochs to switch to a new schedule without having to wait for all hyperepochs in the current schedule to finish first like in complete swap. This feature is restricted to schedule pairs that have the same number of hyperepochs and same resource partitions across hyperepochs. A callback function can be registered per client during init time using the API found in stm.h. The callback gets executed per hyperepoch right before schedule B begins exeuction and is typically used for any setup tasks needed during the switch. The stmRollOverSchedule API returns after all hyperepochs have switched to the new schedule. After that, based on the input from the STM Schedule Manager, execution can roll over to a different schedule or stop then start again.