Lab 1 API
We have listed the most important functions and data structures which you will use in Lab 1 below. All the functions you need to use in Lab 1 are located in scheduler.h and scheduler.c.
- scheduler_t - is an alias for struct s_SCHEDULER_STRUCT which has the following fields:
- minor (unsigned int) - This controls the maximum wait time of the "scheduler_wait_for_timer" function. It can be thought of as the length of the minor cycle in a cyclic schedule.
- tv_started (struct timeval) - Used internally by the scheduler, you do not need to modify this field.
- tv_cycle (struct timeval) - Used internally by the scheduler, you do not need to modify this field.
- void scheduler_run (scheduler_t *ces)
This function is empty and should be implemented by you. The parameter "ces" is a pointer to a scheduler_t struct which you will need when calling the functions below.
- void scheduler_start (scheduler_t *ces)
This function starts the scheduler. You should invoke it just once before starting task execution.
- void scheduler_wait_for_timer (scheduler_t *ces)
This function waits until the timer has reached the time specified in scheduler data structure element "ces->minor".
- void scheduler_exec_task (scheduler_t *ces, int task_id)
This function executes the specified task. The function will return only when execution of the task has ended. The parameter "task_id" corresponds to the ID of the task to run (these are defined in the file task.h).
In addition to the functions provided in the lab skeleton you will also need to make use of basic C library functions for clocks and timers to measure execution time.
Page responsible: Simin Nadjm-Tehrani
Last updated: 2017-10-23