Легенда:
новое сообщение
закрытая нитка
новое сообщение
в закрытой нитке
старое сообщение
|
- Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
- Новичкам также крайне полезно ознакомиться с данным документом.
А если не выполнится условие (((Prcb->SetMember & Affinity)... 12.05.05 20:46 Число просмотров: 2793
Автор: Killer{R} <Dmitry> Статус: Elderman
|
> Знать бы что заставляет решедулится. Интересно глянуть > сырцы NtYieldExecution. MSDN про Sleep(0): A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.
Т.е. видимо вызывается в этом случае SwitchToThread. Это в принципе подтверждаеться сырцами NtYieldExecution внизу.
NTSTATUS
NtYieldExecution (
VOID
)
/*++
Routine Description:
This function yields execution to any ready thread for up to one
quantum.
Arguments:
None.
Return Value:
None.
--*/
{
KIRQL OldIrql;
PRKPRCB Prcb;
KPRIORITY Priority;
NTSTATUS Status;
PRKTHREAD Thread;
//
// If any other threads are ready, then attempt to yield execution.
//
Status = STATUS_NO_YIELD_PERFORMED;
if (KiReadySummary != 0) {
//
// If a thread has not already been selected for execution, then
// attempt to select another thread for execution.
//
Thread = KeGetCurrentThread();
KiLockDispatcherDatabase(&Thread->WaitIrql);
Prcb = KeGetCurrentPrcb();
if (Prcb->NextThread == NULL) {
Prcb->NextThread = KiFindReadyThread(Thread->NextProcessor, 1);
}
//
// If a new thread has been selected for execution, then switch
// immediately to the selected thread.
//
if (Prcb->NextThread != NULL) {
//
// Give the current thread a new quantum, simulate a quantum
// end, insert the current thread in the appropriate ready list,
// and switch context to selected thread.
//
Thread->Quantum = Thread->ApcState.Process->ThreadQuantum;
Thread->State = Ready;
Priority = Thread->Priority;
if (Priority < LOW_REALTIME_PRIORITY) {
Priority = Priority - Thread->PriorityDecrement - 1;
if (Priority < Thread->BasePriority) {
Priority = Thread->BasePriority;
}
Thread->PriorityDecrement = 0;
}
Thread->Priority = (SCHAR)Priority;
InsertTailList(&KiDispatcherReadyListHead[Priority],
&Thread->WaitListEntry);
SetMember(Priority, KiReadySummary);
KiSwapThread();
Status = STATUS_SUCCESS;
} else {
KiUnlockDispatcherDatabase(Thread->WaitIrql);
}
}
return Status;
}
Thread->State = Ready; делается только если есть другой тред который хочет исполняться.
Вобщем сделаю у себя проверку на SMP и на SMP буду исполнять код в отдельном потоке, а на обычной системе - как обычно. Так надежнее Ж)
|
|
|