aboutsummaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/core.c7
-rw-r--r--src/sys/schedule.c83
-rw-r--r--src/sys/schedule.flat.c32
-rw-r--r--src/sys/schedule.h35
-rw-r--r--src/sys/schedule.ll.c13
-rw-r--r--src/sys/schedule.q.c49
6 files changed, 6 insertions, 213 deletions
diff --git a/src/sys/core.c b/src/sys/core.c
index fbe0536..8d37a88 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -8,7 +8,6 @@
#include "../lib/strings.h"
#include "../sys/core.h"
#include "../sys/power.h"
-#include "../sys/schedule.h"
#include "../sys/timer.h"
#include "../util/mutex.h"
#include "../util/status.h"
@@ -51,4 +50,10 @@ void sysinit(void)
enablefiq();
// Start Scheduler
+ unsigned long count1 = -5;
+ struct Mutex* m = create_mutex(&count1);
+ if (lock_mutex(m, SYS_PID) == 0) {
+ uart_hex(*(unsigned long*)m->addr);
+ release_mutex(m, SYS_PID);
+ }
}
diff --git a/src/sys/schedule.c b/src/sys/schedule.c
deleted file mode 100644
index 8cf2780..0000000
--- a/src/sys/schedule.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "../sys/schedule.h"
-#include "../lib/ll.h"
-#include "../lib/q.h"
-
-#ifdef IGNORE
-#ifdef FLAT
-static struct Task* task_list[256];
-
-static struct Scheduler scheduler = {
- .tasks = task_list,
-};
-
-static unsigned int ntask_i = 0;
-
-void add_task(struct Task* t)
-{
- scheduler.tasks[ntask_i] = t;
- ntask_i += 1;
- if (ntask_i > 256) {
- ntask_i = 0;
- }
-}
-
-unsigned int get_task_length(void)
-{
- return ntask_i;
-}
-
-void execute_task(void)
-{
- if (scheduler.tasks[ntask_i-1] != 0)
- scheduler.tasks[ntask_i-1]->task();
-}
-#elseif LL
-static struct LL bl = {
- .prev = 0,
- .next = 0,
-};
-static struct Scheduler scheduler = {
- .tasks = &bl,
-};
-#else
-static struct Q_base bq = {
- .next = 0,
- .last = 0,
-};
-static struct Scheduler scheduler = {
- .tasks = &bq,
-};
-
-void add_task(struct Task* t)
-{
- pushq(scheduler.tasks, t);
-}
-
-unsigned int get_task_length(void)
-{
- unsigned int length = 0;
- if (scheduler.tasks->last == 0)
- return length;
- else if (scheduler.tasks->next == scheduler.tasks->last)
- return 1;
- else {
- struct Q* q = scheduler.tasks->next;
- length += 1;
- while (q->next != 0) {
- q = q->next;
- length += 1;
- }
- return length;
- }
-}
-
-void execute_task(void)
-{
- if (scheduler.tasks->last != 0) {
- struct Task* tsk = (struct Task*)scheduler.tasks->next->data;
- (tsk->task)();
- popq(scheduler.tasks);
- }
-}
-#endif
-#endif
diff --git a/src/sys/schedule.flat.c b/src/sys/schedule.flat.c
deleted file mode 100644
index 6eb0d14..0000000
--- a/src/sys/schedule.flat.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifdef FLAT
-
-#include "../sys/schedule.h"
-static struct Task* task_list[256];
-
-static struct Scheduler scheduler = {
- .tasks = task_list,
-};
-
-static unsigned int ntask_i = 0;
-
-void add_task(struct Task* t)
-{
- scheduler.tasks[ntask_i] = t;
- ntask_i += 1;
- if (ntask_i > 256) {
- ntask_i = 0;
- }
-}
-
-unsigned int get_task_length(void)
-{
- return ntask_i;
-}
-
-void execute_task(void)
-{
- if (scheduler.tasks[ntask_i-1] != 0)
- scheduler.tasks[ntask_i-1]->task();
-}
-
-#endif
diff --git a/src/sys/schedule.h b/src/sys/schedule.h
deleted file mode 100644
index c8e938d..0000000
--- a/src/sys/schedule.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef SYS_SCHEDULE_H
-#define SYS_SCHEDULE_H
-
-#define STACK_SIZE 0x1000
-struct TaskMemory {
- unsigned long reg[16];
- unsigned char stack[STACK_SIZE];
-};
-
-struct Task {
- unsigned char priority;
- void (*task)(void);
-};
-
-#ifdef FLAT
-struct Scheduler {
- struct Task** tasks;
-};
-#elseif LL
-#include "../lib/ll.h"
-struct Scheduler {
- struct LL* tasks;
-};
-#else
-#include "../lib/q.h"
-struct Scheduler {
- struct Q_base* tasks;
-};
-#endif
-
-void add_fxn(void (*task)(void), unsigned char priority);
-unsigned int get_task_length(void);
-void execute_task(void);
-
-#endif
diff --git a/src/sys/schedule.ll.c b/src/sys/schedule.ll.c
deleted file mode 100644
index d9ab954..0000000
--- a/src/sys/schedule.ll.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifdef LL
-
-#include "../sys/schedule.h"
-#include "../lib/ll.h"
-static struct LL bl = {
- .prev = 0,
- .next = 0,
-};
-static struct Scheduler scheduler = {
- .tasks = &bl,
-};
-
-#endif
diff --git a/src/sys/schedule.q.c b/src/sys/schedule.q.c
deleted file mode 100644
index 88488da..0000000
--- a/src/sys/schedule.q.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#if !(defined(LL) || defined(FLAT))
-#include "../sys/schedule.h"
-#include "../lib/q.h"
-#include "../lib/mem.h"
-
-static struct Q_base bq = {
- .next = 0,
- .last = 0,
-};
-static struct Scheduler scheduler = {
- .tasks = &bq,
-};
-
-void add_fxn(void (*task)(void), unsigned char priority)
-{
- struct Task* t = (struct Task*)malloc(sizeof(struct Task));
- t->priority = priority;
- t->task = task;
- pushq(scheduler.tasks, t);
-}
-
-unsigned int get_task_length(void)
-{
- unsigned int length = 0;
- if (scheduler.tasks->last == 0)
- return length;
- else if (scheduler.tasks->next == scheduler.tasks->last)
- return 1;
- else {
- struct Q* q = scheduler.tasks->next;
- length += 1;
- while (q->next != 0) {
- q = q->next;
- length += 1;
- }
- return length;
- }
-}
-
-void execute_task(void)
-{
- if (scheduler.tasks->last != 0) {
- struct Task* tsk = (struct Task*)scheduler.tasks->next->data;
- (tsk->task)();
- popq(scheduler.tasks);
- }
-}
-
-#endif