예제 #1
0
파일: gt_pq.c 프로젝트: jedivind/gtthreads
extern uthread_struct_t *sched_find_best_uthread(kthread_runqueue_t *kthread_runq)
{
	/* [1] Tries to find the highest priority RUNNABLE uthread in active-runq.
	 * [2] Found - Jump to [FOUND]
	 * [3] Switches runqueues (active/expires)
	 * [4] Repeat [1] through [2]
	 * [NOT FOUND] Return NULL(no more jobs)
	 * [FOUND] Remove uthread from pq and return it. */

	rbtree rbrunq = kthread_runq->cfs_rq;
	rbtree_node node = find_leftmost(rbrunq);
	
	uthread_struct_t *u_obj;
	gt_spin_lock(&(kthread_runq->kthread_runqlock));
	kthread_runq->kthread_runqlock.holder = 0x04;



	if(rbrunq->nr_running == 0 || !node){ //If there are no more nodes to schedule, return NULL.
	gt_spin_unlock(&(kthread_runq->kthread_runqlock));
	return NULL;
	}

	u_obj = (uthread_struct_t *) node->value; //Else get the uthread in the leftmost node.
	update_min_vruntime(kthread_runq, u_obj->vruntime); //Set the min_vruntime of the runqueue to this uthread's vruntime.
	__rem_from_cfs_runqueue(rbrunq,u_obj); //Remove the object from the CFS tree.
	gt_spin_unlock(&(kthread_runq->kthread_runqlock));
	return u_obj; //Return the leftmost node.
#if 0
	printf("cpu(%d) : sched best uthread(id:%d, group:%d)\n", u_obj->cpu_id, u_obj->uthread_tid, u_obj->uthread_gid);
#endif
}
예제 #2
0
/*
 * Update the current task's runtime statistics. Skip current tasks that
 * are not in our scheduling class.
 */
static inline void
__update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,
	      unsigned long delta_exec)
{
	unsigned long delta_exec_weighted;

	schedstat_set(curr->exec_max, max((u64)delta_exec, curr->exec_max));

	curr->sum_exec_runtime += delta_exec;
	schedstat_add(cfs_rq, exec_clock, delta_exec);
	delta_exec_weighted = calc_delta_fair(delta_exec, curr);
	curr->vruntime += delta_exec_weighted;
	update_min_vruntime(cfs_rq);
}
예제 #3
0
static void
dequeue_entity_hw(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
	/*
	 * Update run-time statistics of the 'current'.
	 */
	update_hw(cfs_rq, cfs_rq->curr);

	update_stats_dequeue_hw(cfs_rq, se);

	if (se != cfs_rq->curr)
		__dequeue_entity(cfs_rq, se);
	account_entity_dequeue_hw(cfs_rq, se);
	update_min_vruntime(cfs_rq);
}