Round Robin Module Cleaned Up
authorDaniel Röhrig <daniel.roehrig@mailbox.tu-berlin.de>
Mon, 9 Dec 2013 13:08:39 +0000 (14:08 +0100)
committerDaniel Röhrig <daniel.roehrig@mailbox.tu-berlin.de>
Mon, 9 Dec 2013 13:08:39 +0000 (14:08 +0100)
And other stuff I guess. It's been a while.

debug_qemu
framework/modules/rr_module.c

index 24951e5..fb01775 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-qemu-system-x86_64 -nographic -kernel build/arch/x86_64/boot/bzImage -s -S -append "console=ttyS0 init=/bin/busybox sh" -no-kvm
+qemu-system-x86_64 -nographic -kernel build/arch/x86_64/boot/bzImage -s -S -append "console=ttyS0 init=/bin/busybox sh" -no-kvm #-smp 2
index 6058e50..5601af1 100644 (file)
@@ -6,10 +6,8 @@
  *      Author: Rene Sechting
  */
 
-//#include "mod_sched_framework.h"
 #include <fw.h>
 #include <fw_comm.h>
-//void subscribe_to_topic(int i,void *dingens);
 
 struct rq{
        fw_list_head_t          queue;
@@ -28,25 +26,9 @@ static struct fw_task *idle;
 
 static int module_id;
 
-//static void rr_print_rq(){
-//     struct fw_list_head *pos;
-//     struct rr_info *dingens;
-//     fw_printf("rq: ");
-//     for(pos = rr_rq->queue->next;pos != rr_rq->queue;pos = pos->next){
-//             dingens = (struct rr_info *)pos;
-//             dingens->task
-//             fw_printf("task: %p |", dingens->task);
-//     }
-//     fw_print("\n");
-//}
-
 static struct fw_task *task_received(struct fw_task *task)
 {
        struct rr_info *rq_ele;
-//     if(system_state == SYSTEM_RUNNING)
-//             fw_printf("new task %d\n", fw_get_pid(task));
-//     rq_ele = (struct rr_info*)((unsigned long)task+offset);
-//     fw_list_add_tail(&rq_ele->head, &rr_rq->queue);
 
        rq_ele = (struct rr_info *)fw_malloc(sizeof(struct rr_info));
        task->module_data[module_id] = (void *)rq_ele;
@@ -62,10 +44,7 @@ static struct fw_task *task_finished(struct fw_task *finished)
 {
        struct rr_info *next_elem;
        struct fw_task *task;
-//     fw_printf("task finished %d\n",fw_get_pid(finished));
 
-//     next_elem = (struct rr_info *)((unsigned long)finished+offset);
-//     next_elem->on_rq = 0;
        if(!fw_list_empty(&rr_rq->queue)){
                //get the next task running!
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
@@ -85,20 +64,14 @@ static struct fw_task *tick_received(struct fw_task *preempted)
 {
        struct fw_task *task;
        struct rr_info *next_elem;
-//     if(system_state == SYSTEM_RUNNING)
-//             fw_printf(".");
-
-//     rr_print_rq();
 
        if(fw_list_empty(&rr_rq->queue)){
-//             fw_printf("kein kontextwechsel\n");
                fw_dispatch(preempted);
                return NULL;
        }
 
        if((preempted == idle)){
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
-//             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
                fw_dispatch(task);
@@ -106,13 +79,9 @@ static struct fw_task *tick_received(struct fw_task *preempted)
        }else{
                //insert curr task to queue
                next_elem = (struct rr_info*)preempted->module_data[module_id];
-//                     next_elem = (struct rr_info*)((unsigned long)task+offset);
                fw_list_add_tail(&next_elem->head,&rr_rq->queue);
                next_elem->on_rq = 1;
-               //get the new task out of da queue and schedule the hell out of it
-//             next_elem = NULL;
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
-//             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                next_elem->on_rq = 0;
                rr_rq->curr = task;
@@ -127,19 +96,13 @@ static struct fw_task *tick_received(struct fw_task *preempted)
 static struct fw_task *task_yielded(struct fw_task *yielded)
 {
 
-//     fw_printf("yield-state: %d",fw_get_state(yielded));
        struct rr_info *next_elem;
-//     struct rr_info *pos;
        struct fw_task *task;
-//     fw_printf("task has yielded %d\n",fw_get_pid(yielded));
-//     next_elem = (struct rr_info *) ((unsigned long)yielded + offset);
        next_elem = (struct rr_info*)yielded->module_data[module_id];
        next_elem->on_rq = 0;
-//     next_elem = NULL;
        if(!fw_list_empty(&rr_rq->queue)){
                next_elem = (struct rr_info *)__fw_list_pop(&(rr_rq->queue));
                next_elem->on_rq = 0;
-//             task = (struct fw_task*)((unsigned long)next_elem-offset);
                task = next_elem->task;
                rr_rq->curr = task;
                fw_dispatch(task);
@@ -153,9 +116,6 @@ static struct fw_task *task_yielded(struct fw_task *yielded)
 
 static struct fw_task *wake_up_task(struct fw_task *wake_up)
 {
-//     if(system_state == SYSTEM_RUNNING)
-//             fw_printf("aufwachen!!! %d\n",fw_get_pid(wake_up));
-//     struct rr_info *to_wake_up = (struct rr_info*)((unsigned long)wake_up+offset);
        struct rr_info *to_wake_up = (struct rr_info*)wake_up->module_data[module_id];
        if(!to_wake_up->on_rq){
                fw_list_add_tail(&to_wake_up->head,&(rr_rq->queue));
@@ -164,7 +124,6 @@ static struct fw_task *wake_up_task(struct fw_task *wake_up)
        return NULL;
 }
 
-//__init_module(init_sched_rr_module)
 int init_sched_rr_module(void)
 {
        fw_printf("ROUND_ROBIN_MODULE INITIALIZING\n");
@@ -176,17 +135,10 @@ int init_sched_rr_module(void)
        rr_rq->idle = idle;
        rr_rq->curr = idle;
        FW_LIST_INIT(rr_rq->queue);
-//     subscribe_to_topic(1, &task_received);
        fw_subscribe(ADMIT, &task_received);
-//     subscribe_to_topic(2, &task_finished);
        fw_subscribe(RELEASE, &task_finished);
-       //subscribe_to_topic(3, &tick_received);
        fw_subscribe(TIME_OUT, &tick_received);
-       //subscribe_to_topic(4, &task_yielded);
        fw_subscribe(EVENT_WAIT, &task_yielded);
-       //subscribe_to_topic(0, &wake_up_task);
        fw_subscribe(EVENT_OCCURS, &wake_up_task);
-       fw_printf("SCHEDULER INITIALIZED!\n");
-
        return 0;
 }