/* * Definition of the scheduler plugin interface. * */ #ifndef _LINUX_SCHED_PLUGIN_H_ #define _LINUX_SCHED_PLUGIN_H_ #include /* struct for semaphore with priority inheritance */ struct pi_semaphore { atomic_t count; int sleepers; wait_queue_head_t wait; union { /* highest-prio holder/waiter */ struct task_struct *task; struct task_struct* cpu_task[NR_CPUS]; } hp; /* current lock holder */ struct task_struct *holder; }; /* Enforce runqueues to be opaque objects. * * This allows us to pass around pointers to runqueues, * without actually having to rip it out of sched.c. It * also discourages plugins from trying to be * overly clever. */ typedef void runqueue_t; /********************* scheduler invocation ******************/ typedef enum { NO_RESCHED = 0, FORCE_RESCHED = 1 } reschedule_check_t; /* Plugin-specific realtime tick handler */ typedef reschedule_check_t (*scheduler_tick_t) (void); /* Novell make sched decision function */ typedef int (*schedule_t) (struct task_struct * prev, struct task_struct ** next, runqueue_t * rq); /* Clean up after the task switch has occured. * This function is called after every (even non-rt) task switch. */ typedef void (*finish_switch_t)(struct task_struct *prev); /********************* task state changes ********************/ /* called to setup a new real-time task */ typedef long (*prepare_task_t) (struct task_struct *task); /* called to re-introduce a task after blocking */ typedef void (*wake_up_task_t) (struct task_struct *task); /* called to notify the plugin of a blocking real-time task * it will only be called for real-time tasks and before schedule is called */ typedef void (*task_blocks_t) (struct task_struct *task); /* called when a real-time task exits. Free any allocated resources */ typedef long (*tear_down_t) (struct task_struct *); /* Called when the new_owner is released from the wait queue * it should now inherit the priority from sem, _before_ it gets readded * to any queue */ typedef long (*inherit_priority_t) (struct pi_semaphore *sem, struct task_struct *new_owner); /* Called when the current task releases a semahpore where it might have * inherited a piority from */ typedef long (*return_priority_t) (struct pi_semaphore *sem); /* Called when a task tries to acquire a semaphore and fails. Check if its * priority is higher than that of the current holder. */ typedef long (*pi_block_t) (struct pi_semaphore *sem, struct task_struct *t); /********************* sys call backends ********************/ /* This function causes the caller to sleep until the next release */ typedef long (*sleep_next_period_t) (void); typedef int (*scheduler_setup_t) (int cmd, void __user *parameter); typedef int (*mode_change_t) (int); struct sched_plugin { /* basic info */ char *plugin_name; int ready_to_use; /* management interface */ mode_change_t mode_change; /* scheduler invocation */ scheduler_tick_t scheduler_tick; schedule_t schedule; finish_switch_t finish_switch; /* syscall backend */ sleep_next_period_t sleep_next_period; scheduler_setup_t scheduler_setup; /* task state changes */ prepare_task_t prepare_task; wake_up_task_t wake_up_task; task_blocks_t task_blocks; tear_down_t tear_down; /* priority inheritance */ inherit_priority_t inherit_priority; return_priority_t return_priority; pi_block_t pi_block; } __attribute__ ((__aligned__(SMP_CACHE_BYTES))); typedef struct sched_plugin sched_plugin_t; extern sched_plugin_t *curr_sched_plugin; /* common scheduler tick */ reschedule_check_t rt_scheduler_tick(void); /* Don't pull in our definitions on top of the real ones * in sched.c! */ #ifndef __SCHED_C__ /* External linux scheduler facilities */ void deactivate_task(struct task_struct *, runqueue_t *); /* This function is defined in sched.c. We need acces to it for * indirect switching. */ void __activate_task(struct task_struct *, runqueue_t *); void __setscheduler(struct task_struct *, int, int); #endif extern int get_sched_options(void); #endif