user_thread #9

Merged
mathieu merged 12 commits from user_thread into master 2024-02-28 20:24:14 +01:00
2 changed files with 6 additions and 5 deletions
Showing only changes of commit dc4c465e94 - Show all commits

View File

@ -53,10 +53,12 @@ void print_handler(struct cpu_state *frame, ulong intr)
void pagefault_handler(struct cpu_state *frame, ulong intr) void pagefault_handler(struct cpu_state *frame, ulong intr)
{ {
// PAGE_FAULT is a interrupt with an error code (see exception_wrapper.S)
uint32_t error_code = cpu_context_get_EX_err(frame);
struct thread *current = getCurrentThread(); struct thread *current = getCurrentThread();
assert(frame == current->cpuState);
if (cpu_context_is_in_user_mode(current->cpuState)) { if (cpu_context_is_in_user_mode(current->cpuState)) {
assert(frame == current->cpuState); // pagefault in kernel not supported ATM
struct uAddrSpace *as = processGetAddrSpace(current->process); struct uAddrSpace *as = processGetAddrSpace(current->process);
vaddr_t faultAddr = cpu_context_get_EX_faulting_vaddr(frame); vaddr_t faultAddr = cpu_context_get_EX_faulting_vaddr(frame);
@ -70,8 +72,6 @@ void pagefault_handler(struct cpu_state *frame, ulong intr)
if (!uAddrSpaceHeapCheckNAlloc(as, faultAddr)) if (!uAddrSpaceHeapCheckNAlloc(as, faultAddr))
goto release_context; goto release_context;
// PAGE_FAULT is a interrupt with an error code (see exception_wrapper.S)
uint32_t error_code = cpu_context_get_EX_err(frame);
int ret = uAddrSpaceSolvePageFault(as, faultAddr, error_code & 0x2); int ret = uAddrSpaceSolvePageFault(as, faultAddr, error_code & 0x2);
if (!ret) if (!ret)

View File

@ -165,8 +165,9 @@ void threadDelete(struct thread *thread)
} }
if (thread->squattedContext) { if (thread->squattedContext) {
threadChangeCurrentContext(NULL); mmuContextUnref(thread->squattedContext);
} }
if (thread->process) if (thread->process)
processRemoveThread(thread); processRemoveThread(thread);