#ifndef _VX_SCHED_H #define _VX_SCHED_H #define VAVAVOOM_RATIO 50 /* scheduling stuff */ int tokens_left(struct task_struct *); int tokens_recalc(struct task_struct *); /* update the token allocation for a process */ static inline void tokens_alloc(struct task_struct *tsk) { if (tsk->vx_info && (tsk->vx_info->vx_flags & VX_INFO_SCHED)) { spin_lock(&tsk->vx_info->sched.tokens_lock); tokens_recalc(tsk); /* else if (eat && tsk->s_info->tokens > 0) { tsk->s_info->tokens--; } */ spin_unlock(&tsk->vx_info->sched.tokens_lock); } } /* eat a token, only allocating more if we run out. Return: 1 if a token was eaten, 0 if the process has no tokens left -1 if tokens do not apply */ static inline int eat_token(struct task_struct *tsk) { int eaten = -1; if (tsk->vx_info && (tsk->vx_info->vx_flags & VX_INFO_SCHED)) { spin_lock(&tsk->vx_info->sched.tokens_lock); if (tsk->vx_info->sched.tokens || tokens_recalc(tsk)) { tsk->vx_info->sched.tokens--; eaten = 1; } else { eaten = 0; } spin_unlock(&tsk->vx_info->sched.tokens_lock); } return eaten; } #endif