Implemented NtYieldExecution.

This commit is contained in:
Alexandre Julliard 2004-10-11 20:11:01 +00:00
parent 5f21fd47f8
commit de91a8dd0f
5 changed files with 29 additions and 15 deletions

View File

@ -241,17 +241,6 @@ LONG WINAPI KERNEL_nop(void)
return 0; return 0;
} }
/***********************************************************************
* SwitchToThread (KERNEL32.@)
*/
BOOL WINAPI SwitchToThread(void)
{
Sleep(0);
return 1;
}
/*********************************************************************** /***********************************************************************
* MulDiv (KERNEL32.@) * MulDiv (KERNEL32.@)
* RETURNS * RETURNS

View File

@ -91,6 +91,15 @@ DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable )
} }
/***********************************************************************
* SwitchToThread (KERNEL32.@)
*/
BOOL WINAPI SwitchToThread(void)
{
return (NtYieldExecution() != STATUS_NO_YIELD_PERFORMED);
}
/*********************************************************************** /***********************************************************************
* WaitForSingleObject (KERNEL32.@) * WaitForSingleObject (KERNEL32.@)
*/ */

View File

@ -270,6 +270,7 @@
@ stdcall NtWriteFile(long long ptr ptr ptr ptr long ptr ptr) @ stdcall NtWriteFile(long long ptr ptr ptr ptr long ptr ptr)
@ stub NtWriteRequestData @ stub NtWriteRequestData
@ stdcall NtWriteVirtualMemory(long ptr ptr long ptr) @ stdcall NtWriteVirtualMemory(long ptr ptr long ptr)
@ stdcall NtYieldExecution()
@ stub PfxFindPrefix @ stub PfxFindPrefix
@ stub PfxInitialize @ stub PfxInitialize
@ stub PfxInsertPrefix @ stub PfxInsertPrefix
@ -1079,7 +1080,6 @@
@ stub NtReadFileScatter @ stub NtReadFileScatter
@ stub NtSignalAndWaitForSingleObject @ stub NtSignalAndWaitForSingleObject
@ stub NtWriteFileGather @ stub NtWriteFileGather
@ stub NtYieldExecution
@ stub RtlAddAtomToAtomTable @ stub RtlAddAtomToAtomTable
@ stub RtlAllocateHandle @ stub RtlAllocateHandle
@ stub RtlCreateAtomTable @ stub RtlCreateAtomTable

View File

@ -618,6 +618,20 @@ NTSTATUS WINAPI NtWaitForSingleObject(HANDLE handle, BOOLEAN alertable, const LA
} }
/******************************************************************
* NtYieldExecution (NTDLL.@)
*/
NTSTATUS WINAPI NtYieldExecution(void)
{
#ifdef HAVE_SCHED_YIELD
sched_yield();
return STATUS_SUCCESS;
#else
return STATUS_NO_YIELD_PERFORMED;
#endif
}
/****************************************************************** /******************************************************************
* NtDelayExecution (NTDLL.@) * NtDelayExecution (NTDLL.@)
*/ */
@ -635,9 +649,10 @@ NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeou
{ {
for (;;) select( 0, NULL, NULL, NULL, NULL ); for (;;) select( 0, NULL, NULL, NULL, NULL );
} }
#ifdef HAVE_SCHED_YIELD else if (!timeout->QuadPart)
else if (!timeout->QuadPart) sched_yield(); {
#endif NtYieldExecution();
}
else else
{ {
abs_time_t when; abs_time_t when;

View File

@ -1371,6 +1371,7 @@ NTSTATUS WINAPI NtWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*);
NTSTATUS WINAPI NtWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*); NTSTATUS WINAPI NtWaitForMultipleObjects(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
NTSTATUS WINAPI NtWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG); NTSTATUS WINAPI NtWriteFile(HANDLE,HANDLE,PIO_APC_ROUTINE,PVOID,PIO_STATUS_BLOCK,const void*,ULONG,PLARGE_INTEGER,PULONG);
NTSTATUS WINAPI NtWriteVirtualMemory(HANDLE,void*,const void*,SIZE_T,SIZE_T*); NTSTATUS WINAPI NtWriteVirtualMemory(HANDLE,void*,const void*,SIZE_T,SIZE_T*);
NTSTATUS WINAPI NtYieldExecution(void);
void WINAPI RtlAcquirePebLock(void); void WINAPI RtlAcquirePebLock(void);
BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK,BYTE); BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK,BYTE);