/* * 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; }; /********************* scheduler invocation ******************/ /* Plugin-specific realtime tick handler */ typedef void (*scheduler_tick_t) (void); /* Novell make sched decision function */ typedef int (*schedule_t) (struct task_struct * prev, struct task_struct ** next); /* 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); struct sched_plugin { struct list_head list; /* basic info */ char *plugin_name; /* scheduler invocation */ scheduler_tick_t scheduler_tick; schedule_t schedule; finish_switch_t finish_switch; /* syscall backend */ sleep_next_period_t sleep_next_period; /* 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))); extern struct sched_plugin *curr_sched_plugin; int register_sched_plugin(struct sched_plugin* plugin); struct sched_plugin* find_sched_plugin(const char* name); int print_sched_plugins(char* buf, int max); #endif