ReactOS  0.4.12-dev-918-g6c6e7b8
threadwait.c
Go to the documentation of this file.
1 /*
2  * Author: Skywing (skywing@valhallalegends.com)
3  * Date: 09/09/2003
4  * Purpose: Probe for PsUnblockThread crash due to double-acquire spin lock.
5  */
6 
7 #define WIN32_NO_STATUS
8 #include <windows.h>
9 #include <stdio.h>
10 
11 #define NTOS_MODE_USER
12 #include <ndk/ntndk.h>
13 
14 DWORD __stdcall threadfunc(void* UNREFERENCED)
15 {
16  printf("Thread: Initialized\n");
17  Sleep(2500);
18  printf("Thread: Terminating...\n");
19  return 0;
20 }
21 
22 int main(int ac, char **av)
23 {
24  DWORD id;
25  HANDLE Thread;
26 
27  Thread = CreateThread(0, 0, threadfunc, 0, 0, &id);
28  printf("Main: ThreadId for new thread is %08lx\n", id);
29  printf("Main: Waiting on thread...\n");
31  printf("Main: OK, somebody fixed the PsUnblockThread spinlock double-acquire crash\n");
32  NtClose(Thread);
33  printf("Main: Terminating...\n");
34  return 0;
35 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
DWORD __stdcall threadfunc(void *UNREFERENCED)
Definition: threadwait.c:14
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
int main(int ac, char **av)
Definition: threadwait.c:22
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define __stdcall
Definition: typedefs.h:25
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
GLenum GLuint id
Definition: glext.h:5579
#define INFINITE
Definition: serial.h:102
#define printf
Definition: config.h:203