aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-06 23:58:41 -0800
committerChristian Cunningham <cc@localhost>2022-01-06 23:58:41 -0800
commit6d4d2fe7fc4a0d2c70b64d9c232ef2758dd8bf80 (patch)
tree6f884da81190793c1dbf1a6a47ecc6bd43b06a65 /src
parent6faa08e0a5cb7b36f34c0d0527bb3bbc21aa4d82 (diff)
Fix memory leak
Diffstat (limited to 'src')
-rw-r--r--src/sys/core.c10
-rw-r--r--src/sys/schedule.c7
2 files changed, 8 insertions, 9 deletions
diff --git a/src/sys/core.c b/src/sys/core.c
index 384add5..e590e5c 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -59,11 +59,10 @@ void sysinit(void)
add_thread(testlocal, 0);
add_thread(testlocal, 1);
add_thread(testlocal, 3);
- add_thread(testlocal, 0);
- add_thread(testlocal, 5);
- add_thread(testlocal, 8);
//delay(0x20000000);
schedule();
+ heap_info();
+ sched_info();
}
struct Mutex testm = {.addr = (void*)0xDEADBEEF, .pid = NULL_PID};
@@ -82,6 +81,7 @@ void testlocal1(void)
uart_10(a);
uart_string(" Done!\n");
}
+
void testlocal(void)
{
struct Thread* t = scheduler.rthread_ll->data;
@@ -91,9 +91,7 @@ void testlocal(void)
uart_10(t->data.priority);
uart_string(" ...\n");
//delay(0x80000000);
- if (t->data.pid == 6) {
- add_thread(testlocal, 0);
- } else if (t->data.pid == 5) {
+ if (t->data.pid == 5) {
add_thread(testlocal1, 1);
schedule();
}
diff --git a/src/sys/schedule.c b/src/sys/schedule.c
index 7dc2205..ac5b3e2 100644
--- a/src/sys/schedule.c
+++ b/src/sys/schedule.c
@@ -139,9 +139,9 @@ void cleanup(void)
if (scheduler.rthread_ll != 0) {
// Mark the thread as finished
struct Thread* t = scheduler.rthread_ll->data;
- uart_string("Cleaning up thread ");
- uart_10(t->data.pid);
- uart_char('\n');
+ //uart_string("Cleaning up thread ");
+ //uart_10(t->data.pid);
+ //uart_char('\n');
t->data.status = THREAD_FINISHED;
// Mark the stack space as free
unsigned long sidx = (unsigned long)(heap_end() - t->stack_base)/STACK_SIZE;
@@ -152,6 +152,7 @@ void cleanup(void)
struct LL* next = ll->next;
prev->next = ll->next;
next->prev = ll->prev;
+ free(ll->data);
free(ll);
scheduler.rthread_ll = 0;
}