aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-14 12:56:22 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-14 12:56:22 +0100
commitdabd2355f355abd7d1d58641f6cc496adb1482d1 (patch)
tree48f674f68b5ec2314d4dd7735af0db0af3408c49 /src/kernel/core
parent151edb44eea9bf25ec466133e9dbef87bd6b1372 (diff)
downloadkogata-dabd2355f355abd7d1d58641f6cc496adb1482d1.tar.gz
kogata-dabd2355f355abd7d1d58641f6cc496adb1482d1.zip
Add mutexes everywhere ; spam debug log (sorry)
Diffstat (limited to 'src/kernel/core')
-rw-r--r--src/kernel/core/paging.c5
-rw-r--r--src/kernel/core/sys.c3
-rw-r--r--src/kernel/core/thread.c26
3 files changed, 18 insertions, 16 deletions
diff --git a/src/kernel/core/paging.c b/src/kernel/core/paging.c
index f7ebf9c..6233443 100644
--- a/src/kernel/core/paging.c
+++ b/src/kernel/core/paging.c
@@ -58,9 +58,10 @@ void page_fault_handler(registers_t *regs) {
current_thread->user_ex_handler(regs);
} else {
if (pd->user_pfh == 0) {
- dbg_printf("Error: usermode page fault on PD with no user PFH.\n");
+ dbg_printf("Error: usermode page fault (0x%p) on PD with no user PFH.\n", vaddr);
dbg_printf("PD: 0x%p, kernel PD: 0x%p\n", get_current_pagedir(), get_kernel_pagedir());
- PANIC("Un-handlable usermode PF.\n");
+ dbg_dump_registers(regs);
+ PANIC("Un-handlable usermode PF.");
}
ASSERT(pd->user_pfh != 0);
pd->user_pfh(pd->user_pfh_data, regs, vaddr);
diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c
index 290fdfa..333cb58 100644
--- a/src/kernel/core/sys.c
+++ b/src/kernel/core/sys.c
@@ -71,7 +71,7 @@ void load_kernel_symbol_map(char* text, size_t len) {
void kernel_stacktrace(uint32_t ebp, uint32_t eip) {
int i = 0;
- while (ebp >= K_HIGHHALF_ADDR && eip >= K_HIGHHALF_ADDR) {
+ while (ebp >= K_HIGHHALF_ADDR) {
char* sym = 0;
if (kernel_symbol_map != 0) sym = btree_lower(kernel_symbol_map, (void*)eip);
@@ -84,6 +84,7 @@ void kernel_stacktrace(uint32_t ebp, uint32_t eip) {
dbg_printf("| ...");
break;
}
+ if (eip == 0) break;
}
}
diff --git a/src/kernel/core/thread.c b/src/kernel/core/thread.c
index 53b3e70..c4d4f93 100644
--- a/src/kernel/core/thread.c
+++ b/src/kernel/core/thread.c
@@ -120,7 +120,7 @@ void run_scheduler() {
// At this point, interrupts are disabled
// This function is expected NEVER TO RETURN
- /*thread_t *prev_thread = current_thread;*/
+ thread_t *prev_thread = current_thread;
if (current_thread != 0 && current_thread->state == T_STATE_RUNNING) {
current_thread->last_ran = get_kernel_time();
@@ -129,7 +129,7 @@ void run_scheduler() {
}
current_thread = dequeue_thread();
- /*if (current_thread != prev_thread) dbg_printf("[0x%p]\n", current_thread);*/
+ if (current_thread != prev_thread) dbg_printf("[0x%p]\n", current_thread);
if (current_thread != 0) {
thread_t *ptr = current_thread;
@@ -345,19 +345,19 @@ void usleep(int usecs) {
if (ok) wait_on(current_thread);
}
-void exit() {
- void exit_cleanup_task(void* v) {
- thread_t *t = (thread_t*)v;
-
- if (t->proc == 0) {
- // stand alone thread, can be deleted safely
- delete_thread(t);
- } else {
- // call specific routine from process code
- process_thread_exited(t);
- }
+void exit_cleanup_task(void* v) {
+ thread_t *t = (thread_t*)v;
+
+ if (t->proc == 0) {
+ // stand alone thread, can be deleted safely
+ delete_thread(t);
+ } else {
+ // call specific routine from process code
+ process_thread_exited(t);
}
+}
+void exit() {
int st = enter_critical(CL_NOSWITCH);
// the critical section here does not guarantee that worker_push will return immediately
// (it may switch before adding the delete_thread task), but once the task is added