TD2 II.2 Finish thread Gracefuly
This commit is contained in:
parent
615d121a76
commit
feff887fa0
2 changed files with 8 additions and 3 deletions
|
@ -131,8 +131,8 @@ ExceptionHandler (ExceptionType which)
|
||||||
#ifdef CHANGED
|
#ifdef CHANGED
|
||||||
case SC_Exit:
|
case SC_Exit:
|
||||||
{
|
{
|
||||||
while (1)
|
// while (1)
|
||||||
currentThread->Yield();
|
// currentThread->Yield();
|
||||||
int ret = machine->ReadRegister(4);
|
int ret = machine->ReadRegister(4);
|
||||||
printf("Exit code %d\n", ret);
|
printf("Exit code %d\n", ret);
|
||||||
interrupt->Powerdown();
|
interrupt->Powerdown();
|
||||||
|
|
|
@ -68,8 +68,13 @@ void do_ThreadExit(){
|
||||||
DEBUG('x', "Enter do_ThreadExit function\n");
|
DEBUG('x', "Enter do_ThreadExit function\n");
|
||||||
// TODO: what should we do with thread space?
|
// TODO: what should we do with thread space?
|
||||||
// Probalely desallocate it... if no threads remain
|
// Probalely desallocate it... if no threads remain
|
||||||
currentThread->space->Threads--;
|
// currentThread->space->Threads--;
|
||||||
DEBUG('x', "Decrease numbers of Threads:%d\n",currentThread->space->Threads);
|
DEBUG('x', "Decrease numbers of Threads:%d\n",currentThread->space->Threads);
|
||||||
|
if ( --currentThread->space->Threads == 0){
|
||||||
|
// No threads remains, desallocate addrspace
|
||||||
|
delete currentThread->space;
|
||||||
|
interrupt->Powerdown();
|
||||||
|
}
|
||||||
currentThread->Finish();
|
currentThread->Finish();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue