- Fix KiIdleLoop to actuall load the PCR in EBX. It was using a completely random value.
- Call the Processor Idle Routine now, isntead of hard-coding STI+HLT. This routine had already been setup during bootup by PoInitailizePrcb.
- Implemented PopIdle0 and made it call HalProcessorIdle. No performance/throttling is done yet.
svn path=/trunk/; revision=24063
- Implement CPU Idle Loop in assembly for UP and SMP systems. Differences:
* Runs with interrupts off most of the time, except when it does interrupt cycling at each iteration.
* Calls KiRetireDpcList directly, instead of going through KiDispatchInterrupt.
* Support for new scheduler and immediate thread switch.
* Support for Idle Scheduler.
* Support for HAL/ACPI/CPU Driver-defined "Idle Function". currently disabled and STI+HLT harcoded instead.
- Removed ps/idle.c and dumped the hack code directly in psmgr.c wher eit's used.
svn path=/trunk/; revision=24062
- Add KiExitDispatcher from my new scheduler code. Same as KiQuantumEnd, added an assertion to make sure it doesn't enter in code paths that shouldn't yet happen.
svn path=/trunk/; revision=24061
- Fix a bug in KiSetPriorityThread which wasn't setting *released = FALSE, which left the var uninitailized and usually = TRUE on the stack.
- Half-copy KiQuantumEnd from my new scheduler code. Main difference is usage of newly created locks, support for quantum-disable and RT threads, and usage of KiComputeNewPriority.
svn path=/trunk/; revision=24060
- Fixup comment header for KiDeliverApc and KiInsertQueueApc.
- Set APC trap frame during APC delivery. We actually weren't doing this before (I'm kind of amazed at ROS's previous functionality due to importance of this bug!).
- Use proper in-stack queued spinlock mechanisms.
- Make sure that the Kernel APC list didn't become empty while we acquired the APC lock after the first verification.
- Validate IRQL on return from APC routines, to catch bad code.
svn path=/trunk/; revision=24059
- Support and document InsertApcEnvironment KAPC_ENVIRONMENT type.
- Fixup formatting and ASSERTify.
- Acquire dispatcher lock when insereting an APC into another thread.
- Use delayed interrupt request on SMP systems (and fixup KiRequestApcInterrupt accordingly).
svn path=/trunk/; revision=24058
- Fixup KeInitalizeApc like all the other functions.
- Don't use an expensive 48-byte RtlZeroMemory instead of just clearing two members.
svn path=/trunk/; revision=24056
- Optimize KeFlushQueueApc: we can check if the Kernel-Mode APC list is empty without acquiring the lock. If it's empty, we can quit immediately, if not, then we'll acquire and check it again. For user APCs we always need to acquire the lock, though.
svn path=/trunk/; revision=24054
- Move NtQueueApcThread to ps/state.c since it's a Ps-level function.
- Make NtQueueApcThread use POOL_QUOTA_FAIL_INSTEAD_OF_RAISE and add that flag to our DDK. Also fix the check for SystemThread by looking at the flag, not checking if TEB == NULL. Also fix a memory leak and comment header.
- Fix comment header in KiInitalizeUserApc.
svn path=/trunk/; revision=24051
- Move KiInitializeUserApc to ke/i386/userapc.c. The routine is non-portable.
- Force Ring 3 state into User APC TrapFrame to maintain system integrity and coherency. Also respect IOPL.
- Use SEH handling routine just like when handling exceptions, to properly re-direct a crash here. Thanks to KJK again for showing me how to write these kinds of routines.
svn path=/trunk/; revision=24050
- Release dispatcher lock from DPC level in KiAttachProcess.
- Add missing decoration/assert to KeAttachProcess, and only acquire APC lock after we've made the invalid attach test. Also acquire dispatcher lock at DPC level here and in KeStackAttachProcess.
- Loop in KeUnStachDetachProcess to avoid the case where we acquired the APC lock while a kernel APC was pending. Keep releaing the loop and re-attemping acquire until it has been delivered.
- Add Decoration for *ServiceTable* functions.
svn path=/trunk/; revision=24048
- Add some missing decoration.
- NUMA node semantics for KeInitializeProcess are only required on SMP builds.
- Allow KeInitailizeProcess to receive an argument specifying if alignment faults should be enabled or not.
- Use KiComputeIopmOffset to get the IopmOFfset instead of setting -1
svn path=/trunk/; revision=24047
- Add assertions to relevant functions in process.c and re-format some code.
- Check for invalid APC state in KeDetachProcess.
- Decrease process stack count while holding the Dispatcher Lock at DPC level.
- Implement KiSwapProcess in ctxswitch.S and add SMP-support and LDT swap support for the future, as well as updating the IOPM base in the TSS.
svn path=/trunk/; revision=24044
- Same changes to event.c as with the other files.
- Remove lock property, these files have already been audited as clean and were unlocked.
svn path=/trunk/; revision=24040
- Cleanup mutex.c and sem.c. No real code changes, just add ASSERTs, STDCALL->NTAPI, IN/OUT decoration.
- One change though, in KeReleaseMutant, use KeLeaveCriticalRegion instead of manually writing down the code, it's more readable this way.
svn path=/trunk/; revision=24039
- apc.c -> Also multiple optimizations to use the APC lock instead of the full-fledged dispatcher lock.
- gate.c -> Use APC lock as well, the full dispatcher lock isn't required because a thread can only wait on one and only one gate.
- process.c -> Optimize the code to use the Process and/or APC lock instead of the dispatcher lock. Also delay acquiring the locks after some checks, to make the exit paths simpler.
- More fixes are teh needed.
svn path=/trunk/; revision=24038
- Update KeSetAFfinityThread, KeSetPriorityThread with new locks and assertions (plus the current ROS scheduler hack).
svn path=/trunk/; revision=24034
- Update KeSetIdealProcessorThread to properly do Ideal CPU logic instead of blindgly setting it (most importantly, respect UserIdealProcessor and SystemAffinityActive seettings).
svn path=/trunk/; revision=24033
- Stargint reorganizing some public functions to the bottom of the file.
- Don't hold lock during KeSetKernelStackSwapEnable.
svn path=/trunk/; revision=24030
- Update KeFreezeAllThreads to use the Process and APC In-Stack Queued Spinlock.
- Update KeTerminateThread to use the Process Lock. Call KiRundownThread to cleanup the NPX thread. Add some assertions for Stack in/out-paging. Use KiSetThreadSwapBusy for proper SMP vs UP building.
- NUMA Node semantics in KeStartThread only need to be done for CONFIG_SMP builds, so #ifed them appropriately. Also made it use the Process In-Stack QSL.
svn path=/trunk/; revision=24029
- Implement KeAcquireInStackQueuedSpinLockRaiseToSynch for UP systems.
- Implement KiAcquireApcLock, KiAcquireApcLockAtDpcLevel, KiReleaseApcLock, KiReleaseApcLockFromDpcLevel.
- KeResumeThread, KeSuspendThread, KeAlertThread, KeForceResumeThread, KeTestAlertThread, KeAlertResumeThread are now the first to use the new APC In-Stack Queued Spinlock for sychronization.
svn path=/trunk/; revision=24028
- Also fix KeSetAffinityThread to return the old affinity, instead of NTSTATUS and move NtYieldExecution from Ps to Ke, and move NtDelayExecution to wait.c
- No code changes.
svn path=/trunk/; revision=24024
- Finally get rid of duplicated relocation code in ntdll by using the relocate function from RTL and enable/disable protection
- Some improvements added to RTL's relocation function, it's split up into two functions now
svn path=/trunk/; revision=24020