#include <oskit/threads/pthread.h>
#include <oskit/threads/cpuinherit.h>int create_ratemono_scheduler(pthread_t *tid, const pthread_attr_t *attr, int preemptible);
Create a new Rate Monotonic scheduler. The pthread_t of the new scheduler is returned in tid. The attributes structure to use when creating the new thread is attr. The preemptible flag indicates whether the new scheduler should use time-based preemption to achieve fairness. Aside from the usual attributes that can be specified, the caller may also specify the new scheduler's scheduler by using pthread_attr_setscheduler. Thus, the caller can set up an arbitrary hierarchy of schedulers and threads.When creating threads that are scheduled by a Rate Monotonic scheduler, the caller should set the opaque scheduling parameter in the thread creation attributes structure. This opaque value represents a period, and is used to create the ordered scheduling list. It should be an integer (usually a small to moderately sized integer).
Note that this rate monotonic scheduler is extremely simplified, and should be considered strictly as an example of how to write a scheduler; it does not implement a proper Rate Monotonic scheduling policy.
- tid
- A pointer to the location where the thread id of the new scheduler should be stored.
- attr
- A pointer to the thread creation attributes object.
- preemptible
- A flag indicating whether the new scheduler should use time-based preemption.
Returns 0 on success, or an error code specified in <oskit/error.h>, on error.