Commit de91a8dd authored by Alexandre Julliard's avatar Alexandre Julliard

Implemented NtYieldExecution.

parent 5f21fd47
...@@ -242,17 +242,6 @@ LONG WINAPI KERNEL_nop(void) ...@@ -242,17 +242,6 @@ LONG WINAPI KERNEL_nop(void)
} }
/*********************************************************************** /***********************************************************************
* SwitchToThread (KERNEL32.@)
*/
BOOL WINAPI SwitchToThread(void)
{
Sleep(0);
return 1;
}
/***********************************************************************
* MulDiv (KERNEL32.@) * MulDiv (KERNEL32.@)
* RETURNS * RETURNS
* Result of multiplication and division * Result of multiplication and division
......
...@@ -92,6 +92,15 @@ DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable ) ...@@ -92,6 +92,15 @@ DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable )
/*********************************************************************** /***********************************************************************
* SwitchToThread (KERNEL32.@)
*/
BOOL WINAPI SwitchToThread(void)
{
return (NtYieldExecution() != STATUS_NO_YIELD_PERFORMED);
}
/***********************************************************************
* WaitForSingleObject (KERNEL32.@) * WaitForSingleObject (KERNEL32.@)
*/ */
DWORD WINAPI WaitForSingleObject( HANDLE handle, DWORD timeout ) DWORD WINAPI WaitForSingleObject( HANDLE handle, DWORD timeout )
......
...@@ -270,6 +270,7 @@ ...@@ -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 @@ ...@@ -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
......
...@@ -619,6 +619,20 @@ NTSTATUS WINAPI NtWaitForSingleObject(HANDLE handle, BOOLEAN alertable, const LA ...@@ -619,6 +619,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.@)
*/ */
NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeout ) NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeout )
...@@ -635,9 +649,10 @@ NTSTATUS WINAPI NtDelayExecution( BOOLEAN alertable, const LARGE_INTEGER *timeou ...@@ -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;
......
...@@ -1371,6 +1371,7 @@ NTSTATUS WINAPI NtWaitForSingleObject(HANDLE,BOOLEAN,const LARGE_INTEGER*); ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment