コード例 #1
0
ファイル: UThread.c プロジェクト: PedroD222/SO_1516si
//
// 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!");
}
コード例 #2
0
ファイル: UThread.c プロジェクト: rjcanto/ISEL-1516i-SO
//
// Schedule a new thread to run
//
static
FORCEINLINE
VOID Schedule () {
	PUTHREAD NextThread;
    NextThread = ExtractNextReadyThread();
	ContextSwitch(RunningThread, NextThread);
}
コード例 #3
0
ファイル: UThread.c プロジェクト: PedroD222/SO_1516si
//
// Schedule a new thread to run
//
static
FORCEINLINE
VOID Schedule() {
	PUTHREAD NextThread;
	//switchCount++;
	NextThread = ExtractNextReadyThread();
	RunningThread->State = READY;
	NextThread->State = RUNNING;
	ContextSwitch(RunningThread, NextThread);
}
コード例 #4
0
ファイル: UThread.c プロジェクト: rjcanto/ISEL-1516i-SO
//
// 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!");
}