Exemplo n.º 1
0
//
// Terminates the execution of the currently running thread. All associated
// resources are released after the context switch to the next ready thread.
//
VOID UtExit() {
	NumberOfThreads -= 1;
	//switchCount++;
	//change for utjoin para a thread poder voltar a correr
	if (RunningThread == MainThread) {
		InternalExit(RunningThread, ExtractNextReadyThread());
		_ASSERTE(!"Supposed to be here!");
	}
	PLIST_ENTRY aux = RunningThread->Joiners.Flink;
	PUTHREAD ut;
	while (aux != &RunningThread->Joiners)
	{
		ut = CONTAINING_RECORD(aux, UTHREAD, Link);
		ut->State = READY;
		InsertTailList(&ReadyQueue, &ut->Link);
		aux = aux->Flink;
	}
	aux = &AliveThreads.Flink;
	PUTHREAD t;
	while (aux != &AliveThreads)
	{
		t = CONTAINING_RECORD(aux, UTHREAD, Link);
		if (RunningThread == t)
			RemoveEntryList(aux);
		aux = aux->Flink;
	}
	PUTHREAD u = ExtractNextReadyThread();
	u->State = RUNNING;
	InternalExit(RunningThread, u);
	_ASSERTE(!"Supposed to be here!");
}
Exemplo n.º 2
0
//
// Terminates the execution of the currently running thread. All associated
// resources are released after the context switch to the next ready thread.
//
VOID UtExit () {
	NumberOfThreads -= 1;	
	
	InternalExit(RunningThread, ExtractNextReadyThread());
	_ASSERTE(!"Supposed to be here!");
}