diff options
author | Christian Cunningham <cc@localhost> | 2022-01-06 23:48:03 -0800 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-01-06 23:48:03 -0800 |
commit | 6faa08e0a5cb7b36f34c0d0527bb3bbc21aa4d82 (patch) | |
tree | 44df7e63a11c68af9a42565e2d474c78f4b03946 /src/sys/schedule.S | |
parent | aa8d179b2df2ce031a84172a70be88697dfda7c4 (diff) |
Update Thread Flags on Switch
Diffstat (limited to 'src/sys/schedule.S')
-rw-r--r-- | src/sys/schedule.S | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/sys/schedule.S b/src/sys/schedule.S index 18130d0..302c4d8 100644 --- a/src/sys/schedule.S +++ b/src/sys/schedule.S @@ -1,10 +1,9 @@ .section .text .globl schedule +// TODO: Implement Scheduler for IRQ + // Implemented the scheduler in Assembly since the C defined was messing around with the program stacks // This way, I can be confident that the stacks will be unchanged -// -// TODO: Mark threads as READY and RUNNING -// schedule: ldr r3, =scheduler // r3 = struct Scheduler* @@ -38,12 +37,17 @@ schedule.current_thread_exists: // Next is not the same as the current // Preserve stack of current ldr r2, [r1, #0x8] // struct Thread* current + mov r1, #0 // THREAD_READY + strh r1, [r2, #0x0e] str sp, [r2, #0x4] // void* stack // Preserve stack // Preserve program counter of current str lr, [r2, #0x0] // void* thread // Preserve pc ldr r2, [r0, #0x8] // struct Thread* next // Set new stack pointer ldr sp, [r2, #0x4] + // Set the thread as running + mov r1, #1 // THREAD_RUNNING + strh r1, [r2, #0x0e] // unsigned short status add r2, r2, #0x18 // Set new running thread str r0, [r3, #0x0] // struct LL* next_thread_ll // Set new running thread @@ -71,6 +75,9 @@ schedule.dont_overwrite_sys_stack: ldr sp, [r1, #0x4] // void* stack // Store the running thread ll entry str r0, [r3, #0x0] // struct LL* rthread_ll + ldr r2, [r0, #0x8] // struct Thread* thread + mov r0, #1 // THREAD_RUNNING + strh r0, [r2, #0x0e] // Set context add r1, r1, #0x18 // struct cpu_context* str r1, [r3, #0x4] // store to scheduler.ctx |