schedutil
schedutil - various routines that work with OS scheduler
Functions
sched_get_cpuid
publicplat
Returns cpuid of current thread
LIBEXPORT PLATAPI int sched_get_cpuid(void)
sched_switch
publicplat
Yield CPU to another thread
LIBEXPORT PLATAPI int sched_switch(void)
sched_get_affinity, sched_set_affinity
publicplat
LIBEXPORT PLATAPI int sched_set_affinity(thread_t* thread , cpumask_t* mask) LIBEXPORT PLATAPI int sched_get_affinity(thread_t* thread , cpumask_t* mask)
sched_policy_find_byname, sched_policy_find_byid
public
LIBEXPORT sched_policy_t* sched_policy_find_byname(const char* name) LIBEXPORT sched_policy_t* sched_policy_find_byid(int id)
sched_get_policies
publicplat
Returns array of available scheduler policies on current system
NULL is a mark for end of array
LIBEXPORT PLATAPI sched_policy_t** sched_get_policies()
sched_set_policy
publicplat
Sets policy of a thread, but doesn't call operating system until you
call sched_commit. This is because some OSes (like Linux) need to set
policy and param simultaneously, and others (like Solaris) may have multiple
params to set.
RETURN VALUES
SCHED_INVALID_POLICY if name is invalid or SCHED_OK if everything went fine.
LIBEXPORT PLATAPI int sched_set_policy(thread_t* thread, const char* name)
sched_set_param
publicplat
Sets scheduler parameter
RETURN VALUES
SCHED_INVALID_PARAM if name is invalid, SCHED_INVALID_POLICY if policy is not yet set and SCHED_OK if everything went fine.
NOTES
if this function fails, you should start again from sched_set_policy
LIBEXPORT PLATAPI int sched_set_param(thread_t* thread, const char* name, int64_t value)
sched_commit
publicplat
Calls operating system to commit changes made by sched_set_policy() and sched_set_param()
RETURN VALUES
SCHED_ERROR in case of system error, SCHED_INVALID_PARAM/SCHED_INVALID_POLICY if thread was not properly initialized, SCHED_NOT_PERMITTED if you do not have permissions to alter scheduling policy.
LIBEXPORT PLATAPI int sched_commit(thread_t* thread)
sched_get_param, sched_get_policy
publicplat
LIBEXPORT PLATAPI int sched_get_param(thread_t* thread, const char* name, int64_t* value) LIBEXPORT PLATAPI int sched_get_policy(thread_t* thread, char* name, size_t len)
sched_init, sched_fini
publicplat
LIBEXPORT PLATAPI int sched_init(void) LIBEXPORT PLATAPI void sched_fini(void)
Types
sched_param_t
typedef struct { const char* name; int min; int max; } sched_param_t;
sched_policy_t
typedef struct { const char* name; sched_param_t* params; int id; void* private; } sched_policy_t;