aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-06 16:02:43 -0800
committerChristian Cunningham <cc@localhost>2022-01-06 16:02:43 -0800
commit159ba190d626f049512c3ebda70772c03e6737a7 (patch)
treef6479695fe328d3770cf8ac5b836ffccb908a6a7 /include
parenta61201b8047ebe278cfb281723a4bf6c82556472 (diff)
Scheduling
Diffstat (limited to 'include')
-rw-r--r--include/sys/schedule.h44
1 files changed, 2 insertions, 42 deletions
diff --git a/include/sys/schedule.h b/include/sys/schedule.h
index cced851..38c6632 100644
--- a/include/sys/schedule.h
+++ b/include/sys/schedule.h
@@ -19,6 +19,7 @@ struct ThreadData {
void* mutex_waiting;
unsigned long pid;
unsigned char priority;
+ unsigned char preempt_count;
};
struct Thread {
@@ -44,29 +45,9 @@ extern struct Scheduler scheduler;
void init_scheduler(void);
void add_thread(void (*thread_fxn)(void), unsigned char priority);
void schedule(void);
+void schedule_irq(void);
void remove_running_thread(void);
-static inline void preserveregs(struct Thread* thread)
-{
- // Preserve current stack pointer
- void* sp = getsp();
- // Get current mode
- unsigned long mode = getmode();
- // Set supervisor mode - "User mode"
- setsvc();
- void* ssp = getsp();
- // Move stack to reserved register area
- setsp(thread->stack_base - 0x1000 + 16*4);
- // Push registers to the stack
- asm volatile ("push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}");
- // Restore stack to previous
- setsp(ssp);
- // Restore mode
- setmode(mode);
- // Restore current stack pointer
- setsp(sp);
-}
-
static inline void preservestack(struct Thread* thread)
{
// Get current mode
@@ -80,27 +61,6 @@ static inline void preservestack(struct Thread* thread)
setmode(mode);
}
-static inline void restoreregs(struct Thread* thread)
-{
- // Preserve current stack pointer
- void* sp = getsp();
- // Get current mode
- unsigned long mode = getmode();
- // Set supervisor mode - "User mode"
- setsvc();
- void* ssp = getsp();
- // Move stack to reserved register area
- setsp(thread->stack_base - 0x1000 + 16*4 - 14*4);
- // Restore registers on the stack
- asm volatile ("pop {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}");
- // Restore stack to previous
- setsp(ssp);
- // Restore mode
- setmode(mode);
- // Restore current stack pointer
- setsp(sp);
-}
-
static inline void restorestack(struct Thread* thread)
{
// Get current mode