ckrm_lrq_t *queue;
int idx;
int cpu = smp_processor_id();
-
- next = rq->idle;
+
+ // it is guaranteed be the ( rq->nr_running > 0 ) check in
+ // schedule that a task will be found.
+
retry_next_class:
- if ((queue = rq_get_next_class(rq))) {
- //check switch active/expired queue
- array = queue->active;
- if (unlikely(!array->nr_active)) {
- queue->active = queue->expired;
- queue->expired = array;
- queue->expired_timestamp = 0;
-
- if (queue->active->nr_active)
- set_top_priority(queue,
- find_first_bit(queue->active->bitmap, MAX_PRIO));
- else {
- classqueue_dequeue(queue->classqueue,
- &queue->classqueue_linkobj);
- cpu_demand_event(get_rq_local_stat(queue,cpu),CPU_DEMAND_DEQUEUE,0);
- }
- goto retry_next_class;
- }
- BUG_ON(!array->nr_active);
+ queue = rq_get_next_class(rq);
+ // BUG_ON( !queue );
- idx = queue->top_priority;
- if (queue->top_priority == MAX_PRIO) {
- BUG_ON(1);
- }
+ array = queue->active;
+ if (unlikely(!array->nr_active)) {
+ queue->active = queue->expired;
+ queue->expired = array;
+ queue->expired_timestamp = 0;
- next = task_list_entry(array->queue[idx].next);
+ if (queue->active->nr_active)
+ set_top_priority(queue,
+ find_first_bit(queue->active->bitmap, MAX_PRIO));
+ else {
+ classqueue_dequeue(queue->classqueue,
+ &queue->classqueue_linkobj);
+ cpu_demand_event(get_rq_local_stat(queue,cpu),CPU_DEMAND_DEQUEUE,0);
+ }
+ goto retry_next_class;
}
+ // BUG_ON(!array->nr_active);
+
+ idx = queue->top_priority;
+ // BUG_ON (idx == MAX_PRIO);
+ next = task_list_entry(array->queue[idx].next);
return next;
}
#else /*! CONFIG_CKRM_CPU_SCHEDULE*/
rq->expired = array;
array = rq->active;
rq->expired_timestamp = 0;
+ rq->best_expired_prio = MAX_PRIO;
}
idx = sched_find_first_bit(array->bitmap);
*/
static void dequeue_task(struct task_struct *p, prio_array_t *array)
{
- BUG_ON(! array);
array->nr_active--;
list_del(&p->run_list);
if (list_empty(array->queue + p->prio))
return 0;
}
-DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
+DEFINE_PER_CPU(struct kernel_stat, kstat);
EXPORT_PER_CPU_SYMBOL(kstat);
/*
cpu = smp_processor_id();
if (unlikely(!rq->nr_running)) {
idle_balance(cpu, rq);
+ if (!rq->nr_running) {
+ next = rq->idle;
+#ifdef CONFIG_CKRM_CPU_SCHEDULE
+ rq->expired_timestamp = 0;
+#endif
+ wake_sleeping_dependent(cpu, rq);
+ goto switch_tasks;
+ }
}
next = rq_get_next_task(rq);
- if (next == rq->idle) {
- rq->expired_timestamp = 0;
- wake_sleeping_dependent(cpu, rq);
- goto switch_tasks;
- }
if (dependent_sleeper(cpu, rq, next)) {
next = rq->idle;
rq->idle = current;
set_task_cpu(current, smp_processor_id());
#ifdef CONFIG_CKRM_CPU_SCHEDULE
+ cpu_demand_event(&(current)->demand_stat,CPU_DEMAND_INIT,0);
current->cpu_class = get_default_cpu_class();
current->array = NULL;
#endif