@@ -688,9 +688,9 @@ bool kprocess_yield (ProcessRegisterState* currentState)
688688 return s_switchProcess (pinfo , currentState );
689689}
690690
691- bool kprocess_exit (U8 exitCode , bool killBranch )
691+ bool kprocess_exit (U8 exitCode , bool destroyContext )
692692{
693- FUNC_ENTRY ("Exit Code: %x, killBranch : %x" , exitCode , killBranch );
693+ FUNC_ENTRY ("Exit Code: %x, destroyContext : %x" , exitCode , destroyContext );
694694
695695 k_assert (currentProcess != NULL , "Nothing to exit" );
696696
@@ -699,9 +699,12 @@ bool kprocess_exit (U8 exitCode, bool killBranch)
699699 UINT l_exitCode = (UINT )exitCode ;
700700 KProcessInfo * process = currentProcess ;
701701
702- // If parent of the current process is NULL, then the current process is the root process
703- // and branch head. Otherwise its the parent of the current process.
704- if (killBranch && currentProcess -> parent != NULL ) {
702+ // Context is destroyed when the process owning it is killed. For thread processes its their
703+ // parent (non-thread) process who owns the shared context. For non-thread processes the context
704+ // is own by themselves, so nothing special needs to be done. Context owned by Root process
705+ // cannot be destroyed.
706+ if (destroyContext && currentProcess -> parent != NULL &&
707+ BIT_ISSET (currentProcess -> flags , PROCESS_FLAGS_THREAD )) {
705708 process = currentProcess -> parent ;
706709 }
707710
@@ -741,9 +744,9 @@ bool kprocess_exit (U8 exitCode, bool killBranch)
741744 " jz .fin;"
742745 //////////////////////////////////////////////////////////////////////////////
743746 // Call to kprocess_yield to go to the next process now that the current one is
744- // destoryed .
747+ // destroyed .
745748 " mov DWORD PTR [currentProcess], 0;"
746- " xor eax, eax;" // NULL is passed in the first argument of yeld .
749+ " xor eax, eax;" // NULL is passed in the first argument of yield .
747750 " push eax;"
748751 " call kprocess_yield;"
749752 " add esp, 4;"
0 commit comments