changes in core.c to make linux run with framework
authorRené Sechting <sechting@mailbox.tu-berlin.de>
Thu, 2 Jan 2014 11:25:05 +0000 (12:25 +0100)
committerRené Sechting <sechting@mailbox.tu-berlin.de>
Thu, 2 Jan 2014 11:25:05 +0000 (12:25 +0100)
in __schedule a dirty hack function fw_get_decision() is used to get the next
task to schedule. It works flawless, but is not the desired design for the
framework - kernel interaction. But it works! ;)

kernel/sched/modsched/core.c

index 21a90cc..8c5ebe2 100644 (file)
@@ -310,8 +310,7 @@ void sched_init(void)
 
        //TODO: FRAMEORK
        fw_init();
-
-
+       wake_up_new_task(current);
        scheduler_running = 1;
 }
 
@@ -1329,10 +1328,13 @@ void wake_up_new_task(struct task_struct *p)
 {
        unsigned long flags;
        struct rq *rq;
+       struct fw_task *fw_task;
 //     int cpu = 255;
 
 //     TODO: FRAMEWORK ZEUGS
-       fw_notify(FW_ADMIT,&p->fw_task);
+       fw_task = &(p->fw_task);
+       fw_task->real_task = p;
+       fw_notify(FW_ADMIT,fw_task);
 
        raw_spin_lock_irqsave(&p->pi_lock, flags);
 
@@ -1459,18 +1461,17 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
        }
 #endif /* CONFIG_SMP */
 
-
-
        ttwu_queue(p, cpu);
 stat:
 //     raw_spin_unlock(&rq->lock);
 out:
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
-//TODO: FRAMEWORK
-//send_to_topic(0,p);
+//     TODO:framework zeugs
+//     fw_notify(FW_EVENT_OCCURS,&p->fw_task);
 
        return success;
+//     return 1;
 }
 
 /**
@@ -1608,6 +1609,8 @@ context_switch(struct rq *rq, struct task_struct *prev,
  *          - return from syscall or exception to user-space
  *          - return from interrupt-handler to user-space
  */
+extern void *fw_get_decision(void);
+
 static void __sched __schedule(void)
 {
        struct task_struct *prev, *next;
@@ -1645,41 +1648,46 @@ need_resched:
                }
        }
 
-
-       if(prev->state && !(preempt_count() & PREEMPT_ACTIVE)){
+       if(prev->state == TASK_DEAD){
+//             if(prev->pid > 355)
+//                     printk("DEAD %d\n",prev->pid);
+               fw_notify(FW_RELEASE,&prev->fw_task);
+       }else if(prev->state && !(preempt_count() & PREEMPT_ACTIVE)){
                //yield
+//             printk(">>yield task %d\n",prev->pid);
                fw_notify(FW_EVENT_WAIT,&prev->fw_task);
        }
        fw_notify(FW_DISPATCH, NULL);
 
-//     if(next)
-//             next->se.exec_start = rq->clock_task;
-//
-//     clear_tsk_need_resched(prev);
-//     rq->skip_clock_update = 0;
-//
-//     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
-//             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.
-//              */
-//             cpu = smp_processor_id();
-//             rq = cpu_rq(cpu);
-//     }
-//     else
-//             raw_spin_unlock_irq(&rq->lock);
+       next = (struct task_struct*)fw_get_decision();
+       if(next)
+               next->se.exec_start = rq->clock_task;
+
+       clear_tsk_need_resched(prev);
+       rq->skip_clock_update = 0;
+
+       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
+               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.
+                */
+               cpu = smp_processor_id();
+               rq = cpu_rq(cpu);
+       }
+       else
+               raw_spin_unlock_irq(&rq->lock);
 //
 //     post_schedule(rq);