Further cleanup and refactoring
authorAnselm Busse <anselm.busse@tu-berlin.de>
Tue, 2 Feb 2016 17:26:07 +0000 (18:26 +0100)
committerAnselm Busse <anselm.busse@tu-berlin.de>
Tue, 2 Feb 2016 17:26:07 +0000 (18:26 +0100)
46 files changed:
framework/generated/fw_comm_generated.c [deleted file]
framework/generated/topo_lb_rr_multi.c
framework/include/debug/fw_break.h [deleted file]
framework/include/debug/fw_detect.h [deleted file]
framework/include/fw.h
framework/include/fw_components.h
framework/include/fw_debug.h
framework/include/fw_export.h [deleted file]
framework/include/fw_helper.h [new file with mode: 0644]
framework/include/fw_init.h [new file with mode: 0644]
framework/include/fw_list.h
framework/include/fw_lock.h
framework/include/fw_mem.h [new file with mode: 0644]
framework/include/fw_pipe.h
framework/include/fw_sched.h
framework/include/fw_task.h
framework/include/fw_types.h
framework/include/generated/fw_comm_generated.h [deleted file]
framework/include/os.h
framework/include/os/fbsd.h
framework/include/os/linux.h
framework/include/os_sched.h
framework/include/os_types.h [new file with mode: 0644]
framework/lib/fw.c [deleted file]
framework/lib/fw_comm.c
framework/lib/fw_components.c
framework/lib/fw_debug.c [deleted file]
framework/lib/fw_init.c [new file with mode: 0644]
framework/lib/fw_list.c
framework/lib/fw_mem.c [new file with mode: 0644]
framework/lib/fw_pipe.c
framework/lib/fw_sched.c
framework/lib/fw_task.c [new file with mode: 0644]
framework/modules/load_balance.c
framework/os/bertos/os.c
framework/os/freebsd/fbsd_sched.c
framework/os/freebsd/os_kdb.c
framework/os/freebsd/os_sched.c
framework/os/linux/Makefile
framework/os/linux/linux_sched.c
framework/os/linux/os.c
framework/os/linux/os_kdb.c
framework/os/linux/os_sched.c
framework/os/linux/os_syscall.c
framework/os/simulated/fw_task_sim.c
framework/os/simulated/main.c

diff --git a/framework/generated/fw_comm_generated.c b/framework/generated/fw_comm_generated.c
deleted file mode 100644 (file)
index 1c89f0e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "fw.h"
-
-
-
-void fw_comm_register_generated(void)
-{
-
-}
index a1fa74a..c14a4a2 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <fw.h>
 
-
 int fw_build_module_list[3] = {0x01, 0x02, 0x0D};
 
 fw_pipe_t **topo_pipes;
@@ -31,12 +30,6 @@ int fw_build_topo(void)
        fw_pipe_t **temp;
 
        num_links = fw_num_cpus * 2;
-       fw_num_instances = fw_num_cpus + 2; // one RR for each core + load-balancer + affinity module
-
-       if ((fw_component_instances = fw_malloc(fw_num_instances * sizeof(fw_component_inst_t*))) == NULL) {
-                       fw_panic("failed to allocate memory for instance references\n");
-                       /* never reached */;
-       }
 
        if ((topo_pipes = fw_malloc(num_links * sizeof(fw_pipe_t *))) == NULL) {
                        fw_panic("failed to allocate memory for pipes\n");
@@ -77,7 +70,7 @@ int fw_build_topo(void)
        for (i=0; i<fw_num_cpus; i++)
                temp[i+1] = topo_pipes[fw_num_cpus+i];
 
-       if ((fw_component_instances[0] = fw_component_new(0x02, 0, fw_num_cpus+1, temp)) == NULL) {
+       if (fw_component_new(0x02, 0, fw_num_cpus+1, temp) == NULL) {
                fw_panic("failed to allocate component\n");
                /* never reached */;
        }
@@ -87,7 +80,7 @@ int fw_build_topo(void)
                fw_printf("Creating a new Instance of %s...", fw_component_name(0x01));
                temp[0] = topo_pipes[fw_num_cpus+i];
                temp[1] = topo_pipes[i];
-               if ((fw_component_instances[i+1] = fw_component_new(0x01, i+1, 2, temp)) == NULL) {
+               if (fw_component_new(0x01, i+1, 2, temp) == NULL) {
                        fw_panic("failed to allocate component\n");
                        /* never reached */;
                };
@@ -95,7 +88,7 @@ int fw_build_topo(void)
        }
 
        fw_printf("Creating a new Instance of %s...", fw_component_name(0x0D));
-       if ((fw_component_instances[i+1] = fw_component_new(0x0D, i+1, 0, NULL)) == NULL) {
+       if (fw_component_new(0x0D, i+1, 0, NULL) == NULL) {
                fw_panic("failed to allocate component\n");
                /* never reached */;
        };
diff --git a/framework/include/debug/fw_break.h b/framework/include/debug/fw_break.h
deleted file mode 100644 (file)
index c349354..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <debug/fw_detect.h>
-
-#ifndef FW_BREAK_H_
-#define FW_BREAK_H_
-
-#ifdef FW_BREAK_ASSERT
-       #if FW_CPU_X86
-               #define FW_BREAKPOINT  asm volatile ("int3" ::)
-       #elif FW_CPU_AVR
-               #define FW_BREAKPOINT  asm volatile ("break" ::)
-       #else
-               #define FW_BREAKPOINT /* nop */
-       #endif
-#else
-       #define FW_BREAKPOINT /* nop */
-#endif
-
-#endif /* FW_BREAK_H_ */
diff --git a/framework/include/debug/fw_detect.h b/framework/include/debug/fw_detect.h
deleted file mode 100644 (file)
index 2196a2f..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef FW_DETECT_H_
-#define FW_DETECT_H_
-
-#if defined(__i386__)
-       #define FW_CPU_X86                 1
-       #define FW_CPU_X86_32              1
-       #define FW_CPU_X86_64              0
-       #define FW_CPU_CORE_NAME           "x86"
-#elif defined(__x86_64__)
-       #define FW_CPU_X86                 1
-       #define FW_CPU_X86_32              0
-       #define FW_CPU_X86_64              1
-       #define FW_CPU_CORE_NAME           "x86_64"
-#else
-       #define FW_CPU_X86                 0
-       #define FW_CPU_I386                0
-       #define FW_CPU_X86_64              0
-#endif
-
-#if defined (__AVR__)
-       #define FW_CPU_AVR                 1
-       #define FW_CPU_CORE_NAME           "AVR"
-#else
-       #define FW_CPU_AVR                 0
-#endif
-
-#endif /* FW_DETECT_H_ */
index ec9d426..ed3deaa 100644 (file)
-/**
- * \file fw.h
- * \brief The main header file for the framework.
- * \author Anselm Busse
+/*
+ * fw.h
  *
- * This file has to be included for everything related to the framework.
+ *  Created on: 02.02.2016
+ *      Author: abusse
  */
 
-#ifndef _FW_H_
-#define _FW_H_
+#ifndef FW_H_
+#define FW_H_
 
-
-#include <os.h>
-
-#include <fw_types.h>
 #include <fw_comm.h>
-#include <fw_list.h>
-#include <fw_task.h>
-#include <generated/fw_comm_generated.h>
+#include <fw_components.h>
+#include <fw_debug.h>
+#include <fw_helper.h>
 #include <fw_irq.h>
+#include <fw_limits.h>
+#include <fw_list.h>
 #include <fw_lock.h>
-#include <fw_sched.h>
+#include <fw_mem.h>
 #include <fw_pipe.h>
+#include <fw_task.h>
+#include <fw_types.h>
 
-#include <fw_debug.h>
-#include "fw_components.h"
-
-/**
- * \brief A printf function.
- *
- * @param formatstring The format string to print on screen.
- */
-#define fw_printf(fmt, ...) os_printf("CoBaS: " fmt, ## __VA_ARGS__)
-
-/**
- * \brief Print an error message.
- *
- * @param formatstring The format string to print on screen.
- */
-#define fw_error(fmt, ...) os_printf("CoBaS Error: " fmt, ## __VA_ARGS__)
-
-/**
- * \brief Panic if we do not know what else to do.
- *
- * @param formatstring The format string to print on screen.
- */
-#define fw_panic(fmt, ...) os_panic("CoBaS Panic: " fmt, ## __VA_ARGS__)
-
-/**
- * CPU information.
- */
-#define fw_num_cpus os_num_cpus
-#define fw_cpu_id os_cpu_id
-
-/**
- * Macros to access OS dependent task information.
- */
-#define FW_TASK_NAME(tsk) OS_TASK_NAME(tsk)
-#define FW_TASK_ID(tsk) OS_TASK_ID(tsk)
-#define FW_TASK_CPU(tsk) OS_TASK_CPU(tsk)
-#define FW_TASK_CPUMASK(tsk) OS_TASK_CPUMASK(tsk)
-#define FW_CPU_ISSET(tsk, cpu) OS_CPU_ISSET(tsk, cpu)
-#define FW_TASK_STATE(tsk) OS_TASK_STATE(tsk)
-
-#define FW_SMP_STARTED OS_SMP_STARTED
-
-extern fw_component_inst_t **fw_component_instances;
-extern unsigned int fw_num_instances;
-
-// TODO move to helper .h
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
-#ifndef UNUSED
-#define UNUSED(x) (void)(x)
-#endif
-
-/**
- *  Export global lists used by e.g. modules
- */
-//extern fw_tlist_t *fw_fw_ready_list_out;
-//extern fw_tlist_t *fw_fw_schedule_in[FW_NR_CPUS];
-//extern fw_tlist_t *fw_fw_blocked_list_out;
-
-extern int fw_malloc_count;
-
-void fw_schedule(int cpu);
-
-void fw_task_init(fw_task_t *task);
-
-void fw_task_destroy(fw_task_t *task);
-
-/**
- * \brief Dynamic allocation of memory.
- *
- * @param size The amount of memory to allocate.
- * @return A pointer to the allocated memory.
- */
-void *fw_malloc(fw_size_t size);
-
-/**
- * \brief Releases a dynamically allocated chunk of memory.
- *
- * @param ptr Memory region to release.
- */
-void fw_free(void* addr);
-
-void fw_init(void);
-
-#endif /* _FW_H_ */
+#endif /* FW_H_ */
index 16ded83..270f39f 100644 (file)
 #include <fw_types.h>
 #include <fw_limits.h>
 
+/**
+ * This array hold references to every instantiated component.
+ */
+extern fw_component_inst_t *fw_component_instances[];
+/**
+ * Represents the number of running component instances.
+ */
+extern unsigned int fw_num_component_instances;
+
 /**
  * Type for component identifiers.
  */
index f428635..5df0d17 100644 (file)
@@ -1,32 +1,31 @@
+/**
+ * @file fw_comm.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains debugging macros.
+ */
+
 #ifndef FW_DEBUG_H_
 #define FW_DEBUG_H_
 
-#include <debug/fw_detect.h>
-#include <debug/fw_break.h>
+#include <fw_helper.h>
 
 #define FW_DEBUG 1
 
-void __fw_assert(const char *cond, const char *file, int line);
-
-
 #ifdef FW_DEBUG
+       #define __fw_assert(cond, file, line) fw_error("%s:%d - Assertion failed: %s\n", file, line, cond)
+
        #define FW_DEBUG_PRINT(fmt, ...) fw_printf(fmt, ## __VA_ARGS__)
 
        #define FW_ASSERT(x)         ((void)((x) ? 0 : __fw_assert(#x, __FILE__, __LINE__)))
        #define FW_ASSERT_H(x, help) ((void)((x) ? 0 : __fw_assert(help " (" #x ")", __FILE__, __LINE__)))
+
 #else /* FW_DEBUG */
        #define FW_DEBUG_PRINT(fmt, ...)
 
        #define FW_ASSERT(x)
        #define FW_ASSERT_H(x, help)
-
 #endif /* FW_DEBUG */
 
-/**
- * Checks if a lock is locked. Note that this call is *NOT* safe!
- *
- * @param lock The lock to check.
- */
-#define FW_IS_LOCKED(ptr) ((*ptr).raw_lock.slock == FW_SPINLOCK_LOCKED.slock)
-
 #endif /* FW_DEBUG_H_ */
diff --git a/framework/include/fw_export.h b/framework/include/fw_export.h
deleted file mode 100644 (file)
index f21c11d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef FW_EXPORT_H_
-#define FW_EXPORT_H_
-
-/*
-* Export symbols from the kernel to modules.  Forked from module.h
-* to reduce the amount of pointless cruft we feed to gcc when only
-* exporting a simple symbol or two.
-*
-* Try not to add #includes here.  It slows compilation and makes kernel
-* hackers place grumpy comments in header files.
-*/
-
-/* Some toolchains use a `_' prefix for all user symbols. */
-//#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
-#if 1
-       #define __FW_SYMBOL(x) _##x
-       #define __FW_SYMBOL_STR(x) "_" #x
-#else
-       #define __FW_SYMBOL(x) x
-       #define __FW_SYMBOL_STR(x) #x
-#endif
-
-/* Indirect, so macros are expanded before pasting. */
-#define FW_SYMBOL(x) __FW_SYMBOL(x)
-#define FW_SYMBOL_STR(x) __FW_SYMBOL_STR(x)
-
-#endif /* FW_EXPORT_H_ */
diff --git a/framework/include/fw_helper.h b/framework/include/fw_helper.h
new file mode 100644 (file)
index 0000000..f3c53ea
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * @file fw_comm.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains helper macros including printf facilities.
+ */
+
+#ifndef INCLUDE_FW_HELPER_H_
+#define INCLUDE_FW_HELPER_H_
+
+/**
+ * \brief A printf function.
+ *
+ * @param fmt The format string to print on screen.
+ */
+#define fw_printf(fmt, ...) os_printf("CoBaS: " fmt, ## __VA_ARGS__)
+
+/**
+ * \brief Print an error message.
+ *
+ * @param fmt The format string to print on screen.
+ */
+#define fw_error(fmt, ...) os_printf("CoBaS Error: " fmt, ## __VA_ARGS__)
+
+/**
+ * \brief Panic if we do not know what else to do.
+ *
+ * @param fmt The format string to print on screen.
+ */
+#define fw_panic(fmt, ...) os_panic("CoBaS Panic: " fmt, ## __VA_ARGS__)
+
+/**
+ * CPU information.
+ */
+#define fw_num_cpus os_num_cpus
+#define fw_cpu_id os_cpu_id
+
+/**
+ * Macros to access OS dependent task information.
+ */
+#define FW_TASK_NAME(tsk) OS_TASK_NAME(tsk)
+#define FW_TASK_ID(tsk) OS_TASK_ID(tsk)
+#define FW_TASK_CPU(tsk) OS_TASK_CPU(tsk)
+#define FW_TASK_CPUMASK(tsk) OS_TASK_CPUMASK(tsk)
+#define FW_CPU_ISSET(tsk, cpu) OS_CPU_ISSET(tsk, cpu)
+#define FW_TASK_STATE(tsk) OS_TASK_STATE(tsk)
+
+#define FW_SMP_STARTED OS_SMP_STARTED
+
+#ifndef UNUSED
+       #define UNUSED(x) do { (void)(x); } while (0)
+#endif
+
+#ifndef ARRAY_SIZE
+       #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+#endif /* INCLUDE_FW_HELPER_H_ */
diff --git a/framework/include/fw_init.h b/framework/include/fw_init.h
new file mode 100644 (file)
index 0000000..4a1645f
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * @file fw_comm.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * Interface definition of the CoBaS initialization.
+ */
+#ifndef INCLUDE_FW_INIT_H_
+#define INCLUDE_FW_INIT_H_
+
+void fw_init(void);
+
+#endif /* INCLUDE_FW_INIT_H_ */
index 87cac05..435decd 100644 (file)
@@ -9,120 +9,6 @@ typedef struct fw_list_head {
        struct fw_list_head *prev;
 }fw_list_head_t;
 
-typedef struct fw_tlist_elem {
-       struct fw_task *task;
-       struct fw_tlist_elem *next;
-       struct fw_tlist_elem *prev;
-} fw_tlist_elem_t;
-
-typedef struct fw_tlist {
-       struct fw_tlist_elem *head;
-       struct fw_tlist_elem *tail;
-} fw_tlist_t;
-
-/*
- * fw_tlist_init - init for a list. head and tail are set to NULL
- * @list: the list to initialize
- */
-void fw_tlist_init(struct fw_tlist *list);
-
-/**
- * fw_tlist_empty - tests whether a list is empty or not
- * @list: the list to test.
- */
-int fw_tlist_empty(struct fw_tlist *list);
-
-/**
- * fw_tlist_length - returns the number of entries in a list.
- * @list: the list to test.
- */
-int fw_tlist_length(struct fw_tlist *list);
-
-/*
- * __fw_tlist_add
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-void __fw_tlist_add(struct fw_tlist_elem *_new,
-                             struct fw_tlist_elem *prev,
-                             struct fw_tlist_elem *next);
-
-/**
- * fw_tlist_add_tail - add a new entry
- * @_new: new entry to be added
- * @list: the list where the entry gets added
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- */
-void fw_tlist_add_tail(struct fw_tlist_elem *_new, struct fw_tlist *list);
-
-/**
- * fw_tlist_add_first - add a new entry at the beginning of the list
- * @_new: new entry to be added
- * @list: the list where the entry gets added
- */
-void fw_tlist_add_first(struct fw_tlist_elem *_new, struct fw_tlist *list);
-
-/**
- * fw_tlist_add_at_pos - add a new entry at a given position (starting with 0);
- * @_new: new entry to be added
- * @list: the list where the entry gets added
- * @pos: position where to insert the element at
- */
-void fw_tlist_add_at_pos(struct fw_tlist_elem *_new, struct fw_tlist *list, int pos);
-
-/**
- * __fw_tlist_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: fw_tlist_empty() on entry does not return true after this, the entry is
- * in an undefined state.
- */
-void __fw_tlist_del(struct fw_tlist_elem * elem);
-
-/*
- * fw_tlist_pop - returns the first element of a list and removes it from there
- * @list: the list to remove the first entry from
- * note: returns NULL if the list is empty
- */
-struct fw_tlist_elem *fw_tlist_pop(struct fw_tlist *list);
-
-/*
- * fw_tlist_entry - returns the task from the first element in the list
- * @list: the list to take the first task from
- * note: the list does not get manipulated, the first element stays in the list
- */
-struct fw_task *fw_tlist_entry(struct fw_tlist *list);
-
-/*
- * fw_tlist_remove - removes an element from a list
- * @elem: the element that should be removed
- * @list: the list where the element should be removed from
- * note:  there are no checkings if the given element resides on
- *               on the given list. Mixing things up here causes corrupted
- *               lists!!!
- */
-void fw_tlist_remove(struct fw_tlist_elem *elem, struct fw_tlist *list);
-
-/*
- * fw_tlist_for_each_entry - for each through the whole list
- * @pos: a pointer to a fw_tlist_elem_t to go through the list
- * @list: the list to go through
- * note: every iteration pos is the next entry in the list
- *
- * an example:
- *
- *             fw_tlist_for_each_entry(pos,list) {
- *                     pos->...
- *             }
- *
- *             importante: { and }
- */
-#define fw_tlist_for_each_entry(pos,list)\
-       for(pos = list->head;pos != NULL;pos = pos->next)
-
 /*
  * KERNEL LIST STUFF
  */
index 315345f..911835e 100644 (file)
@@ -67,6 +67,7 @@
  * interrupt states. It willbspin until capable to do so.
  *
  * @param lock The lock to operate on.
+ * @param flags The flags to save.
  */
 #define fw_spin_lock_irqsave(lock, flags) os_spin_lock_irqsave(lock, flags)
 
diff --git a/framework/include/fw_mem.h b/framework/include/fw_mem.h
new file mode 100644 (file)
index 0000000..3126235
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * @file fw_mem.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains the interface description for the CoBaS memory management.
+ */
+
+#ifndef FW_MEM_H_
+#define FW_MEM_H_
+
+#include <fw_types.h>
+
+/**
+ * \brief Dynamic allocation of memory.
+ *
+ * @param size The amount of memory to allocate.
+ * @return A pointer to the allocated memory.
+ */
+void *fw_malloc(fw_size_t size);
+
+/**
+ * \brief Releases a dynamically allocated chunk of memory.
+ *
+ * @param addr Memory region to release.
+ */
+void fw_free(void* addr);
+
+#endif /* FW_MEM_H_ */
index 3865d60..e7386f8 100644 (file)
@@ -5,23 +5,18 @@
  * @brief Interface definition for CoBaS pipes.
  *
  * This is the interface definition for pipes in CoBaS. Pipes are connecting
- * component instances with each other and are the main means to propergate
- * task sets and orders inside the framework.
+ * component instances with each other and are the main means to propagate task
+ * sets and orders inside the framework.
  */
 
 #ifndef _FW_PIPE_H_
 #define _FW_PIPE_H_
 
-#include <fw_limits.h>
-#include <fw_pipe_pcb.h>
+#include <fw_types.h>
 #include <fw_lock.h>
-#include <fw_list.h>
-#include "fw_components.h"
 
 /**
  * @brief Definition of the CoBaS Pipe structure.
- *
- * TODO
  */
 typedef struct fw_pipe {
        int id;                                                 /**< Unique identifier for a pipe instance. */
@@ -32,8 +27,8 @@ typedef struct fw_pipe {
        fw_list_head_t tasks_removed;   /**< Tasks removed from the pipe since the last access. */
        fw_list_head_t tasks_moved;             /**< Tasks moved inside the pipe since the last access. */
 
-       fw_component_inst_t *in;                        /**< Reference to the source component instance connected to the pipe. */
-       fw_component_inst_t *out;                       /**< Reference to the target component instance connected to the pipe. */
+       fw_component_inst_t *in;                /**< Reference to the source component instance connected to the pipe. */
+       fw_component_inst_t *out;               /**< Reference to the target component instance connected to the pipe. */
 } fw_pipe_t;
 
 /**
@@ -41,15 +36,44 @@ typedef struct fw_pipe {
  */
 #define fw_pipe_entry(PIPE,LIST) fw_container_of(fw_container_of(&(PIPE)->tasks_ ## LIST, fw_pipe_pcb_t, LIST),fw_task_t,pipe_pcb[(PIPE)->id])
 
-
+/**
+ * \brief Allocates and initializes a new CoBaS pipe.
+ *
+ * @return The new pipe of NULL if an error occured.
+ */
 fw_pipe_t *fw_pipe_alloc(void);
 
+/**
+ * \brief Frees the resources of the given CoBaS pipe.
+ *
+ * @param pipe The pipe to remove from memory.
+ */
 void fw_pipe_free(fw_pipe_t *pipe);
 
+/**
+ * \brief Initializes the PCB for the pipe subsystem for a new Task.
+ *
+ * @param self Not considered and only for compatibility. There is only one pipe
+ * subsystem
+ * @param task The new task.
+ * @return Returns zero on success.
+ */
 int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task);
 
+/**
+ * \brief Frees the PCB for the pipe subsystem.
+ *
+ * @param self Not considered and only for compatibility. There is only one pipe
+ * subsystem
+ * @param task The obsolete task
+ */
 void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task);
 
+/**
+ * \brief Initializes the pipe subsystem.
+ *
+ * @return Returns zero on success.
+ */
 int fw_pipes_init(void);
 
 #endif /* _FW_PIPE_H_ */
index 02f7edd..7a96447 100644 (file)
-/*
- * fw_sched.h
+/**
+ * @file fw_sched.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
  *
- *  Created on: 17.12.2013
- *      Author: jkrieg
+ * This file contains the interface description for CoBaS function that are
+ * related to the rescheduling of tasks.
  */
 
 #ifndef FW_SCHED_H_
 #define FW_SCHED_H_
 
-
-#define FW_NR_QUEUES 3
-
-#define FW_FOREACH_CPU(i)                                      \
-       for ((i) = 0; (i) <= FW_NR_CPUS; (i)++)
+#include <fw_types.h>
 
 /**
- * Define the queues as a bit mask.
+ * The pipe for all available tasks that are ready for scheduling.
  */
-#define FW_RUN_QUEUE           0x01
-#define FW_BLOCKED_QUEUE       0x02
-#define FW_SUSPEND_QUEUE       0x04
-
-
-#define fw_per_cpu(var, cpu) ((typeof(*(var))*)&(var[cpu]))
-#define fw_data_cpu(cpu)       (fw_per_cpu(fw_data, (cpu)))
-
-
-
-struct fw_rq {
-       fw_spinlock_t *lock;
-       struct fw_tlist list;
-};
-
-struct fw_bq {
-       fw_spinlock_t *lock;
-       struct fw_tlist list;
-};
-
-struct fw_sq {
-       fw_spinlock_t *lock;
-       struct fw_tlist list;
-};
-
-
-struct fw_data {
-       struct fw_rq rq;
-       struct fw_bq bq;
-       struct fw_sq sq;
-
-       struct fw_task *fw_current, *fw_idle;
-};
-extern struct fw_data *fw_data;
-
-
-/**
- * \brief      Initialize framework dependent scheduling variables.
- */
-void fw_sched_init(void);
-
+extern fw_pipe_t *fw_fw_ready_pipe;
 /**
- * \brief      Adds task to global run-queue and sets the task state
- *                     to FW_READY.
- *
- * @param      task    Task that should be added.
- */
-void fw_task_rq_add(struct fw_task *task);
-
-/**
- * \brief      Removes task from global run-queue.
- *
- * @param      task    Task that should be removed.
+ * The pipes that are considered during dispatching.
  */
-void fw_task_rq_rem(struct fw_task *task);
+extern fw_pipe_t **fw_fw_dispatch_pipe;
 
 /**
- * \brief      Adds task to global block-queue and sets the task state
- *                     to FW_BLOCKED.
- *
- * @param      task    Task that should be added.
+ * \brief Initializes the CoBaS scheduling subsystem.
  */
-void fw_task_bq_add(struct fw_task *task);
-
-/**
- * \brief      Removes task from global block-queue.
- *
- * @param      task    Task that should be removed.
- */
-void fw_task_bq_rem(struct fw_task *task);
+void fw_sched_init(void);
 
-/**
- * \brief      Removes task from global block-queue and adds it to
- *                     to global run-queue.
- *
- * @param      task    Task that should be removed.
- */
-void fw_task_unblock(struct fw_task *task);
 
 /**
- * \brief      Sets the task state to FW_EXIT.
- *
- * @param      task    Task that should be removed.
- */
-void fw_task_release(struct fw_task *task);
-
-
-/*
- * \brief      Wrapper that combines two lists and calls __fw_dispatch.
+ * \brief Dispatches the next task on the requested processing element.
  *
- * @param      none.
- */
-void fw_dispatch(void);
-
-/**
- * \brief      Runs the given task on the given processing unit.
+ * This function selects a new task for the given processing element and calls
+ * the runtime system via the os_dispatch(fw_task_t*) function. The execution
+ * path will, in general, leave the framework at this point.
  *
- * @param      task    The task that shall run.
- * @param      cpu     The CPU that will run the task.
+ * @param pe The processing element that needs a new task assigned.
  */
-void fw_dispatch_mp(struct fw_task *task, int cpu);
+void fw_schedule(int pe);
 
 /**
  * \brief      Returns the currently running task on the given processing unit.
  *
- * @param      cpu     CPU to look on.
+ * @param      pe      PE to look on.
  * @return     The currently running task.
  */
-struct fw_task *fw_current_task(int cpu);
+struct fw_task *fw_current_task(int pe);
 
 /**
  * \brief      Sets the CPU value of the given task.
@@ -145,13 +64,6 @@ void fw_set_task_cpu(struct fw_task *task, int cpu);
  */
 int fw_task_info(struct fw_task *task, char *buf, int length);
 
-/**
- * \brief      Schedules away a task which used up his time slice
- *
- * @param      task    Current running task.
- */
-void fw_need_resched(struct fw_task *task);
-
 /**
  * \brief      Send an interrupt to remote CPU.
  *
@@ -159,15 +71,5 @@ void fw_need_resched(struct fw_task *task);
  */
 void fw_send_ipi(int cpu);
 
-/**
- * \brief      Prints elements of desired list.
- *
- * @param      head    List head.
- */
-void fw_tlist_print(struct fw_tlist *list);
-
-void fw_sched_init_stage1(void);
-
-void fw_sched_init_stage2(void);
 
 #endif /* FW_SCHED_H_ */
index fedaf0b..97221f0 100644 (file)
@@ -1,32 +1,72 @@
+/**
+ * @file fw_task.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains the interface definition for task operations in CoBaS.
+ */
+
 #ifndef FW_TASK_H_
 #define FW_TASK_H_
 
-#include <fw_limits.h>
-#include <fw_pipe_pcb.h>
-
-
-#define task_context_t void
-
-/* defined task states */
+#include <fw_types.h>
 
+/**
+ * Definition of task states in CoBaS.
+ */
 typedef enum fw_task_state {
-       FW_RUNNING      = 0x00,
-       FW_BLOCKED      = 0x01,
-       FW_READY        = 0x02,
-       FW_EXIT         = 0x04,
-       FW_IDLE         = 0x80
+       FW_RUNNING      = 0x00, /**< FW_RUNNING */
+       FW_BLOCKED      = 0x01, /**< FW_BLOCKED */
+       FW_READY        = 0x02, /**< FW_READY */
+       FW_EXIT         = 0x04, /**< FW_EXIT */
+       FW_IDLE         = 0x80  /**< FW_IDLE */
 } fw_task_state_t;
 
 /**
- * The PCB of CoBaS.
+ * This structure represents the PCB in CoBaS.
  */
 typedef struct fw_task {
-       enum fw_task_state state;
-       void *real_task;
+       enum fw_task_state state;                       /**< The state of the current task. */
+       os_task_t *os_task;                                     /**< A reference to the legacy PCB in the runtime environment */
        unsigned int cpu;
-       task_context_t *task_context;
+       fw_task_context_t *task_context;
        fw_pipe_pcb_t pipe_pcb[FW_MAX_PIPES];
        void *component_pcb[FW_MAX_COMPONENT_INST];
 } fw_task_t;
 
+/**
+ * \brief Allocates memory for a new task structure.
+ *
+ * @return Pointer to the new task structure if successful, NULL otherwise.
+ */
+fw_task_t *fw_task_alloc(void);
+
+/**
+ * \brief Allocates memory for a new task structure and initializes it.
+ *
+ * @return Pointer to the new task structure if successful, NULL otherwise.
+ */
+fw_task_t *fw_task_new(void);
+
+/**
+ * \brief Initializes a task.
+ *
+ * During task initialization the CoBaS PCB filled with sane values. Furthermore
+ * the task initialization function of every component instance is called, so
+ * every module can initialize its local PCB.
+ *
+ * @param task The task to initialize
+ */
+void fw_task_init(fw_task_t *task);
+
+/**
+ * \brief Frees the resources specific to a task.
+ *
+ * This function frees the CoBaS PCB and also orders every component instance to
+ * free the task specific resources for the given task.
+ *
+ * @param task The task to free.
+ */
+void fw_task_destroy(fw_task_t *task);
+
 #endif /* FW_TASK_H_ */
index 21d68b1..0c4aa81 100644 (file)
@@ -1,15 +1,34 @@
-#include <fw_list.h>
-
 #ifndef FW_TYPES_H_
 #define FW_TYPES_H_
 
+#include <os_types.h>
+
+#include <fw_limits.h>
+#include <fw_pipe_pcb.h>
+
 #ifndef NULL
-#define NULL (void *)0
+       #define NULL (void *)0
 #endif
 
+#define fw_size_t os_size_t
+
+
+typedef struct fw_list_head fw_list_head_t;
+
 typedef struct fw_sched_chain fw_sched_chain_t;
 
-typedef struct fw_task fw_task_t;
+/**
+ * The type of the legacy PCB of the runtime system. Defaults to <code>void</code>
+ * if not defined by the target runtime system.
+ */
+#define os_task_t __os_task_t
+/**
+ * The type of the process context that is saved when a process is evaded from
+ * the processing element.
+ */
+#define fw_task_context_t os_task_context_t
+
+
 typedef struct fw_pipe fw_pipe_t;
 typedef struct fw_component_inst fw_component_inst_t;
 
diff --git a/framework/include/generated/fw_comm_generated.h b/framework/include/generated/fw_comm_generated.h
deleted file mode 100644 (file)
index 8466eb5..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef FW_COMM_GENERATED_H_
-#define FW_COMM_GENERATED_H_
-
-#define RR_ADMIT       20
-#define RR_RELEASE     21
-#define RR_BLOCK       22
-#define RR_UNBLOCK     23
-#define RR_DISPATCH    24
-
-void fw_comm_register_generated(void);
-
-#endif /* FW_COMM_GENERATED_H_ */
index d76d2d0..13f1595 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef OS_H_
 #define OS_H_
 
+//this must be included fist as it has multiple mappings to target OS related stuff
 #include <os_target.h>
 #include <os_irq.h>
 #include <os_lock.h>
@@ -62,7 +63,7 @@
  * @param size The amount of memory to allocate.
  * @return A pointer to the allocated memory.
  */
-void *os_malloc(fw_size_t size);
+void *os_malloc(os_size_t size);
 
 /**
  * \brief Releases a dynamically allocated chunk of memory.
index 21dda09..8d10869 100644 (file)
@@ -28,7 +28,7 @@
 #define os_printf printf
 #define fw_irq_flags long
 
-#define fw_size_t unsigned long
+#define os_size_t unsigned long
 
 
 /*
index 6200fad..0d52c42 100644 (file)
@@ -1,42 +1,10 @@
 #ifndef LINUX_H_
 #define LINUX_H_
 
-#include  <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <asm/mmu_context.h>
-#include <linux/completion.h>
-#include <linux/kernel_stat.h>
-#include <linux/blkdev.h>
-#include <linux/syscalls.h>
-#include <linux/kprobes.h>
-
-#include <linux/export.h>
-#include <linux/context_tracking.h>
-#include <linux/kthread.h>
-#include <linux/init_task.h>
-
-#include <asm/switch_to.h>
-#include <asm/tlb.h>
-#include <linux/cgroup.h>
-//#include "sched.h"
-#include "../workqueue_internal.h"
-#include "../smpboot.h"
-
-
-
 #include <linux/sched.h>
-#include <linux/sched/sysctl.h>
-#include <linux/sched/rt.h>
-#include <linux/spinlock.h>
-#include <linux/stop_machine.h>
-//#include <linux/spinlock_api_smp.h>
-#include <linux/list.h>
-#include <linux/delayacct.h>
 
 #include <linux/cpuidle.h>
-#include <linux/cpumask.h>
-
+#include <linux/slab.h>
 
 struct task_group {
 };
@@ -69,8 +37,9 @@ extern unsigned int smp_started;
 #define os_local_irq_save local_irq_save
 #define os_local_irq_restore local_irq_restore
 
-#define fw_size_t unsigned long
-
+#define os_size_t unsigned long
+#define __os_task_t struct task_struct
+#define os_task_context_t void
 
 #define os_spinlock_t spinlock_t
 
@@ -97,7 +66,7 @@ extern unsigned int smp_started;
 /*
  * Macros to access thread struct specific OS dependent information.
  */
-#define OS_TASK(tsk) ((struct task_struct*)tsk->real_task)
+#define OS_TASK(tsk) (tsk->os_task)
 #define OS_TASK_NAME(tsk) (OS_TASK(tsk)->comm)
 #define OS_TASK_ID(tsk) (OS_TASK(tsk)->pid)
 #define OS_TASK_CPU(tsk) task_thread_info(OS_TASK(tsk))->cpu
index c47d411..0a5fcb7 100644 (file)
 #include "fw_types.h"
 #include "fw_task.h"
 
-
-
-/**
- * \brief Runs the given task on a (random) processing unit.
- *
- * @param task The task that shall run.
- */
-void os_dispatch(fw_task_t *task);
-
 /**
  * \brief Runs the given task on the given processing unit.
  *
  * @param task The task that shall run.
  * @param cpu The CPU that will run the task.
  */
-void os_dispatch_mp(fw_task_t *task, int cpu);
+void os_schedule(fw_task_t *task, int pe);
 
 /**
  * \brief Obtains the currently running thread on the given CPU.
diff --git a/framework/include/os_types.h b/framework/include/os_types.h
new file mode 100644 (file)
index 0000000..6ab116e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * os_types.h
+ *
+ *  Created on: 01.02.2016
+ *      Author: abusse
+ */
+
+#ifndef INCLUDE_OS_TYPES_H_
+#define INCLUDE_OS_TYPES_H_
+
+#include <os_target.h>
+
+#ifndef os_size_t
+#error "os_size_t not defined for target OS"
+#endif
+
+#ifndef __os_task_t
+#warning "__os_task_t not defined for target OS, defaulting to 'void'"
+#define __os_task_t void
+#endif
+
+#ifndef os_task_context_t
+#warning "os_task_context_t not defined for target OS, defaulting to 'void'"
+#define os_task_context_t void
+#endif
+
+#endif /* INCLUDE_OS_TYPES_H_ */
diff --git a/framework/lib/fw.c b/framework/lib/fw.c
deleted file mode 100644 (file)
index 1e4e083..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "fw.h"
-
-extern int fw_build_topo(void);
-extern void __fw_schedule(int);
-
-fw_component_inst_t **fw_component_instances;
-unsigned int fw_num_instances;
-
-void fw_schedule(int cpu)
-{
-       __fw_schedule(cpu);
-}
-
-void fw_task_init(fw_task_t *task)
-{
-       int i;
-
-       fw_pipe_task_init(NULL, task);
-
-       for(i=0;i<fw_num_instances;i++){
-               if (fw_component_instances[i]->ops.task_init != NULL)
-                       fw_component_instances[i]->ops.task_init(fw_component_instances[i],task);
-       }
-}
-
-void fw_task_destroy(fw_task_t *task)
-{
-       int i;
-
-       fw_pipe_task_destroy(NULL, task);
-
-       for(i=0;i<fw_num_instances;i++){
-               if (fw_component_instances[i]->ops.task_destroy != NULL)
-                       fw_component_instances[i]->ops.task_destroy(fw_component_instances[i],task);
-       }
-}
-
-void *fw_malloc(fw_size_t size)
-{
-       return os_malloc(size);
-}
-
-void fw_free(void* addr)
-{
-       os_free(addr);
-}
-
-void fw_init()
-{
-       fw_printf("Initializing framework...\n");
-       
-       os_init_os();
-
-       fw_comm_init();
-       fw_pipes_init();
-       fw_sched_init();
-       fw_components_init();
-       fw_build_topo();
-}
index 0b59a79..4bfb73e 100644 (file)
@@ -6,7 +6,11 @@
  * CoBaS uses a publish subscribe based communication pattern. This file
  * contains all the functionality to realize that.
  */
-#include <fw.h>
+#include <fw_comm.h>
+#include <fw_types.h>
+#include <fw_helper.h>
+#include <fw_mem.h>
+#include <fw_debug.h>
 
 #include <topics/admit.h>
 #include <topics/block.h>
@@ -191,5 +195,4 @@ void fw_comm_init(void)
        }
 
        fw_comm_register_global();
-       fw_comm_register_generated();
 }
index 03865d2..b8bd168 100644 (file)
@@ -1,4 +1,7 @@
-#include "fw.h"
+#include <fw_components.h>
+#include <fw_helper.h>
+#include <fw_mem.h>
+#include <fw_debug.h>
 
 /**
  * Holds all the property of necessary to describe a CoBaS component.
@@ -25,11 +28,11 @@ static unsigned int registered_components = 0;
 /**
  * References to all component instances.
  */
-static fw_component_inst_t *components_instances[FW_MAX_COMPONENT_INST];
+fw_component_inst_t *fw_component_instances[FW_MAX_COMPONENT_INST];
 /**
  * The number of component instances.
  */
-static unsigned int instantiated_components = 0;
+unsigned int fw_num_component_instances = 0;
 
 int fw_component_register(component_uuid_t uuid, const char *name, const char *description,
                fw_component_inst_t* (*_new) (inst_uuid_t inst_id, int link_count, fw_pipe_t **links),
@@ -78,26 +81,26 @@ fw_component_inst_t *fw_component_new(component_uuid_t uuid, inst_uuid_t inst_id
                return NULL;
        }
 
-       if (components_instances[inst_id] != NULL) {
+       if (fw_component_instances[inst_id] != NULL) {
                fw_error("There is already an instance with ID %x \n", inst_id);
                return NULL;
        }
 
-       components_instances[inst_id] = components[uuid]._new(inst_id, link_count, links);
+       fw_component_instances[inst_id] = components[uuid]._new(inst_id, link_count, links);
 
-       if (components_instances[inst_id] == NULL) {
+       if (fw_component_instances[inst_id] == NULL) {
                fw_error("Failed to create a new instance of %s(0x%02x) with ID %x.\n", fw_component_name(uuid), uuid, inst_id);
                return NULL;
        }
 
-       instantiated_components++;
+       fw_num_component_instances++;
 
-       return components_instances[inst_id];
+       return fw_component_instances[inst_id];
 }
 
 void fw_component_destroy(fw_component_inst_t *inst)
 {
-       components_instances[inst->inst_id] = NULL;
+       fw_component_instances[inst->inst_id] = NULL;
        components[inst->comp_id]._destroy(inst);
 }
 
@@ -125,7 +128,7 @@ void fw_components_init(void)
        }
 
        for (i=0; i<FW_MAX_COMPONENT_INST; i++) {
-               components_instances[i]= NULL;
+               fw_component_instances[i]= NULL;
        }
 
        for (call=__cobas_components_init_start, i=0; call<__cobas_components_init_end; call++, i++) {
diff --git a/framework/lib/fw_debug.c b/framework/lib/fw_debug.c
deleted file mode 100644 (file)
index d7814c9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <fw.h>
-
-
-
-void __fw_assert(const char *cond, const char *file, int line)
-{
-       //klocation(file, line);
-       fw_printf("%s:%d - Framework assertion failed: %s\n", file, line, cond);
-//     FW_BREAKPOINT;
-}
diff --git a/framework/lib/fw_init.c b/framework/lib/fw_init.c
new file mode 100644 (file)
index 0000000..a6a950a
--- /dev/null
@@ -0,0 +1,23 @@
+#include <fw_init.h>
+#include <fw_comm.h>
+#include <fw_pipe.h>
+#include <fw_sched.h>
+#include <fw_components.h>
+#include <fw_helper.h>
+#include <os.h>
+
+
+extern int fw_build_topo(void);
+
+void fw_init()
+{
+       fw_printf("Initializing framework...\n");
+
+       os_init_os();
+
+       fw_comm_init();
+       fw_pipes_init();
+       fw_sched_init();
+       fw_components_init();
+       fw_build_topo();
+}
index d810f99..a7b4340 100644 (file)
@@ -1,155 +1,6 @@
-#include "fw.h"
-
-void fw_tlist_init(struct fw_tlist *list)
-{
-       list->head = list->tail = NULL;
-}
-
-int fw_tlist_empty(struct fw_tlist *list)
-{
-       return (list->head == NULL);
-}
-
-int fw_tlist_length(struct fw_tlist *list)
-{
-       int i=0;
-       fw_tlist_elem_t *tmp;
-
-       fw_tlist_for_each_entry(tmp,list){
-               i++;
-       }
-               return i;
-}
-
-void __fw_tlist_add(struct fw_tlist_elem *_new,
-                             struct fw_tlist_elem *prev,
-                             struct fw_tlist_elem *next)
-{
-       next->prev = _new;
-       _new->next = next;
-       _new->prev = prev;
-       prev->next = _new;
-}
-
-void fw_tlist_add_tail(struct fw_tlist_elem *_new, struct fw_tlist *list)
-{
-       fw_tlist_elem_t *old_tail = list->tail;
-
-       if(list->head != NULL){
-               old_tail->next = _new;
-               _new->prev = old_tail;
-       }else{
-               list->head = _new;
-               _new->prev = NULL;
-       }
-       _new->next = NULL;
-       list->tail = _new;
-
-}
-
-void fw_tlist_add_first(struct fw_tlist_elem *_new, struct fw_tlist *list)
-{
-       fw_tlist_elem_t *old_head = list->head;
-
-       if(list->head != NULL){
-               old_head->prev = _new;
-               _new->next = old_head;
-       }else{
-               list->tail = _new;
-               _new->next = NULL;
-       }
-       _new->prev = NULL;
-       list->head = _new;
-}
-
-void fw_tlist_add_at_pos(struct fw_tlist_elem *_new, struct fw_tlist *list, int pos)
-{
-       fw_tlist_elem_t *tmp = list->head;
-       if(list->head != NULL){
-               if(pos<fw_tlist_length(list) && pos>=0 ){
-                       while(pos-- > 0){
-                               tmp=tmp->next;
-                       }
-                       __fw_tlist_add(_new, tmp, tmp->next);
-               }else{
-                       fw_tlist_add_tail(_new, list);
-               }
-       }else{
-               fw_tlist_add_first(_new,list);
-       }
-}
-
-void __fw_tlist_del(struct fw_tlist_elem *elem)
-{
-       if(elem == NULL) return;
-
-       if(elem->prev){
-               elem->prev->next = elem->next;
-       }
-       if(elem->next){
-               elem->next->prev = elem->prev;
-       }
-       elem->next = FW_LIST_POISON1;
-       elem->prev = FW_LIST_POISON2;
-}
-
-struct fw_tlist_elem *fw_tlist_pop(struct fw_tlist *list)
-{
-       struct fw_tlist_elem *ret = list->head;
-
-       if(list->head == NULL){
-               return ret;
-       }else if(list->head == list->tail){
-               list->head = list->tail = NULL;
-       }else{
-               list->head = ret->next;
-               list->head->prev = NULL;
-       }
-       ret->next = FW_LIST_POISON1;
-       ret->prev = FW_LIST_POISON2;
-       return ret;
-}
-
-struct fw_task *fw_tlist_entry(struct fw_tlist *list)
-{
-       if(list->head != NULL){
-               return list->head->task;
-       }else{
-               return NULL;
-       }
-}
-
-void fw_tlist_remove(struct fw_tlist_elem *elem, struct fw_tlist *list)
-{
-       //no list, do nothing
-       if(list == NULL) return;
-       //list is empty, do nothing
-       if(list->head == NULL) return;
-       //elem is not on any list, do nothing
-       if((elem->prev == FW_LIST_POISON2) && (elem->next == FW_LIST_POISON1)) return;
-
-       if(list->head == list->tail){
-               if(elem != list->head) return;
-               fw_tlist_init(list);
-               elem->next = FW_LIST_POISON1;
-               elem->prev = FW_LIST_POISON2;
-       }else{
-               if(elem == list->head){
-                       list->head = elem->next;
-                       list->head->prev = NULL;
-                       elem->next = FW_LIST_POISON1;
-                       elem->prev = FW_LIST_POISON2;
-               }else if(elem == list->tail){
-                       list->tail = elem->prev;
-                       list->tail->next = NULL;
-                       elem->next = FW_LIST_POISON1;
-                       elem->prev = FW_LIST_POISON2;
-               }else{
-                       __fw_tlist_del(elem);
-
-               }
-       }
-}
+#include <fw_list.h>
+#include <fw_types.h>
+#include <fw_helper.h>
 
 /*
  *  KERNEL LIST FUNCTIONS
diff --git a/framework/lib/fw_mem.c b/framework/lib/fw_mem.c
new file mode 100644 (file)
index 0000000..3f41c4d
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * @file fw_mem.c
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file implements the OS independent memory management functions for CoBaS.
+ */
+
+#include <fw_mem.h>
+
+#include <os.h>
+
+void *fw_malloc(fw_size_t size)
+{
+       return os_malloc(size);
+}
+
+void fw_free(void* addr)
+{
+       os_free(addr);
+}
index 58ed27d..6026b9a 100644 (file)
@@ -1,13 +1,28 @@
-/*
- * fw_pipe.c
+/**
+ * @file fw_pipe.h
+ * @author Anselm Busse
+ * @date 9 Sep 2015
+ * @brief Implementation of the CoBaS pipe subsystem.
  *
- *  Created on: 06.09.2015
- *      Author: abusse
+ * This is the interface definition for pipes in CoBaS. Pipes are connecting
+ * component instances with each other and are the main means to propagate task
+ * sets and orders inside the framework.
  */
 
-#include <fw.h>
 #include <fw_pipe.h>
-
+#include <fw_pipe_pcb.h>
+#include <fw_limits.h>
+#include <fw_lock.h>
+#include <fw_list.h>
+#include <fw_components.h>
+#include <fw_helper.h>
+#include <fw_mem.h>
+
+
+/**
+ * The pipe subsystem is partially presented as a component to the rest of
+ * the system
+ */
 static fw_component_inst_t fw_pipe_termination;
 
 fw_pipe_t *fw_pipe_alloc(void)
@@ -46,18 +61,42 @@ void fw_pipe_free(fw_pipe_t *pipe)
 
 int fw_pipe_task_init(fw_component_inst_t *self, fw_task_t *task)
 {
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
+
+       // The pipe subsystem does not need the PCB so far.
+       UNUSED(task);
+
        return 0;
 }
 
 void fw_pipe_task_destroy(fw_component_inst_t *self, fw_task_t *task)
 {
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
 
+       // The pipe subsystem does not need the PCB so far.
+       UNUSED(task);
 }
 
+/**
+ * \brief Termination of a pipe.
+ *
+ * If a pipe is the last in the pipeline, information is and cannot be further
+ * forwarded. This function ensures that the end of the pipeline stays clean.
+ * It empties the pipe and frees the last lock.
+ *
+ * @param self Not considered and only for compatibility. Ther is only one pipe
+ * subsystem
+ * @param pipe The pipe that should be terminated.
+ */
 static void fw_pipe_termination_update(fw_component_inst_t *self, fw_pipe_t *pipe)
 {
        fw_task_t *pos, *n;
 
+       // self is not needed here, because we have only one pipe subsystem
+       UNUSED(self);
+
        fw_spin_lock(&pipe->lock);
 
        fw_list_for_each_entry_safe(pos,n,(&pipe->tasks_added),pipe_pcb[pipe->id].added) {
index cbff562..3efb3b7 100644 (file)
@@ -1,10 +1,21 @@
-/*FW
- * SCHED_LIST: IN fw_fw_schedule_in
- * SCHED_LIST: OUT fw_fw_ready_out
- * SCHED_LIST: OUT fw_fw_blocked_out
+/**
+ * @file fw_sched.c
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains the implementation for task management and rescheduling
+ * in CoBaS.
  */
 
-#include <fw.h>
+#include <fw_types.h>
+#include <fw_lock.h>
+#include <fw_sched.h>
+#include <fw_pipe.h>
+#include <fw_comm.h>
+#include <fw_components.h>
+
+#include <fw_debug.h>
+
 
 #include <topics/admit.h>
 #include <topics/block.h>
 #include <topics/relinquish.h>
 #include <topics/unblock.h>
 
+
+/**
+ * The pipe for all available tasks that are ready for scheduling.
+ */
 fw_pipe_t *fw_fw_ready_pipe;
+/**
+ * The pipes that are considered during dispatching.
+ */
 fw_pipe_t **fw_fw_dispatch_pipe;
 
-fw_component_inst_t **fw_fw_dispatch_inst;
-
-char fw_sched_buf[127] = {0};
-FW_DEFINE_SPINLOCK(fw_lock);
-
+/**
+ * \brief Updates the ready pipe when CoBas is notified about a new task.
+ *
+ * @param self NULL as we are the only framework.
+ * @param admit The message containing the new task.
+ */
 static void __fw_admit(fw_component_inst_t *self, fw_admit_msg_t *admit)
 {
        fw_task_t *task = admit->task;
@@ -42,6 +61,12 @@ static void __fw_admit(fw_component_inst_t *self, fw_admit_msg_t *admit)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
+/**
+ * \brief Updates the scheduler subsystem when a task is released by the runtime system.
+ *
+ * @param self NULL as we are the only framework.
+ * @param release The message containing the released task.
+ */
 static void __fw_release(fw_component_inst_t *self, fw_release_msg_t *release)
 {
        fw_task_t *task = release->task;
@@ -53,30 +78,14 @@ static void __fw_release(fw_component_inst_t *self, fw_release_msg_t *release)
        UNUSED(self);
 
        task->state = FW_EXIT;
-
-}
-
-void __fw_schedule(int cpu)
-{
-       struct fw_task *next_task = NULL;
-
-       if (!fw_list_empty(&fw_fw_dispatch_pipe[cpu]->tasks_list)) {
-               next_task = fw_list_first_entry(&fw_fw_dispatch_pipe[cpu]->tasks_list,fw_task_t,pipe_pcb[fw_fw_dispatch_pipe[cpu]->id].list);
-               next_task->state = FW_RUNNING;
-
-               fw_spin_lock(&fw_fw_ready_pipe->lock);
-               fw_list_del(&next_task->pipe_pcb[fw_fw_ready_pipe->id].list);
-               fw_list_add_tail(&next_task->pipe_pcb[fw_fw_ready_pipe->id].removed, &fw_fw_ready_pipe->tasks_removed);
-               fw_spin_unlock(&fw_fw_ready_pipe->lock);
-
-               fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
-
-               //FW_DEBUG_PRINT("__fw_schedule: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(next_task), FW_CPU_ID(), next_task->state, next_task, next_task->real_task);
-       }
-
-       os_dispatch(next_task);
 }
 
+/**
+ * \brief Updates the ready pipe when CoBas is notified about a relinquish task.
+ *
+ * @param self NULL as we are the only framework.
+ * @param relinquish The message containing the relinquish task.
+ */
 static void __fw_relinquish(fw_component_inst_t *self, fw_relinquish_msg_t *relinquish)
 {
        fw_task_t *task = relinquish->task;
@@ -99,6 +108,12 @@ static void __fw_relinquish(fw_component_inst_t *self, fw_relinquish_msg_t *reli
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
+/**
+ * \brief Updates the ready pipe when the framework is notified that a task is blocked.
+ *
+ * @param self NULL as we are the only framework.
+ * @param block The message containing the blocked task
+ */
 static void __fw_block(fw_component_inst_t *self, fw_block_msg_t *block)
 {
        fw_task_t *task = block->task;
@@ -111,6 +126,12 @@ static void __fw_block(fw_component_inst_t *self, fw_block_msg_t *block)
        task->state = FW_BLOCKED;
 }
 
+/**
+ * \brief Updates the ready pipe when the framework is notified about a task unblock.
+ *
+ * @param self NULL as we are the only framework.
+ * @param unblock The message containing the unblocked task.
+ */
 static void __fw_unblock(fw_component_inst_t *self, fw_unblock_msg_t *unblock)
 {
        fw_task_t *task = unblock->task;
@@ -132,6 +153,27 @@ static void __fw_unblock(fw_component_inst_t *self, fw_unblock_msg_t *unblock)
        fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
 }
 
+void fw_schedule(int pe)
+{
+       struct fw_task *next_task = NULL;
+
+       if (!fw_list_empty(&fw_fw_dispatch_pipe[pe]->tasks_list)) {
+               next_task = fw_list_first_entry(&fw_fw_dispatch_pipe[pe]->tasks_list,fw_task_t,pipe_pcb[fw_fw_dispatch_pipe[pe]->id].list);
+               next_task->state = FW_RUNNING;
+
+               fw_spin_lock(&fw_fw_ready_pipe->lock);
+               fw_list_del(&next_task->pipe_pcb[fw_fw_ready_pipe->id].list);
+               fw_list_add_tail(&next_task->pipe_pcb[fw_fw_ready_pipe->id].removed, &fw_fw_ready_pipe->tasks_removed);
+               fw_spin_unlock(&fw_fw_ready_pipe->lock);
+
+               fw_fw_ready_pipe->out->ops.pipe_update(fw_fw_ready_pipe->out, fw_fw_ready_pipe);
+
+               //FW_DEBUG_PRINT("__fw_schedule: %s on CPU(%i) state:%i (%p->%p)\n", FW_TASK_NAME(next_task), FW_CPU_ID(), next_task->state, next_task, next_task->real_task);
+       }
+
+       os_schedule(next_task, pe);
+}
+
 void fw_sched_init(void)
 {
        fw_fw_ready_pipe = fw_pipe_alloc();
@@ -143,9 +185,9 @@ void fw_sched_init(void)
        fw_subscribe(FW_TOPIC_RELEASE, __fw_release, NULL);
 }
 
-struct fw_task* fw_current_task(int cpu)
+fw_task_t* fw_current_task(int pe)
 {
-       return os_current_task(cpu);
+       return os_current_task(pe);
 }
 
 void fw_need_resched(struct fw_task *task)
@@ -165,61 +207,3 @@ void fw_send_ipi(int cpu)
        os_send_ipi(cpu);
 }
 #endif
-
-int fw_task_info(struct fw_task *task, char *buf, int length)
-{
-       int count = 0;
-
-
-       count += snprintf(buf, length, "addr:%p->%p ", task, (void*)task->real_task);
-
-       count += snprintf(buf+count, length-count, "state:");
-
-       switch(task->state) {
-       case FW_RUNNING:
-               count += snprintf(buf+count, length-count, "running");
-               break;
-       case FW_BLOCKED:
-               count += snprintf(buf+count, length-count, "blocked");
-               break;
-       case FW_READY:
-               count += snprintf(buf+count, length-count, "ready");
-               break;
-       default:
-               count += snprintf(buf+count, length-count, "unknown");
-               break;
-       }
-
-       count += snprintf(buf+count, length-count, " name:%s", FW_TASK_NAME(task));
-
-       count += snprintf(buf+count, length-count, "(%d) ", FW_TASK_ID(task));
-
-       count += snprintf(buf+count, length-count, "CPU(%d) ", task->cpu);
-
-       count += snprintf(buf+count, length-count, "td_state:%ld ", FW_TASK_STATE(task));
-
-       count += snprintf(buf+count, length-count, "ts_cpu:%d ", FW_TASK_CPU(task));
-
-       return count;
-}
-
-void fw_tlist_print(struct fw_tlist *list)
-{
-       struct fw_tlist_elem *tmp;
-       int tasks = 0;
-
-       FW_ASSERT_H(list != NULL, "List pointer not set!");
-
-       FW_DEBUG_PRINT("List: ");
-       if (fw_tlist_empty(list)) {
-               FW_DEBUG_PRINT("empty\n");
-               return;
-       }
-       FW_DEBUG_PRINT("\n");
-       fw_tlist_for_each_entry(tmp, list) {
-               fw_task_info(tmp->task, fw_sched_buf, 127);
-               FW_DEBUG_PRINT("\t%s\n", fw_sched_buf);
-               tasks++;
-       }
-       FW_DEBUG_PRINT("\tQueue load: %d\n", tasks);
-}
diff --git a/framework/lib/fw_task.c b/framework/lib/fw_task.c
new file mode 100644 (file)
index 0000000..2a9ef22
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * @file fw_task.h
+ * @author Anselm Busse
+ * @date 25 Jan 2015
+ *
+ * This file contains implementation concerning task handling.
+ */
+
+#include <fw_task.h>
+#include <fw_types.h>
+#include <fw_pipe.h>
+#include <fw_components.h>
+#include <fw_mem.h>
+#include <fw_helper.h>
+
+fw_task_t *fw_task_alloc()
+{
+       fw_task_t *p;
+
+       p = fw_malloc(sizeof(fw_task_t));
+       if (p == NULL) {
+               fw_error("OOM for new task.\n");
+               return NULL;
+       }
+
+       return p;
+}
+
+fw_task_t *fw_task_new(){
+       fw_task_t *p;
+
+       p = fw_task_alloc();
+
+       if (p != NULL) {
+               fw_task_init(p);
+       }
+
+       return p;
+}
+
+void fw_task_init(fw_task_t *task)
+{
+       int i;
+
+       fw_pipe_task_init(NULL, task);
+
+       for(i=0;i<fw_num_component_instances;i++){
+               if (fw_component_instances[i] != NULL)
+                       if (fw_component_instances[i]->ops.task_init != NULL)
+                               fw_component_instances[i]->ops.task_init(fw_component_instances[i],task);
+       }
+}
+
+void fw_task_destroy(fw_task_t *task)
+{
+       int i;
+
+       fw_pipe_task_destroy(NULL, task);
+
+       for(i=0;i<fw_num_component_instances;i++){
+               if (fw_component_instances[i] != NULL)
+                       if (fw_component_instances[i]->ops.task_destroy != NULL)
+                               fw_component_instances[i]->ops.task_destroy(fw_component_instances[i],task);
+       }
+}
index 36b70c6..8040da8 100644 (file)
 
 FW_DEFINE_SPINLOCK(lb_lock);
 
-struct lb_pool_entry {
-       struct lb_pool_entry *next;
-       fw_tlist_elem_t elem;
-};
-
 struct lb_load {
        int tlist_length;
        int tlist_balanced;
index d9bca87..3eca029 100644 (file)
@@ -68,7 +68,7 @@ void os_dispatch(fw_task_t *task)
                return;
        }
 
-       current_process = task->real_task;
+       current_process = task->os_task;
        os_set_current_task(task);
 
        /*
@@ -76,7 +76,7 @@ void os_dispatch(fw_task_t *task)
         * dummy variable that we ignore.  In fact, this happens only when the
         * old process has just exited.
         */
-       asm_switch_context(&((Process*)(__os_current_task->real_task))->stack, old_task ? &((Process*)(old_task->real_task))->stack : &dummy);
+       asm_switch_context(&((Process*)(__os_current_task->os_task))->stack, old_task ? &((Process*)(old_task->os_task))->stack : &dummy);
 }
 
 void os_dispatch_mp(fw_task_t *task, int cpu)
index bfd81fa..e51d53c 100644 (file)
@@ -350,7 +350,7 @@ void schedinit(void)
        td_sched0.fw_task = fwt;
        td_sched0.fw_task->list_elem.task= fwt;
        td_sched0.fw_task->state = FW_RUNNING;
-       td_sched0.fw_task->real_task = &thread0;
+       td_sched0.fw_task->os_task = &thread0;
 
        fw_init();
 }
@@ -666,7 +666,7 @@ void sched_fork_thread(struct thread *td, struct thread *child)
        fwt = malloc((size_t) sizeof(struct fw_task), M_TEMP, M_ZERO|M_NOWAIT);
 
        ts2->fw_task = fwt;
-       ts2->fw_task->real_task = child;
+       ts2->fw_task->os_task = child;
        ts2->fw_task->state = FW_READY;
        ts2->fw_task->cpu = ts->ts_cpu;
        /* So far module_data is uninitialized. Free will only check against Zero. */
index a72b4c7..6aaebb4 100644 (file)
@@ -20,10 +20,10 @@ const char *os_task_info(struct fw_task *task)
                return "<NULL>";
        }
 
-       if (task->real_task == NULL) {
+       if (task->os_task == NULL) {
                return "Invalid Task";
        }
 
 
-       return ((struct thread*)task->real_task)->td_name;
+       return ((struct thread*)task->os_task)->td_name;
 }
index afd4691..08eadd4 100644 (file)
@@ -25,7 +25,7 @@ void os_dispatch(struct fw_task *task)
                next = PCPU_GET(idlethread);
        }
        else {
-               next = task->real_task;
+               next = task->os_task;
        }
 
        TD_SET_RUNNING(next);
index 47e0c59..5e75d64 100644 (file)
@@ -1,12 +1,13 @@
 obj-y += linux_sched.o os.o os_kdb.o os_sched.o os_syscall.o
-obj-y += ../../lib/fw.o \
-                ../../lib/fw_comm.o \
+obj-y += ../../lib/fw_comm.o \
                 ../../lib/fw_components.o \
                 ../../lib/fw_list.o \
+                ../../lib/fw_init.o \
                 ../../lib/fw_irq.o \
+                ../../lib/fw_mem.o \
                 ../../lib/fw_pipe.o \
                 ../../lib/fw_sched.o \
-                ../../lib/fw_debug.o
+                ../../lib/fw_task.o 
 
 obj-y += ../../generated/fw_comm_generated.o
 
index 5f96d93..c404962 100644 (file)
@@ -1,4 +1,40 @@
-#include <fw.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/mmu_context.h>
+#include <linux/completion.h>
+#include <linux/kernel_stat.h>
+#include <linux/blkdev.h>
+#include <linux/syscalls.h>
+#include <linux/kprobes.h>
+
+#include <linux/export.h>
+#include <linux/context_tracking.h>
+#include <linux/kthread.h>
+#include <linux/init_task.h>
+
+#include <asm/switch_to.h>
+#include <asm/tlb.h>
+#include <linux/cgroup.h>
+#include "../workqueue_internal.h"
+#include "../smpboot.h"
+
+#include <linux/sched.h>
+#include <linux/sched/sysctl.h>
+#include <linux/sched/rt.h>
+#include <linux/spinlock.h>
+#include <linux/stop_machine.h>
+#include <linux/list.h>
+#include <linux/delayacct.h>
+
+#include <linux/cpuidle.h>
+#include <linux/cpumask.h>
+
+#include <fw_init.h>
+#include <fw_types.h>
+#include <fw_comm.h>
+#include <fw_sched.h>
+#include <fw_helper.h>
 
 #include <topics/admit.h>
 #include <topics/affinity.h>
@@ -266,7 +302,10 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
 
        __sched_fork(clone_flags, p);
 
-       fw_task_init(&p->fw_task);
+       p->fw_task = fw_task_new();
+
+       if(p->fw_task == NULL)
+               return -1;
 
        /*
         * We mark the process as running here. This guarantees that
@@ -285,9 +324,9 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
        raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
        /* Modsched framework */
-       p->fw_task.state = FW_READY;
-       p->fw_task.real_task = (void*)p;
-       p->fw_task.cpu = task_cpu(p);
+       p->fw_task->state = FW_READY;
+       p->fw_task->os_task = p;
+       p->fw_task->cpu = task_cpu(p);
 
 
 
@@ -344,9 +383,10 @@ void init_idle(struct task_struct *idle, int cpu)
 #endif
 
        /* Modsched framework */
-       idle->fw_task.real_task = (void*)idle;
-       idle->fw_task.state = FW_RUNNING;
-       idle->fw_task.cpu = task_cpu(idle);
+       idle->fw_task = fw_task_new();
+       idle->fw_task->os_task = idle;
+       idle->fw_task->state = FW_RUNNING;
+       idle->fw_task->cpu = task_cpu(idle);
 
        raw_spin_unlock_irqrestore(&rq->lock, flags);
 
@@ -567,7 +607,7 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
        retval = 0;
 
        raw_spin_lock_irqsave(&p->pi_lock, flags);
-       msg.task = &p->fw_task;
+       msg.task = p->fw_task;
        fw_request(FW_TOPIC_AFFINITY,&msg);
        read_mask.bits[0] = msg.mask.bits[0];
        cpumask_and(mask, &read_mask, cpu_online_mask);
@@ -642,7 +682,7 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
 //     cpuset_cpus_allowed(p, cpus_allowed);
 //     cpumask_and(new_mask, in_mask, cpus_allowed);
 
-       msg.task = &p->fw_task;
+       msg.task = p->fw_task;
        msg.mask.bits[0] = in_mask->bits[0];
        fw_notify(FW_TOPIC_AFFINITY, &msg);
 //again:
@@ -1179,8 +1219,8 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
  */
 void activate_task(struct rq *rq, struct task_struct *p, int flags)
 {
-       fw_admit_msg_t admit = {&p->fw_task};
-       fw_unblock_msg_t unblock = {&p->fw_task};
+       fw_admit_msg_t admit = {p->fw_task};
+       fw_unblock_msg_t unblock = {p->fw_task};
 
        if (flags == 0) {
                fw_notify(FW_TOPIC_ADMIT, &admit);
@@ -1330,8 +1370,8 @@ void wake_up_new_task(struct task_struct *p)
        set_task_cpu(p,smp_processor_id());
 #endif
 
-       p->fw_task.real_task = (void*)p;
-       p->fw_task.state = FW_READY;
+       p->fw_task->os_task = p;
+       p->fw_task->state = FW_READY;
 
        rq = __task_rq_lock(p);
        activate_task(rq, p, 0);
@@ -1353,7 +1393,7 @@ static int ttwu_remote(struct task_struct *p, int wake_flags)
        int ret = 0;
 
        rq = __task_rq_lock(p);
-       if((p->fw_task.state == FW_READY) || (p->fw_task.state == FW_RUNNING)){
+       if((p->fw_task->state == FW_READY) || (p->fw_task->state == FW_RUNNING)){
                ttwu_do_wakeup(rq, p, wake_flags);
                ret = 1;
        }
@@ -1392,7 +1432,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
        success = 1; /* we're going to change ->state */
        cpu = task_cpu(p);
 
-       if(((p->fw_task.state == FW_READY)||(p->fw_task.state == FW_RUNNING)) && ttwu_remote(p,wake_flags))
+       if(((p->fw_task->state == FW_READY)||(p->fw_task->state == FW_RUNNING)) && ttwu_remote(p,wake_flags))
                goto stat;
 
 
@@ -1481,7 +1521,7 @@ static void try_to_wake_up_local(struct task_struct *p)
        if (!(p->state & TASK_NORMAL))
                goto out;
 
-       if(!((p->fw_task.state == FW_READY)||(p->fw_task.state == FW_RUNNING)))
+       if(!((p->fw_task->state == FW_READY)||(p->fw_task->state == FW_RUNNING)))
                ttwu_activate(rq, p, ENQUEUE_WAKEUP);
 
        check_preempt_curr(rq, p, 0);
@@ -1646,12 +1686,12 @@ static void /*__sched*/ __schedule(bool preempt)
                        prev->state = TASK_RUNNING;
                }
                else if (prev->state == TASK_DEAD) {
-                       release.task = &prev->fw_task;
+                       release.task = prev->fw_task;
                        fw_notify(FW_TOPIC_RELEASE, &release);
 //                     prev->on_rq = 0;
                }
                else {
-                       block.task = &prev->fw_task;
+                       block.task = prev->fw_task;
                        fw_notify(FW_TOPIC_BLOCK, &block);
 //                     prev->on_rq = 0;
 
@@ -1670,8 +1710,8 @@ static void /*__sched*/ __schedule(bool preempt)
                }
        }
 
-       if ((prev != rq->idle) && ((prev->fw_task.state == FW_READY)||(prev->fw_task.state == FW_RUNNING))) {
-               relinquish.task = &prev->fw_task;
+       if ((prev != rq->idle) && ((prev->fw_task->state == FW_READY)||(prev->fw_task->state == FW_RUNNING))) {
+               relinquish.task = prev->fw_task;
                fw_notify(FW_TOPIC_RELINQUISH, &relinquish);
        }
 
@@ -2038,7 +2078,7 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
         * If we're not on a rq, the next wake-up will ensure we're
         * placed properly.
         */
-       if((p->fw_task.state == FW_READY)||(p->fw_task.state == FW_RUNNING)){
+       if((p->fw_task->state == FW_READY)||(p->fw_task->state == FW_RUNNING)){
                set_task_cpu(p, dest_cpu);
                if (rq_dest->curr == rq_dest->idle)
                        resched_task(rq_dest->curr);
@@ -2230,7 +2270,7 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
                goto out;
 
        dest_cpu = cpumask_any_and(cpu_active_mask, new_mask);
-       if((p->fw_task.state == FW_RUNNING)||(p->fw_task.state == FW_READY)){
+       if((p->fw_task->state == FW_RUNNING)||(p->fw_task->state == FW_READY)){
                struct migration_arg arg = { p, dest_cpu };
                /* Need help from migration thread: drop lock and wait. */
                task_rq_unlock(rq, p, &flags);
@@ -2350,8 +2390,8 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state)
                 * lock now, to be *sure*. If we're wrong, we'll
                 * just go back and repeat.
                 */
-               running = (p->fw_task.state == FW_RUNNING);
-               on_rq = ((p->fw_task.state == FW_READY)||(p->fw_task.state == FW_RUNNING));
+               running = (p->fw_task->state == FW_RUNNING);
+               on_rq = ((p->fw_task->state == FW_READY)||(p->fw_task->state == FW_RUNNING));
                ncsw = 0;
                if (!match_state || p->state == match_state)
                        ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
@@ -2499,9 +2539,9 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
        }
 
        __set_task_cpu(p, new_cpu);
-       p->fw_task.cpu = new_cpu;
+       p->fw_task->cpu = new_cpu;
 
-       msg.task = &p->fw_task;
+       msg.task = p->fw_task;
        msg.mask.bits[0] = p->cpus_allowed.bits[0];
        fw_notify(FW_TOPIC_AFFINITY, &msg);
 
index 02be7b3..b7d0281 100644 (file)
@@ -5,7 +5,8 @@
  *      Author: jkrieg
  */
 
-#include "fw.h"
+#include <os.h>
+#include <fw_types.h>
 
 
 /**
index 91e30bb..0427ca6 100644 (file)
@@ -5,9 +5,7 @@
  *      Author: jkrieg
  */
 
-#include "fw.h"
-
-
+#include <os.h>
 
 int os_task_name(struct fw_task *task, char *buf, fw_size_t size)
 {
index a997663..a40fabd 100644 (file)
@@ -5,17 +5,19 @@
  *      Author: jkrieg
  */
 
-#include "fw.h"
+#include <os.h>
+#include <fw_debug.h>
 
-
-
-void os_dispatch(struct fw_task *task)
+void os_schedule(struct fw_task *task, int pe)
 {
        struct task_struct *prev, *next;
        struct rq *rq;
        int cpu;
 
        cpu = smp_processor_id();
+
+       FW_ASSERT(pe == cpu);
+
        rq = cpu_rq(cpu);
 
        prev = rq->curr;
@@ -40,13 +42,9 @@ void os_dispatch(struct fw_task *task)
        context_switch(rq, prev, next); /* unlocks the rq */
 }
 
-void os_dispatch_mp(struct fw_task *task, int cpu)
-{
-}
-
 struct fw_task *os_current_task(int cpu)
 {
-       return &(current->fw_task);
+       return current->fw_task;
 }
 
 void os_set_current_task(struct fw_task *task)
index 11f161b..6b6df43 100644 (file)
@@ -1,10 +1,10 @@
-#include <fw.h>
+#include <os.h>
 
 #include <linux/syscalls.h>
 
 SYSCALL_DEFINE2(sched_notify, unsigned int, topic, void __user *, info)
 {
-       fw_printf("called CoBaS notification syscall for topic %d.\n", topic);
+       os_printf("called CoBaS notification syscall for topic %d.\n", topic);
 
        return 0;
 }
index f7cf0a3..b544ddd 100644 (file)
@@ -15,18 +15,18 @@ struct task_struct{
 
 int fw_get_state(struct fw_task *task)
 {
-       struct task_struct *ptr = task->real_task;
+       struct task_struct *ptr = task->os_task;
        return ptr->state;
 }
 
 int fw_get_pid(struct fw_task *task)
 {
-       struct task_struct *ptr = task->real_task;
+       struct task_struct *ptr = task->os_task;
        return ptr->pid;
 }
 
 int fw_get_flags(struct fw_task *task)
 {
-       struct task_struct *ptr = task->real_task;
+       struct task_struct *ptr = task->os_task;
        return ptr->flags;
 }
index 502b33a..2341790 100644 (file)
@@ -62,7 +62,7 @@ void schedulefw(struct fw_task *task)
        printfw("scheduled task %d\n", fw_get_pid(task));
        tc *curr;
        fw_list_for_each_entry(curr, &head->list, list){
-               if(curr->task == task->real_task){
+               if(curr->task == task->os_task){
                        currtc = curr; 
                }
        }