/* * Exit system call. * The interrupted user process is terminated. * Params: * state->ebx - process exit code * Returns: * Never returns to user mode! */ static int Sys_Exit(struct Interrupt_State* state) { Enable_Interrupts(); Detach_User_Context(g_currentThread); Disable_Interrupts(); Exit(state->ebx); return 0; }
/* * Destroy given thread. * This function should perform all cleanup needed to * reclaim the resources used by a thread. * Called with interrupts enabled. */ static void Destroy_Thread(struct Kernel_Thread* kthread) { Detach_User_Context(kthread); // improtant /* Dispose of the thread's memory. */ Disable_Interrupts(); Free_Page(kthread->stackPage); Free_Page(kthread); /* Remove from list of all threads */ Remove_From_All_Thread_List(&s_allThreadList, kthread); Enable_Interrupts(); }