aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpu/irq.c4
-rw-r--r--src/sys/schedule.S11
-rw-r--r--src/sys/schedule.c38
-rw-r--r--src/tests/test.c26
4 files changed, 21 insertions, 58 deletions
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index 51bc7f2..65300af 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -60,7 +60,7 @@ void c_irq_handler(void)
static char timer_lock = 0;
if (!timer_lock) {
timer_lock = 1;
- //add_thread(test_entry, 0, 2);
+ add_thread(test_entry, 0, 2);
timer_lock = 0;
}
*nexttime = *timer_chi + 30000000;
@@ -103,6 +103,6 @@ void handle_data(unsigned char data)
} else if (data == 0x61) {
add_thread(uart_scheduler, 0, 2);
} else if (data == 0x62) {
- add_thread(test_entry, 0, 2);
+ //add_thread(test_entry, 0, 2);
}
}
diff --git a/src/sys/schedule.S b/src/sys/schedule.S
index 903e967..6b3d3e1 100644
--- a/src/sys/schedule.S
+++ b/src/sys/schedule.S
@@ -27,17 +27,6 @@ schedule:
.globl cleanup
cleanup:
bl c_cleanup
-// // roffset++
-// bl get_rthread_roffset
-// ldr r1, [r0, #0]
-// add r1, #1
-// cmp r1, #0x100 /* TQUEUE_MAX */
-// blo 1f
-// mov r1, #0
-//1:
-// str r1, [r0, #0]
-// // Free thread in table
-// svc #3
// usrloop -> rthread
ldr r3, =scheduler
ldr r2, =usrloopthread
diff --git a/src/sys/schedule.c b/src/sys/schedule.c
index 3050e6e..287091c 100644
--- a/src/sys/schedule.c
+++ b/src/sys/schedule.c
@@ -270,68 +270,42 @@ void sched_mutex_resurrect(void* m)
{
// Look through each priority
for (int p = 0; p < PRIORITIES; p++) {
- /// struct ThreadRotBuffer* trbm = &scheduler.thread_queues[p].mwait;
struct ThreadQueue* tmq = &scheduler.mwait[p];
- /// unsigned long roffset = trbm->roffset;
struct ThreadEntryIterator iter;
iter = tmq->read;
- /// // Look through the lock wait queue
- /// while (roffset != trbm->woffset) {
+ // Look through the lock wait queue
while (iter.entry != tmq->write.entry) {
- /// // Check if the thread is waiting for the released mutex
- /// if (trbm->queue[roffset]->mptr == m) {
+ // Check if the thread is waiting for the released mutex
if (iter.entry->thread->mptr == m) {
- /// // Ressurect the thread
- /// trbm->queue[roffset]->mptr = 0;
+ // Ressurect the thread
iter.entry->thread->mptr = 0;
- /// struct ThreadRotBuffer* trb = &scheduler.thread_queues[trbm->queue[roffset]->priority].ready;
- /// trb->queue[trb->woffset++] = trbm->queue[roffset];
scheduler.ready[iter.entry->thread->priority].write.entry->thread = iter.entry->thread;
- /// trb->woffset %= TQUEUE_MAX;
scheduler.ready[iter.entry->thread->priority].write.entry = scheduler.ready[iter.entry->thread->priority].write.entry->next;
- /// // Move the read pointer ahead
+ // Move the read pointer ahead
if (iter.entry == tmq->read.entry)
tmq->read.entry = tmq->read.entry->next;
iter.entry->prev->next = iter.entry->next;
iter.entry->next->prev = iter.entry->prev;
tmq->write.entry->next->prev = iter.entry;
tmq->write.entry->next = iter.entry;
- /// struct Thread* rthread = scheduler.rthread;
struct Thread* rthread = scheduler.rthread;
- /// // Move the current thread to its old priority if it was promoted earlier
- /// if (rthread->old_priority != 0xFF) {
+ // Move the current thread to its old priority if it was promoted earlier
if (rthread->old_priority != 0xFF) {
- /// struct ThreadRotBuffer* rtrb = &scheduler.thread_queues[rthread->priority].ready;
struct ThreadQueue* cur_trq = &scheduler.ready[rthread->priority];
- /// struct ThreadRotBuffer* ntrb = &scheduler.thread_queues[rthread->old_priority].ready;
struct ThreadQueue* old_trq = &scheduler.ready[rthread->old_priority];
// Prune from the current ready queue
- /// rtrb->roffset++;
- /// rtrb->roffset %= TQUEUE_MAX;
cur_trq->read.entry->thread = 0;
cur_trq->read.entry = cur_trq->read.entry->next;
// Prepend to original ready queue
- /// if (ntrb->roffset == 0)
- /// ntrb->roffset = TQUEUE_MAX-1;
- /// else
- /// ntrb->roffset--;
- /// ntrb->queue[ntrb->roffset] = rthread;
old_trq->read.entry = old_trq->read.entry->prev;
old_trq->read.entry->thread = rthread;
- /// rthread->priority = rthread->old_priority;
- /// rthread->old_priority = -1;
+ // Reset Priority
rthread->priority = rthread->old_priority;
rthread->old_priority = -1;
- /// }
}
- /// return;
return;
- /// }
}
- /// roffset++;
- /// roffset %= TQUEUE_MAX;
iter.entry = iter.entry->next;
- /// }
}
}
}
diff --git a/src/tests/test.c b/src/tests/test.c
index 2a5a100..7f18627 100644
--- a/src/tests/test.c
+++ b/src/tests/test.c
@@ -1,5 +1,5 @@
#include <cpu.h>
-#include <drivers/uart.h>
+//#include <drivers/uart.h>
#include <graphics/lfb.h>
#include <lib/kmem.h>
#include <sys/core.h>
@@ -47,48 +47,48 @@ void ctest4(void);
void ctest1(void)
{
draw_cletter(x++, y+2, 'S', 0xFF0000);
- uart_string("1 Started\n");
+ //uart_string("1 Started\n");
draw_cletter(x++, y+2, 'L', 0xFF0000);
- uart_string("1 Locking\n");
+ //uart_string("1 Locking\n");
lock(&testm);
add_thread(ctest3, 0, 2);
draw_cletter(x++, y+2, 'U', 0xFF0000);
- uart_string("1 Unlocking\n");
+ //uart_string("1 Unlocking\n");
unlock(&testm);
draw_cletter(x++, y+2, 'F', 0xFF0000);
- uart_string("1 Finished\n");
+ //uart_string("1 Finished\n");
}
void ctest2(void)
{
draw_cletter(x++, y+0, 'S', 0x0000FF);
- uart_string("2 Started\n");
+ //uart_string("2 Started\n");
add_thread(ctest4, 0, 3);
draw_cletter(x++, y+0, 'L', 0x0000FF);
- uart_string("2 Locking\n");
+ //uart_string("2 Locking\n");
lock(&testm);
draw_cletter(x++, y+0, 'U', 0x0000FF);
- uart_string("2 Unlocking\n");
+ //uart_string("2 Unlocking\n");
unlock(&testm);
draw_cletter(x++, y+0, 'F', 0x0000FF);
- uart_string("2 Finished\n");
+ //uart_string("2 Finished\n");
}
void ctest3(void)
{
draw_cletter(x++, y+1, 'S', 0x00FF00);
- uart_string("3 Started\n");
+ //uart_string("3 Started\n");
add_thread(ctest2, 0, 1);
draw_cletter(x++, y+1, 'F', 0x00FF00);
- uart_string("3 Finished\n");
+ //uart_string("3 Finished\n");
}
void ctest4(void)
{
draw_cletter(x++, y+2, 'S', 0xAFAF00);
- uart_string("4 Started\n");
+ //uart_string("4 Started\n");
draw_cletter(x++, y+2, 'F', 0xAFAF00);
- uart_string("4 Finished\n");
+ //uart_string("4 Finished\n");
}
void btest(void)