Deleted PubSub
authorDaniel Röhrig <daniel.roehrig@mailbox.tu-berlin.de>
Fri, 22 Nov 2013 15:07:02 +0000 (16:07 +0100)
committerDaniel Röhrig <daniel.roehrig@mailbox.tu-berlin.de>
Fri, 22 Nov 2013 15:07:02 +0000 (16:07 +0100)
And changed the makefile and stuff.

framework/Makefile
framework/fw.c
framework/os/linux/os.c
framework/pub_sub.c [deleted file]
framework/pub_sub.h [deleted file]
kernel/sched.new/core.c

index 6f0265a..dfc4626 100644 (file)
@@ -1,5 +1,5 @@
 MOD_SCHED_DIR?=$(PWD)
-OBJ=$(MOD_SCHED_DIR)/pub_sub.o $(MOD_SCHED_DIR)/fw_task.o $(MOD_SCHED_DIR)/modules/rr_module.o 
+OBJ= $(MOD_SCHED_DIR)/fw_task.o $(MOD_SCHED_DIR)/modules/rr_module.o 
 OBJ += $(MOD_SCHED_DIR)/fw_list.o $(MOD_SCHED_DIR)/fw.o $(MOD_SCHED_DIR)/fw_comm.o $(MOD_SCHED_DIR)/fw_modules.o
 LINUX_DIR?=$(PWD)/../
 
index 02b22b7..03319e9 100644 (file)
@@ -46,7 +46,6 @@ void fw_init()
        fw_module_count = 0;
 
        os_init_os();
-       init_sched_pub_sub();
 
        fw_init_comm();
        fw_modules_init();
index 5488b57..2780dbf 100644 (file)
@@ -69,9 +69,7 @@ void os_dispatch(fw_task_t *task)
 int os_init_os(void)
 {
        struct task_struct* ptr = current;
-       //fw_idle_task = register_task(ptr);
        fw_idle_task = (struct fw_task *)fw_malloc(sizeof(struct fw_task));
-       //insert_fw_task(new_task, real_task);
        ptr->fw_task = fw_idle_task;
        fw_idle_task->real_task = ptr;
        return 0;
diff --git a/framework/pub_sub.c b/framework/pub_sub.c
deleted file mode 100644 (file)
index 16385a6..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * pub_sub.c
- *
- * Initializes a simple Publish/Subscribe mechanism
- * for the Scheduler Framework.
- *
- * Topics are identified by positive integers that are mapped
- * to an array and cannot have gaps between them. The amount
- * of topics is defined in the preprocessor directive TOPICS.
- *
- * Messages are limited to being just plain strings.
- *
- *
- *  Created on: 14.06.2013
- *      Author: Daniel Roehrig, Christian Rene Sechting
- */
-#include <pub_sub.h>
-#include <fw_types.h>
-#include <fw.h>
-#include <fw_list.h>
-
-#define TOPICS 5//Number of Topics
-
-topic_list topic_arr[TOPICS];//May be confused with topic_t
-int initialized = 0;//Preventing Kernel Panic since 2013
-
-
-/**
- * Initialize the array that contains the topics.
- */
-
-int init_sched_pub_sub(void)
-{
-       int i = 0;
-
-       //Initialize the different topics
-       for (i = 0; i < TOPICS; i++) {
-               FW_LIST_INIT(topic_arr[i].head);
-       }
-
-       fw_printf("++++++++++++++++Scheduler Pub/Sub System Initialized+++++++++++++++++++++++\n");
-       initialized=1;//The Pub/Sub-System can now be used
-       return 0;
-}
-
-/**
- * Return a topic(list) by its id
- * @param topic_id An integer corresponding to the needed topic
- * @return topic that was requested or null if topic does not exist
- */
-static topic_list* get_topic_by_id(int topic_id) {
-       if (topic_id >= TOPICS || topic_id < 0) {
-               return NULL ;
-       }
-       return &topic_arr[topic_id]; //Aus Testgr�nden haben wir nur eins
-}
-
-/**
- * Register a callback function for a topic
- *
- * Each topic has a list of callback-functions that is being called
- * whenever a new message for that topic arrives.
- * @param topic_id
- * @param callback
- * @return
- */
-int subscribe_to_topic(int topic_id, void* callback) {
-       topic_list* topic_header;
-       if(initialized==0){//Force initialization when first needed
-               init_sched_pub_sub();
-       }
-       topic_header = get_topic_by_id(topic_id);
-       if (topic_header == NULL ) {
-               fw_printf("Subscribe to Topic Failed: No topic with id %d found!",topic_id);
-               return 1;
-       } else {
-               topic_list* new_topic_elem;
-               fw_malloc(10);
-               new_topic_elem = (topic_list*)fw_malloc(sizeof(topic_list));
-               new_topic_elem->callback = callback;
-               fw_list_add_tail(&new_topic_elem->head,&topic_header->head);
-               fw_printf("+++ Subscribed to Topic %d +++\n", topic_id);
-       }
-       return 0;
-}
-
-/**
- * Deregister a callback function from a topic
- * WARNING! This does NOT Work in Kernel Mode! Throws a Kernel Panic that we cannot explain.
- */
-int unsubscribe_from_topic(int topic_id, void* callback){
-       topic_list* topic_header;
-       if(initialized==0){//Force initialization when first needed
-               init_sched_pub_sub();
-       }
-       topic_header = get_topic_by_id(topic_id);
-               if (topic_header == NULL ) {
-                       fw_printf("Unsubscribe from Topic Failed: No topic with id %d found!",topic_id);
-                       return 1;
-               } else {
-                       topic_list* pos=topic_header;
-                       fw_list_for_each_entry(pos, &topic_header->head, head){
-                               if(pos->callback==callback){
-                                       fw_printf("Found Topic To Unsubscribe!\n");
-                                       fw_list_del(&pos->head);
-                                       return 0;
-                               }
-                       }
-                       fw_printf("Cannot Unsubscribe from Topic %d. Cannot find the given callback function.\n", topic_id);
-               }
-               return 0;
-}
-
-/**
- * Send a string to a topic
- *
- * @topic_id: subject id
- * @message: string that is to be delivered to the module
- */
-void *send_to_topic(int topic_id, void *ptr) {
-       struct fw_task *ret = NULL;
-       topic_list* topic_header = get_topic_by_id(topic_id);
-       if(initialized==0){//Force initialization when first needed
-               init_sched_pub_sub();
-       }
-       if (topic_header == NULL) {
-               fw_printf("Send To Channel Failed: No topic with id %d found!",topic_id);
-               return NULL;
-       } else {
-                       if(!fw_list_empty(&topic_header->head)){
-                               topic_list *pos;
-                               pos=topic_header;
-                               switch(topic_id){
-                                       case 0://OS demands to wake up the following task
-                                       {
-                                               struct fw_task *wake_up = register_task(ptr);
-                                               fw_list_for_each_entry(pos, &topic_header->head, head){
-                                                       topic_0_callback* cb = (topic_0_callback*) pos->callback;
-                                                       ret = cb(wake_up);
-                                               }
-                                               break;
-                                       }
-                                       case 1://new task has arrived
-                                               {
-                                                       struct fw_task *new_task = register_task(ptr);
-                       
-                                                       fw_list_for_each_entry(pos, &topic_header->head, head){
-                                                               topic_1_callback* cb = (topic_1_callback*) pos->callback;
-                                                               ret = cb(new_task);
-                                                       }
-                                                       break;
-                                               }
-                                       case 2://task finished 
-                                               {
-                                                       struct fw_task *finished = find_fw_task(ptr);
-                                                       fw_list_for_each_entry(pos, &topic_header->head, head){
-                                                               topic_2_callback* cb = (topic_2_callback*) pos->callback;
-                                                               ret = cb(finished);
-                                                       }
-                                                       break;
-                                               }
-                                       case 3://tick 
-                                               {
-                                                       fw_list_for_each_entry(pos, &topic_header->head, head){
-                                                               topic_3_callback* cb = (topic_3_callback*) pos->callback;
-                                                               ret = cb();
-                                                       }
-                                                       break;
-                                               }
-                                       case 4://task yield
-                                               {
-                                                       struct fw_task *yielded = find_fw_task(ptr);
-                                                       fw_list_for_each_entry(pos, &topic_header->head, head){
-                                                               topic_4_callback* cb = (topic_4_callback*) pos->callback;
-                                                               ret = cb(yielded);
-                                                       }
-                                                       break;
-                                               }
-                                       default:
-                                               break;
-
-                               }
-                       }
-                       if(ret)
-                               return ret->real_task;
-       }
-       return NULL;
-}
diff --git a/framework/pub_sub.h b/framework/pub_sub.h
deleted file mode 100644 (file)
index b03395f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * pub_sub.h
- *
- * Initializes a simple Publish/Subscribe mechanism
- * for the Scheduler Framework.
- *
- *  Created on: 14.06.2013
- *      Author: Daniel R�hrig, Christian Ren� Sechting
- */
-
-#ifndef PUB_SUB_H_
-#define PUB_SUB_H_
-
-#include <fw_list.h>
-#include <fw_task.h>
-
-/* List implementation similar to the linux lists */
-typedef struct topic topic_list;
-struct topic{
-       fw_list_head_t head;
-       void* callback;
-};
-/*
- * 0: Task Activated
- * 1: Task Deactivated
- * 2: ?
- * 3: ?
- */
-//typedef enum {ACTIVATED, DEACTIVATED, COMING, SOON} topic_t;
-
-/**
- * Callbacks for the pubsub system
- */
-
-typedef void *topic_0_callback(struct fw_task *wake_up);
-typedef void *topic_1_callback(struct fw_task *task);
-typedef void *topic_2_callback(struct fw_task *finished);
-typedef void *topic_3_callback(void);
-typedef void *topic_4_callback(struct fw_task *yielded);
-
-int init_sched_pub_sub(void);
-
-//TODO: topic_id should be topic_t
-int subscribe_to_topic(int topic_id, void* callback);
-
-//TODO: topic_id should be topic_t
-void *send_to_topic(int topic_id, void *ptr);
-
-//TODO: topic_id should be topic_t
-int unsubscribe_from_topic(int topic_id, void* callback);
-
-#endif /* PUB_SUB_H_ */
index 2d0572e..7463399 100644 (file)
@@ -1165,8 +1165,6 @@ void activate_task(struct rq *rq, struct task_struct *p, int flags)
 //     enqueue_task(rq, p, flags);
 //     list_add(&p->rq_tasks, &rq->rq_list);
 
-//TODO: FRAMEWORK STUFF OR not?
-//     send_to_topic(0,p);
 }
 
 /*
@@ -1327,7 +1325,6 @@ void wake_up_new_task(struct task_struct *p)
        new_task->real_task = p;
 
        fw_notify(ADMIT,new_task);
-//     send_to_topic(1,p);
 
        raw_spin_lock_irqsave(&p->pi_lock, flags);
 
@@ -1347,7 +1344,6 @@ void wake_up_new_task(struct task_struct *p)
 
 
        rq = __task_rq_lock(p);
-//     send_to_topic(1,p);
 //     printk(">>wake_up_new_task:");
        activate_task(rq, p, 0);
        p->on_rq = 1;
@@ -1360,7 +1356,6 @@ void wake_up_new_task(struct task_struct *p)
        task_rq_unlock(rq, p, &flags);
 
        //TODO: FRAMEWORK ZEUGS
-//     send_to_topic(1,p);
 
 //     printk(">>wake_up_new_task:");
 //     activate_task(rq, p, 0);
@@ -1425,8 +1420,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
        if (p->on_rq && ttwu_remote(p, wake_flags))
                goto stat;
 
-//     TODO:framework zeugs
-//     send_to_topic(0,p);
+
        fw_notify(EVENT_OCCURS, p->fw_task);
 
 #ifdef CONFIG_SMP
@@ -1462,10 +1456,6 @@ stat:
 //     raw_spin_unlock(&rq->lock);
 out:
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-
-//TODO: FRAMEWORK
-//send_to_topic(0,p);
-
        return success;
 }