diff options
author | Christian Cunningham <cc@localhost> | 2022-02-13 13:22:43 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-02-13 13:23:01 -0700 |
commit | 921398936d989aef06be8d869d9162e3d9b294b3 (patch) | |
tree | 62e1c575a2df812bfd2c5a7edaf13ed0528d1f4d /src | |
parent | 5643e3587507f3351a2ebeb44a5d95d13470741d (diff) |
Output the count of the task stacks
Diffstat (limited to 'src')
-rw-r--r-- | src/exceptions/svc.S | 4 | ||||
-rw-r--r-- | src/globals.c | 1 | ||||
-rw-r--r-- | src/sys/schedule.c | 2 | ||||
-rw-r--r-- | src/tests/test.c | 18 | ||||
-rw-r--r-- | src/util/status.c | 4 |
5 files changed, 15 insertions, 14 deletions
diff --git a/src/exceptions/svc.S b/src/exceptions/svc.S index bebc417..dc1a351 100644 --- a/src/exceptions/svc.S +++ b/src/exceptions/svc.S @@ -45,6 +45,10 @@ svc_000003: // Clean task stack // Free the thread after freeing the stack mov r0, r2 bl kfree + ldr r3, =sched_stack_count + ldr r2, [r3] + sub r2, #1 + str r2, [r3] b svc_exit svc_000004: // Lock Mutex (usr_r0 = struct Mutex*) ldr r3, =scheduler diff --git a/src/globals.c b/src/globals.c index 1510f36..c596309 100644 --- a/src/globals.c +++ b/src/globals.c @@ -13,6 +13,7 @@ char* os_info_v = VERSION; __attribute__((section(".bss.kmem"))) unsigned char kmem_begin[0x2000000]; __attribute__((section(".bss"))) unsigned char kmem_lookup[0xD000]; __attribute__((section(".bss"))) unsigned long nextpid; +__attribute__((section(".bss"))) unsigned long sched_stack_count; __attribute__((section(".bss"))) unsigned long stimel; __attribute__((section(".bss"))) unsigned long stimeh; __attribute__((section(".bss"))) struct Drawer g_Drawer; diff --git a/src/sys/schedule.c b/src/sys/schedule.c index 5c7a546..1643670 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -33,6 +33,7 @@ void init_scheduler(void) trb += 1; } } + sched_stack_count = 0; // Initialize nextpid nextpid = FIRST_AVAIL_PID; } @@ -84,6 +85,7 @@ void add_thread(void* pc, void* arg, unsigned char priority) *(unsigned long**)argp = (unsigned long*)cleanup; // Set lr to the cleanup function thread->sp = (void*)argp; thread->status = THREAD_READY; + sched_stack_count++; } else { thread->sp_base = r.idx; thread->sp = r.sp; diff --git a/src/tests/test.c b/src/tests/test.c index c4abb3e..8b01706 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -29,11 +29,10 @@ void test_entry(void) dt += tf - ti; DRAW64(34, 19, dt/64); DRAW64(34+17, 19, dt%64); - btest(); + add_thread(btest, 0, 4); } static struct Mutex testm = {.addr = 0, .pid = 0}; -static int testi = 0; void ctest1(void) { @@ -59,16 +58,7 @@ void ctest3(void) void btest(void) { - if (testi % 3 == 0) { - testi++; - add_thread(ctest1, 0, 1); - } - else if (testi % 3 == 1) { - testi++; - add_thread(ctest2, 0, 0); - } - else if (testi % 3 == 2) { - testi++; - add_thread(ctest3, 0, 1); - } + add_thread(ctest1, 0, 1); + add_thread(ctest2, 0, 2); + add_thread(ctest3, 0, 3); } diff --git a/src/util/status.c b/src/util/status.c index 5672a8c..0e93102 100644 --- a/src/util/status.c +++ b/src/util/status.c @@ -137,6 +137,10 @@ void status(void) write_char(&g_Drawer, '\n'); write_10(&g_Drawer, ((unsigned long)tval)/1000000); + g_Drawer.x = 0; + g_Drawer.y = 7; + write_string(&g_Drawer, "Task Stack #"); + write_hex32(&g_Drawer, sched_stack_count); g_Drawer.x = x; g_Drawer.y = y; |