diff --git a/reactos/include/ndk/pstypes.h b/reactos/include/ndk/pstypes.h index c3ca39a85ac..5bb62044ae4 100644 --- a/reactos/include/ndk/pstypes.h +++ b/reactos/include/ndk/pstypes.h @@ -129,8 +129,11 @@ extern POBJECT_TYPE NTSYSAPI PsJobType; // // Process Priority Separation Values (OR) // -#define PSP_VARIABLE_QUANTUMS 4 -#define PSP_LONG_QUANTUMS 16 +#define PSP_DEFAULT_QUANTUMS 0x00 +#define PSP_VARIABLE_QUANTUMS 0x04 +#define PSP_FIXED_QUANTUMS 0x08 +#define PSP_LONG_QUANTUMS 0x10 +#define PSP_SHORT_QUANTUMS 0x20 #ifndef NTOS_MODE_USER // diff --git a/reactos/ntoskrnl/config/cmdata.c b/reactos/ntoskrnl/config/cmdata.c index 9eeede73556..4d2cb938cb8 100644 --- a/reactos/ntoskrnl/config/cmdata.c +++ b/reactos/ntoskrnl/config/cmdata.c @@ -765,7 +765,7 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] = { L"PriorityControl", L"Win32PrioritySeparation", - &DummyData, + &PsRawPrioritySeparation, NULL, NULL }, diff --git a/reactos/ntoskrnl/include/internal/ps.h b/reactos/ntoskrnl/include/internal/ps.h index 86df7838af9..055a2e31281 100644 --- a/reactos/ntoskrnl/include/internal/ps.h +++ b/reactos/ntoskrnl/include/internal/ps.h @@ -452,6 +452,7 @@ extern PVOID PspSystemDllBase; extern BOOLEAN PspUseJobSchedulingClasses; extern CHAR PspJobSchedulingClasses[PSP_JOB_SCHEDULING_CLASSES]; extern ULONG PsRawPrioritySeparation; +extern ULONG PsPrioritySeparation; extern POBJECT_TYPE _PsThreadType, _PsProcessType; extern PTOKEN PspBootAccessToken; extern GENERIC_MAPPING PspJobMapping; diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 68e7a8e2920..eff280e7d61 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -1495,7 +1495,7 @@ try_again: /* Create a random name and set up the string*/ NameLength = (USHORT)swprintf(NameBuffer, DRIVER_ROOT_NAME L"%08u", - KeTickCount); + KeTickCount.LowPart); LocalDriverName.Length = NameLength * sizeof(WCHAR); LocalDriverName.MaximumLength = LocalDriverName.Length + sizeof(UNICODE_NULL); LocalDriverName.Buffer = NameBuffer; diff --git a/reactos/ntoskrnl/ke/thrdschd.c b/reactos/ntoskrnl/ke/thrdschd.c index c56ab019e0c..a3235d221a4 100644 --- a/reactos/ntoskrnl/ke/thrdschd.c +++ b/reactos/ntoskrnl/ke/thrdschd.c @@ -172,6 +172,14 @@ KiDeferredReadyThread(IN PKTHREAD Thread) /* Calculate the new priority after the increment */ OldPriority = Thread->BasePriority + Thread->AdjustIncrement; + /* Check if this is a foreground process */ + if (CONTAINING_RECORD(Thread->ApcState.Process, EPROCESS, Pcb)-> + Vm.Flags.MemoryPriority == MEMORY_PRIORITY_FOREGROUND) + { + /* Apply the foreground boost */ + OldPriority += PsPrioritySeparation; + } + /* Check if this new priority is higher */ if (OldPriority > Thread->Priority) { diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index d59dfc66ee0..a1086da0948 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -24,7 +24,7 @@ KGUARDED_MUTEX PspActiveProcessMutex; LARGE_INTEGER ShortPsLockDelay; -ULONG PsRawPrioritySeparation = 0; +ULONG PsRawPrioritySeparation; ULONG PsPrioritySeparation; CHAR PspForegroundQuantum[3]; @@ -255,11 +255,16 @@ PsChangeQuantumTable(IN BOOLEAN Immediate, /* Use a variable table */ QuantumTable = PspVariableQuantums; } - else + else if (PspQuantumTypeFromMask(PrioritySeparation) == PSP_FIXED_QUANTUMS) { /* Use fixed table */ QuantumTable = PspFixedQuantums; } + else + { + /* Use default for the type of system we're on */ + QuantumTable = MmIsThisAnNtAsSystem() ? PspFixedQuantums : PspVariableQuantums; + } /* Now check if we should use long or short */ if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_LONG_QUANTUMS) @@ -267,6 +272,16 @@ PsChangeQuantumTable(IN BOOLEAN Immediate, /* Use long quantums */ QuantumTable += 3; } + else if (PspQuantumLengthFromMask(PrioritySeparation) == PSP_SHORT_QUANTUMS) + { + /* Keep existing table */ + NOTHING; + } + else + { + /* Use default for the type of system we're on */ + QuantumTable += MmIsThisAnNtAsSystem() ? 3 : 0; + } /* Check if we're using long fixed quantums */ if (QuantumTable == &PspFixedQuantums[3]) @@ -292,12 +307,10 @@ PsChangeQuantumTable(IN BOOLEAN Immediate, Process = PsGetNextProcess(Process); while (Process) { - /* - * Use the priority separation, unless the process has - * low memory priority - */ - i = (Process->Vm.Flags.MemoryPriority == 1) ? - 0: PsPrioritySeparation; + /* Use the priority separation if this is a foreground process */ + i = (Process->Vm.Flags.MemoryPriority == + MEMORY_PRIORITY_BACKGROUND) ? + 0: PsPrioritySeparation; /* Make sure that the process isn't idle */ if (Process->PriorityClass != PROCESS_PRIORITY_CLASS_IDLE) @@ -306,8 +319,7 @@ PsChangeQuantumTable(IN BOOLEAN Immediate, if ((Process->Job) && (PspUseJobSchedulingClasses)) { /* Use job quantum */ - Quantum = PspJobSchedulingClasses[Process->Job-> - SchedulingClass]; + Quantum = PspJobSchedulingClasses[Process->Job->SchedulingClass]; } else {