ckrm_E16rc1 cpu controller version 9.1
authorMarc Fiuczynski <mef@cs.princeton.edu>
Sun, 17 Oct 2004 11:25:07 +0000 (11:25 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Sun, 17 Oct 2004 11:25:07 +0000 (11:25 +0000)
kernel/sched.c

index 85fb705..743e5bc 100644 (file)
@@ -337,36 +337,35 @@ static inline struct task_struct * rq_get_next_task(struct runqueue* rq)
        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*/
@@ -385,6 +384,7 @@ static inline struct task_struct * rq_get_next_task(struct runqueue* rq)
                rq->expired = array;
                array = rq->active;
                rq->expired_timestamp = 0;
+               rq->best_expired_prio = MAX_PRIO;
        }
 
        idx = sched_find_first_bit(array->bitmap);
@@ -404,7 +404,6 @@ static inline void ckrm_sched_tick(int j,int this_cpu,void* name) {}
  */
 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))
@@ -2507,7 +2506,7 @@ static inline int wake_priority_sleeper(runqueue_t *rq)
        return 0;
 }
 
-DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
+DEFINE_PER_CPU(struct kernel_stat, kstat);
 EXPORT_PER_CPU_SYMBOL(kstat);
 
 /*
@@ -2824,14 +2823,17 @@ need_resched:
        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;
@@ -4556,6 +4558,7 @@ void __init sched_init(void)
        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