Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Nascondi spazi bianchi
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Stili testo
Modifica aspetto
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
balmgr.c MS and ReactOS
Creato
7 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
165 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
189 linee
Copia tutti
95 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
114 linee
Copia tutti
Copia
Copiato
Copia
Copiato
NTOS Kernel
REACT OS
VOID
VOID
Copia
Copiato
Copia
Copiato
KiScanReadyQueues
(
NTAPI
IN PKDPC Dpc,
KiScanReadyQueues
(
IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2
IN PVOID SystemArgument2
)
)
/*++
Routine Description:
This function scans a section of the ready queues and attempts to
boost the priority of threads that run at variable priority levels.
N.B. This function is executed as a DPC from the periodic timer that
drives the balance set manager.
Arguments:
Dpc - Supplies a pointer to a DPC object - not used.
DeferredContext - Supplies the DPC context - not used.
SystemArgument1 - Supplies the first system argument - note used.
SystemArgument2 - Supplies the second system argument - note used.
Return Value:
None.
--*/
{
{
Copia
Copiato
Copia
Copiato
P
ULONG
ScanLast
=
DeferredContext
;
ULONG
Count
=
0;
ULONG
Scan
Index
= *ScanLast
;
PLIST_ENTRY Entry
;
ULONG
Count = 10,
Number =
16
;
ULONG
Index
;
PKPRCB Prcb
= KiProcessorBlock[ScanIndex]
;
PLIST_ENTRY ListHead
;
ULONG
Index = Prcb->QueueIndex
;
ULONG
Number =
0;
ULONG
WaitLimit = KeTickCount.LowPart - 300
;
KIRQL OldIrql
;
PKPRCB Prcb
;
ULONG
ScanIndex
;
P
ULONG
ScanLast
;
ULONG Summary;
ULONG Summary;
Copia
Copiato
Copia
Copiato
KIRQL OldIrql;
PLIST_ENTRY ListHead, NextEntry;
PKTHREAD Thread;
PKTHREAD Thread;
Copia
Copiato
Copia
Copiato
ULONG WaitLimit;
UNREFERENCED_PARAMETER(SystemArgument1);
UNREFERENCED_PARAMETER(SystemArgument2);
//
// Get the address of the queue index variable.
//
// N.B. If a fault occurs accessing queue index value, then the exception
// handler is either executed or a bugcheck occurs.
//
ScanLast = (PULONG)DeferredContext;
#if defined(_AMD64_)
try {
ScanIndex = *ScanLast;
} except(KiKernelDpcFilter(Dpc, GetExceptionInformation())) {
return;
}
#else
UNREFERENCED_PARAMETER(Dpc);
ScanIndex = *ScanLast;
#endif
//
// Lock the dispatcher database, acquire the PRCB lock, and check if
// there are any ready threads queued at the scanable priority levels.
//
Copia
Copiato
Copia
Copiato
Count = THREAD_READY_COUNT;
/* Lock the dispatcher and PRCB */
Number = THREAD_SCAN_COUNT;
OldIrql = KiAcquireDispatcherLock();
Prcb = KiProcessorBlock[ScanIndex];
Index = Prcb->QueueIndex;
WaitLimit = KiQueryLowTickCount() - READY_WITHOUT_RUNNING;
KiLockDispatcherDatabase(&OldIrql);
KiAcquirePrcbLock(Prcb);
KiAcquirePrcbLock(Prcb);
Copia
Copiato
Copia
Copiato
/* Check if there's any thread that need help */
Summary = Prcb->ReadySummary & ((1 << THREAD_BOOST_PRIORITY) - 2);
Summary = Prcb->ReadySummary & ((1 << THREAD_BOOST_PRIORITY) - 2);
Copia
Copiato
Copia
Copiato
if (Summary
!= 0) {
if (Summary
)
do {
{
/* Start scan loop */
//
do
// If the current ready queue index is beyond the end of the range
{
// of priorities that are scanned, then wrap back to the beginning
/* Normalize the index */
// priority.
if (Index > (THREAD_BOOST_PRIORITY - 1)) Index = 1;
//
if (Index > THREAD_SCAN_PRIORITY) {
Index = 1;
}
//
// If there are any ready threads queued at the current priority
// level, then attempt to boost the thread priority.
//
if (Summary & PRIORITY_MASK(Index)) {
Copia
Copiato
Copia
Copiato
ASSERT(
IsListEmpty(&Prcb->DispatcherReadyListHead[Index])
== FALSE
);
/* Loop for ready threads */
if (Summary & PRIORITY_MASK(Index))
{
/* Sanity check */
ASSERT(
!
IsListEmpty(&Prcb->DispatcherReadyListHead[Index])
);
Copia
Copiato
Copia
Copiato
/* Update summary and select list */
Summary ^= PRIORITY_MASK(Index);
Summary ^= PRIORITY_MASK(Index);
ListHead = &Prcb->DispatcherReadyListHead[Index];
ListHead = &Prcb->DispatcherReadyListHead[Index];
Copia
Copiato
Copia
Copiato
Entry = ListHead->Flink;
Next
Entry = ListHead->Flink;
do
{
do
{
//
/
* Select a
thread
*/
/
/ If the
thread
has been waiting for an extended period,
Thread = CONTAINING_RECORD(
NextEntry,
// then boost the priority of the selected.
KTHREAD,
//
WaitListEntry);
ASSERT(Thread->Priority == Index);
Thread = CONTAINING_RECORD(
Entry, KTHREAD, WaitListEntry);
ASSERT(Thread->Priority == (KPRIORITY)Index);
if (WaitLimit >= Thread->WaitTime) {
//
// Remove the thread from the respective ready queue.
//
Entry = Entry->Blink;
ASSERT((Prcb->ReadySummary & PRIORITY_MASK(Index)) != 0);
Copia
Copiato
Copia
Copiato
if (RemoveEntryList(
Entry->Flink)
!= FALSE) {
/* Check if the thread has been waiting too long */
if (WaitLimit >= Thread->WaitTime)
{
/* Remove the thread from the queue */
NextEntry = NextEntry->Blink;
ASSERT((Prcb->ReadySummary & PRIORITY_MASK(Index)));
if (RemoveEntryList(
Next
Entry->Flink)
)
{
/* The list is empty now */
Prcb->ReadySummary ^= PRIORITY_MASK(Index);
Prcb->ReadySummary ^= PRIORITY_MASK(Index);
}
}
Copia
Copiato
Copia
Copiato
/
/
/
* Verify
priority decrement
and
set the new
one */
// Compute the
priority decrement
value,
set the new
// thread priority, set the thread quantum to a value
// appropriate for lock ownership, and insert the
// thread in the ready list.
//
ASSERT((Thread->PriorityDecrement >= 0) &&
ASSERT((Thread->PriorityDecrement >= 0) &&
Copia
Copiato
Copia
Copiato
(Thread->PriorityDecrement <=
Thread->Priority));
(Thread->PriorityDecrement <=
Thread->Priority));
Thread->PriorityDecrement +=
Thread->PriorityDecrement +=
(THREAD_BOOST_PRIORITY -
(THREAD_BOOST_PRIORITY -
Thread->Priority);
Thread->Priority);
ASSERT((Thread->PriorityDecrement >= 0) &&
ASSERT((Thread->PriorityDecrement >= 0) &&
Copia
Copiato
Copia
Copiato
(Thread->PriorityDecrement <=
THREAD_BOOST_PRIORITY));
(Thread->PriorityDecrement <=
THREAD_BOOST_PRIORITY));
Copia
Copiato
Copia
Copiato
/* Update priority and insert into ready list */
Thread->Priority = THREAD_BOOST_PRIORITY;
Thread->Priority = THREAD_BOOST_PRIORITY;
Copia
Copiato
Copia
Copiato
Thread->Quantum =
LOCK_OWNERSHIP
_QUANTUM
;
Thread->Quantum =
WAIT
_QUANTUM
_DECREMENT * 4
;
KiInsertDeferredReadyList(Thread);
KiInsertDeferredReadyList(Thread);
Copia
Copiato
Copia
Copiato
Count -
= 1
;
Count -
-
;
}
}
Copia
Copiato
Copia
Copiato
Entry =
Entry->Flink;
/* Go to the next entry */
Number
-= 1
;
Next
Entry =
Next
Entry->Flink;
} while
((
Entry != ListHead) && (Number
!= 0
) && (Count
!= 0
));
Number
--
;
} while
((Next
Entry != ListHead) && (Number
) && (Count
));
}
}
Copia
Copiato
Copia
Copiato
Index
+= 1
;
/* Increase index */
} while ((Summary
!= 0
) && (Number
!= 0
) && (Count
!= 0
));
Index
++
;
} while ((Summary
) && (Number
) && (Count
));
}
}
Copia
Copiato
Copia
Copiato
/
/
/
*
Release the
lock
s and
dispatcher
*/
//
Release the
PRCB
lock
, unlock the
dispatcher
database, and save the
// last ready queue index for the next scan.
//
KiReleasePrcbLock(Prcb);
KiReleasePrcbLock(Prcb);
Copia
Copiato
Copia
Copiato
KiUnlockDispatcherDatabase
(OldIrql);
KiReleaseDispatcherLock
(OldIrql);
if ((Count
!= 0
) && (Number
!= 0)) {
/* Update the queue index for next time */
if ((Count
) && (Number
))
{
/* Reset the queue at index 1 */
Prcb->QueueIndex = 1;
Prcb->QueueIndex = 1;
Copia
Copiato
Copia
Copiato
}
}
else
{
else
{
/* Set the index we're in now */
Prcb->QueueIndex = Index;
Prcb->QueueIndex = Index;
}
}
Copia
Copiato
Copia
Copiato
//
/* Increment the CPU number for next time and normalize to CPU count */
// Increment the processor number.
ScanIndex++;
//
if (ScanIndex ==
KeNumberProcessors)
ScanIndex = 0;
ScanIndex += 1;
if (ScanIndex ==
(ULONG)
KeNumberProcessors)
{
ScanIndex = 0;
}
Copia
Copiato
Copia
Copiato
/* Return the index */
*ScanLast = ScanIndex;
*ScanLast = ScanIndex;
Copia
Copiato
Copia
Copiato
return;
}
}
Diff salvati
Testo originale
Apri file
NTOS Kernel VOID KiScanReadyQueues ( IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2 ) /*++ Routine Description: This function scans a section of the ready queues and attempts to boost the priority of threads that run at variable priority levels. N.B. This function is executed as a DPC from the periodic timer that drives the balance set manager. Arguments: Dpc - Supplies a pointer to a DPC object - not used. DeferredContext - Supplies the DPC context - not used. SystemArgument1 - Supplies the first system argument - note used. SystemArgument2 - Supplies the second system argument - note used. Return Value: None. --*/ { ULONG Count = 0; PLIST_ENTRY Entry; ULONG Index; PLIST_ENTRY ListHead; ULONG Number = 0; KIRQL OldIrql; PKPRCB Prcb; ULONG ScanIndex; PULONG ScanLast; ULONG Summary; PKTHREAD Thread; ULONG WaitLimit; UNREFERENCED_PARAMETER(SystemArgument1); UNREFERENCED_PARAMETER(SystemArgument2); // // Get the address of the queue index variable. // // N.B. If a fault occurs accessing queue index value, then the exception // handler is either executed or a bugcheck occurs. // ScanLast = (PULONG)DeferredContext; #if defined(_AMD64_) try { ScanIndex = *ScanLast; } except(KiKernelDpcFilter(Dpc, GetExceptionInformation())) { return; } #else UNREFERENCED_PARAMETER(Dpc); ScanIndex = *ScanLast; #endif // // Lock the dispatcher database, acquire the PRCB lock, and check if // there are any ready threads queued at the scanable priority levels. // Count = THREAD_READY_COUNT; Number = THREAD_SCAN_COUNT; Prcb = KiProcessorBlock[ScanIndex]; Index = Prcb->QueueIndex; WaitLimit = KiQueryLowTickCount() - READY_WITHOUT_RUNNING; KiLockDispatcherDatabase(&OldIrql); KiAcquirePrcbLock(Prcb); Summary = Prcb->ReadySummary & ((1 << THREAD_BOOST_PRIORITY) - 2); if (Summary != 0) { do { // // If the current ready queue index is beyond the end of the range // of priorities that are scanned, then wrap back to the beginning // priority. // if (Index > THREAD_SCAN_PRIORITY) { Index = 1; } // // If there are any ready threads queued at the current priority // level, then attempt to boost the thread priority. // if (Summary & PRIORITY_MASK(Index)) { ASSERT(IsListEmpty(&Prcb->DispatcherReadyListHead[Index]) == FALSE); Summary ^= PRIORITY_MASK(Index); ListHead = &Prcb->DispatcherReadyListHead[Index]; Entry = ListHead->Flink; do { // // If the thread has been waiting for an extended period, // then boost the priority of the selected. // Thread = CONTAINING_RECORD(Entry, KTHREAD, WaitListEntry); ASSERT(Thread->Priority == (KPRIORITY)Index); if (WaitLimit >= Thread->WaitTime) { // // Remove the thread from the respective ready queue. // Entry = Entry->Blink; ASSERT((Prcb->ReadySummary & PRIORITY_MASK(Index)) != 0); if (RemoveEntryList(Entry->Flink) != FALSE) { Prcb->ReadySummary ^= PRIORITY_MASK(Index); } // // Compute the priority decrement value, set the new // thread priority, set the thread quantum to a value // appropriate for lock ownership, and insert the // thread in the ready list. // ASSERT((Thread->PriorityDecrement >= 0) && (Thread->PriorityDecrement <= Thread->Priority)); Thread->PriorityDecrement += (THREAD_BOOST_PRIORITY - Thread->Priority); ASSERT((Thread->PriorityDecrement >= 0) && (Thread->PriorityDecrement <= THREAD_BOOST_PRIORITY)); Thread->Priority = THREAD_BOOST_PRIORITY; Thread->Quantum = LOCK_OWNERSHIP_QUANTUM; KiInsertDeferredReadyList(Thread); Count -= 1; } Entry = Entry->Flink; Number -= 1; } while ((Entry != ListHead) && (Number != 0) && (Count != 0)); } Index += 1; } while ((Summary != 0) && (Number != 0) && (Count != 0)); } // // Release the PRCB lock, unlock the dispatcher database, and save the // last ready queue index for the next scan. // KiReleasePrcbLock(Prcb); KiUnlockDispatcherDatabase(OldIrql); if ((Count != 0) && (Number != 0)) { Prcb->QueueIndex = 1; } else { Prcb->QueueIndex = Index; } // // Increment the processor number. // ScanIndex += 1; if (ScanIndex == (ULONG)KeNumberProcessors) { ScanIndex = 0; } *ScanLast = ScanIndex; return; }
Testo modificato
Apri file
REACT OS VOID NTAPI KiScanReadyQueues(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2) { PULONG ScanLast = DeferredContext; ULONG ScanIndex = *ScanLast; ULONG Count = 10, Number = 16; PKPRCB Prcb = KiProcessorBlock[ScanIndex]; ULONG Index = Prcb->QueueIndex; ULONG WaitLimit = KeTickCount.LowPart - 300; ULONG Summary; KIRQL OldIrql; PLIST_ENTRY ListHead, NextEntry; PKTHREAD Thread; /* Lock the dispatcher and PRCB */ OldIrql = KiAcquireDispatcherLock(); KiAcquirePrcbLock(Prcb); /* Check if there's any thread that need help */ Summary = Prcb->ReadySummary & ((1 << THREAD_BOOST_PRIORITY) - 2); if (Summary) { /* Start scan loop */ do { /* Normalize the index */ if (Index > (THREAD_BOOST_PRIORITY - 1)) Index = 1; /* Loop for ready threads */ if (Summary & PRIORITY_MASK(Index)) { /* Sanity check */ ASSERT(!IsListEmpty(&Prcb->DispatcherReadyListHead[Index])); /* Update summary and select list */ Summary ^= PRIORITY_MASK(Index); ListHead = &Prcb->DispatcherReadyListHead[Index]; NextEntry = ListHead->Flink; do { /* Select a thread */ Thread = CONTAINING_RECORD(NextEntry, KTHREAD, WaitListEntry); ASSERT(Thread->Priority == Index); /* Check if the thread has been waiting too long */ if (WaitLimit >= Thread->WaitTime) { /* Remove the thread from the queue */ NextEntry = NextEntry->Blink; ASSERT((Prcb->ReadySummary & PRIORITY_MASK(Index))); if (RemoveEntryList(NextEntry->Flink)) { /* The list is empty now */ Prcb->ReadySummary ^= PRIORITY_MASK(Index); } /* Verify priority decrement and set the new one */ ASSERT((Thread->PriorityDecrement >= 0) && (Thread->PriorityDecrement <= Thread->Priority)); Thread->PriorityDecrement += (THREAD_BOOST_PRIORITY - Thread->Priority); ASSERT((Thread->PriorityDecrement >= 0) && (Thread->PriorityDecrement <= THREAD_BOOST_PRIORITY)); /* Update priority and insert into ready list */ Thread->Priority = THREAD_BOOST_PRIORITY; Thread->Quantum = WAIT_QUANTUM_DECREMENT * 4; KiInsertDeferredReadyList(Thread); Count --; } /* Go to the next entry */ NextEntry = NextEntry->Flink; Number--; } while((NextEntry != ListHead) && (Number) && (Count)); } /* Increase index */ Index++; } while ((Summary) && (Number) && (Count)); } /* Release the locks and dispatcher */ KiReleasePrcbLock(Prcb); KiReleaseDispatcherLock(OldIrql); /* Update the queue index for next time */ if ((Count) && (Number)) { /* Reset the queue at index 1 */ Prcb->QueueIndex = 1; } else { /* Set the index we're in now */ Prcb->QueueIndex = Index; } /* Increment the CPU number for next time and normalize to CPU count */ ScanIndex++; if (ScanIndex == KeNumberProcessors) ScanIndex = 0; /* Return the index */ *ScanLast = ScanIndex; }
Trovare la differenza