context_switch invoked by framework
authorRené Sechting <sechting@mailbox.tu-berlin.de>
Mon, 11 Nov 2013 14:59:47 +0000 (15:59 +0100)
committerRené Sechting <sechting@mailbox.tu-berlin.de>
Mon, 11 Nov 2013 14:59:47 +0000 (15:59 +0100)
fw_dispatch(next) is now invoking the context_switch.

framework/modules/rr_module.c
framework/os/linux/os.c
kernel/sched.new/core.c

index eaa820d..cd0e29f 100644 (file)
@@ -60,10 +60,12 @@ static struct fw_task *task_finished(struct fw_task *finished)
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
                task = (struct fw_task*)((unsigned long)next_elem-offset);
                rr_rq->curr = task;
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
                task = (struct fw_task*)((unsigned long)next_elem-offset);
                rr_rq->curr = task;
+               fw_dispatch(task);
                return task;
        }else{
                //every task is done, go to idle mode
                rr_rq->curr = idle;
                return task;
        }else{
                //every task is done, go to idle mode
                rr_rq->curr = idle;
+               fw_dispatch(idle);
                return idle;
        }
 }
                return idle;
        }
 }
@@ -82,6 +84,7 @@ static struct fw_task *tick_received(void)
 //             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
 //             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
+               fw_dispatch(task);
                return task;
        }else if(!fw_list_empty(&rr_rq->queue)){
                if(task!=idle){
                return task;
        }else if(!fw_list_empty(&rr_rq->queue)){
                if(task!=idle){
@@ -98,8 +101,11 @@ static struct fw_task *tick_received(void)
                task = next_elem->task;
                next_elem->on_rq = 0;
                rr_rq->curr = task;
                task = next_elem->task;
                next_elem->on_rq = 0;
                rr_rq->curr = task;
+               fw_dispatch(task);
                return task;
        }
                return task;
        }
+       rr_rq->curr = idle;
+       fw_dispatch(idle);
        return idle;
 }
 
        return idle;
 }
 
@@ -121,9 +127,11 @@ static struct fw_task *task_yielded(struct fw_task *yielded)
 //             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
 //             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
+               fw_dispatch(task);
                return task;
        }else{
                rr_rq->curr = idle;
                return task;
        }else{
                rr_rq->curr = idle;
+               fw_dispatch(idle);
                return idle;
        }
 }
                return idle;
        }
 }
index 2158b5e..70d6261 100644 (file)
@@ -11,6 +11,7 @@
 #include <fw_types.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <fw_types.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include "sched.h"
 
 extern struct fw_task *fw_idle_task;
 
 
 extern struct fw_task *fw_idle_task;
 
@@ -38,9 +39,28 @@ void os_create_task(fw_task_t *task)
        return;
 }
 
        return;
 }
 
+//static inline void
+//context_switch(struct rq *rq, struct task_struct *prev,
+//            struct task_struct *next);
+extern void context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next);
 void os_dispatch(fw_task_t *task)
 {
 void os_dispatch(fw_task_t *task)
 {
-       return;
+       struct rq *rq;
+       int cpu;
+       struct task_struct *prev, *next;
+
+       cpu = smp_processor_id();
+       rq = cpu_rq(cpu);
+       prev = rq->curr;
+       next = (struct task_struct*)task->real_task;
+
+       next->se.exec_start = rq->clock_task;
+//     clear_tsk_need_resched(prev);
+//     rq->skip_clock_update = 0;
+       rq->nr_switches++;
+       rq->curr = next;
+       context_switch(rq,prev,next);
+//     arch_local_irq_enable();
 }
 
 void os_dispatch_mp(fw_task_t *task, int cpu)
 }
 
 void os_dispatch_mp(fw_task_t *task, int cpu)
index 987ccf4..d82bc49 100644 (file)
@@ -1517,7 +1517,8 @@ out:
  * context_switch - switch to the new MM and the new
  * thread's register state.
  */
  * context_switch - switch to the new MM and the new
  * thread's register state.
  */
-static inline void
+//static inline void
+void
 context_switch(struct rq *rq, struct task_struct *prev,
               struct task_struct *next)
 {
 context_switch(struct rq *rq, struct task_struct *prev,
               struct task_struct *next)
 {
@@ -1691,29 +1692,30 @@ need_resched:
 //             next = rq->idle;
        }
 */
 //             next = rq->idle;
        }
 */
-       if(next)
-               next->se.exec_start = rq->clock_task;
 
 
+//     if(next)
+//             next->se.exec_start = rq->clock_task;
+//
        clear_tsk_need_resched(prev);
        rq->skip_clock_update = 0;
        clear_tsk_need_resched(prev);
        rq->skip_clock_update = 0;
-
+//
        if (likely(prev != next)&&(next!=NULL)) {
        if (likely(prev != next)&&(next!=NULL)) {
-               rq->nr_switches++;
-               rq->curr = next;
-//             ++*switch_count;
-
-//             printk("wechsel! PID: %d | CPU :%d | allows: %d\n",next->pid, cpu, next->cpus_allowed);
-               context_switch(rq, prev, next); /* unlocks the rq */
-
-               // TODO: remove irq enable
+//             rq->nr_switches++;
+//             rq->curr = next;
+////           ++*switch_count;
+//
+////           printk("wechsel! PID: %d | CPU :%d | allows: %d\n",next->pid, cpu, next->cpus_allowed);
+//             context_switch(rq, prev, next); /* unlocks the rq */
+//
+//             // TODO: remove irq enable
                arch_local_irq_enable();
                arch_local_irq_enable();
-
-               /*
-                * The context switch have flipped the stack from under us
-                * and restored the local variables which were saved when
-                * this task called schedule() in the past. prev == current
-                * is still correct, but it can be moved to another cpu/rq.
-                */
+//
+//             /*
+//              * The context switch have flipped the stack from under us
+//              * and restored the local variables which were saved when
+//              * this task called schedule() in the past. prev == current
+//              * is still correct, but it can be moved to another cpu/rq.
+//              */
                cpu = smp_processor_id();
                rq = cpu_rq(cpu);
        }
                cpu = smp_processor_id();
                rq = cpu_rq(cpu);
        }