mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
- Add func.endfunc decoration.
- Add code to wait for SwapBusy == FALSE on SMP. - Add stub code to check for new PCR fields in 2003. Currently disabled because thread swap code still uses XP fields. - Check for active DPCs at the end of thread swap, not at the beginning. - Set PRCB->IdleThread outside of the thread swap routine. - Don't set the thread state to running inside the swap routine, we already do it outside. svn path=/trunk/; revision=24180
This commit is contained in:
parent
70cca480e5
commit
b52483ba9a
2 changed files with 35 additions and 13 deletions
|
@ -229,6 +229,7 @@ Return:
|
|||
* If a return from a system thread is detected, a bug check will occur.
|
||||
*
|
||||
*--*/
|
||||
.func KiThreadStartup@156
|
||||
.globl _KiThreadStartup@156
|
||||
_KiThreadStartup@156:
|
||||
|
||||
|
@ -268,6 +269,7 @@ BadThread:
|
|||
|
||||
/* A system thread returned...this is very bad! */
|
||||
int 3
|
||||
.endfunc
|
||||
|
||||
/*++
|
||||
* KiSwapContextInternal
|
||||
|
@ -287,22 +289,32 @@ BadThread:
|
|||
* Absolutely all registers except ESP can be trampled here for maximum code flexibility.
|
||||
*
|
||||
*--*/
|
||||
.globl @KiSwapContextInternal@0
|
||||
.func @KiSwapContextInternal@0, @KiSwapContextInternal@0
|
||||
@KiSwapContextInternal@0:
|
||||
|
||||
/* Set the Thread to running */
|
||||
mov byte ptr es:[esi+KTHREAD_STATE], Running
|
||||
|
||||
/* Save the IRQL */
|
||||
push ecx
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
GetSwapLock:
|
||||
/* Acquire the swap lock */
|
||||
cmp [esi+KTHREAD_SWAP_BUSY], 0
|
||||
jz NotBusy
|
||||
pause
|
||||
jmp GetSwapLock
|
||||
#endif
|
||||
|
||||
/* Increase context switches (use ES for lazy load) */
|
||||
//inc dword ptr es:[ebx+KPCR_CONTEXT_SWITCHES]
|
||||
|
||||
/* Save the Exception list */
|
||||
push [ebx+KPCR_EXCEPTION_LIST]
|
||||
|
||||
/* DPC shouldn't be active */
|
||||
cmp byte ptr [ebx+KPCR_PRCB_DPC_ROUTINE_ACTIVE], 0
|
||||
jnz BugCheckDpc
|
||||
/* Check for WMI */
|
||||
//cmp dword ptr [ebx+KPCR_PERF_GLOBAL_GROUP_MASK], 0
|
||||
//jnz WmiTrace
|
||||
|
||||
AfterTrace:
|
||||
/* Switching, disable interrupts now */
|
||||
cli
|
||||
|
||||
|
@ -391,7 +403,6 @@ SameProcess:
|
|||
|
||||
/* Increase context switches */
|
||||
inc dword ptr [esi+KTHREAD_CONTEXT_SWITCHES]
|
||||
//inc dword ptr [esi+KPRC_PRCB_CONTEXT_SWITCHES]
|
||||
|
||||
/* Restore exception list */
|
||||
pop [ebx+KPCR_EXCEPTION_LIST]
|
||||
|
@ -399,6 +410,10 @@ SameProcess:
|
|||
/* Restore IRQL */
|
||||
pop ecx
|
||||
|
||||
/* DPC shouldn't be active */
|
||||
cmp byte ptr [ebx+KPCR_PRCB_DPC_ROUTINE_ACTIVE], 0
|
||||
jnz BugCheckDpc
|
||||
|
||||
/* Check if kernel APCs are pending */
|
||||
cmp byte ptr [esi+KTHREAD_PENDING_KERNEL_APC], 0
|
||||
jnz CheckApc
|
||||
|
@ -446,9 +461,18 @@ LdtStuff:
|
|||
mov eax, KGDT_LDT
|
||||
jmp LoadLdt
|
||||
|
||||
WmiTrace:
|
||||
|
||||
/* No WMI support yet */
|
||||
int 3
|
||||
|
||||
/* Jump back */
|
||||
jmp AfterTrace
|
||||
|
||||
BugCheckDpc:
|
||||
push ATTEMPTED_SWITCH_FROM_DPC
|
||||
call _KeBugCheck@4
|
||||
.endfunc
|
||||
|
||||
/*++
|
||||
* KiSwapContext
|
||||
|
@ -460,7 +484,7 @@ BugCheckDpc:
|
|||
* switch to.
|
||||
*
|
||||
* Returns:
|
||||
* The WaitStatus of the Target Thread. NOT YET SUPPORTED.
|
||||
* The WaitStatus of the Target Thread.
|
||||
*
|
||||
* Remarks:
|
||||
* This is a wrapper around KiSwapContextInternal which will save all the
|
||||
|
@ -472,7 +496,7 @@ BugCheckDpc:
|
|||
*
|
||||
*--*/
|
||||
.globl @KiSwapContext@8
|
||||
.func @KiSwapContext@8, @KiSwapContext@8
|
||||
.func @KiSwapContext@8, @KiSwapContext@8
|
||||
@KiSwapContext@8:
|
||||
/* Note, we CANNOT touch ebp */
|
||||
|
||||
|
@ -494,9 +518,6 @@ BugCheckDpc:
|
|||
/* Get the New Thread */
|
||||
mov esi, edx
|
||||
|
||||
/* Save it as Current thread */
|
||||
mov fs:[KPCR_CURRENT_THREAD], esi
|
||||
|
||||
/* Get the wait IRQL */
|
||||
movzx ecx, byte ptr [edi+KTHREAD_WAIT_IRQL]
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus)
|
|||
|
||||
/* Special note for Filip: This will release the Dispatcher DB Lock ;-) -- Alex */
|
||||
DPRINT("You are : %x, swapping to: %x.\n", OldThread, CurrentThread);
|
||||
KeGetCurrentPrcb()->CurrentThread = CurrentThread;
|
||||
ApcState = KiSwapContext(OldThread, CurrentThread);
|
||||
DPRINT("You are : %x, swapped from: %x\n", OldThread, CurrentThread);
|
||||
return ApcState;
|
||||
|
|
Loading…
Reference in a new issue