diff --git a/reactos/apps/tests/suspend/.cvsignore b/reactos/apps/tests/suspend/.cvsignore new file mode 100644 index 00000000000..d63774a7353 --- /dev/null +++ b/reactos/apps/tests/suspend/.cvsignore @@ -0,0 +1,6 @@ +*.o +*.d +*.exe +*.coff +*.sym +*.map diff --git a/reactos/apps/tests/suspend/Makefile b/reactos/apps/tests/suspend/Makefile new file mode 100644 index 00000000000..ca7fbcf2bc9 --- /dev/null +++ b/reactos/apps/tests/suspend/Makefile @@ -0,0 +1,19 @@ +# $Id: Makefile,v 1.1 2003/07/20 12:17:19 dwelch Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = suspend + +TARGET_OBJECTS = $(TARGET_NAME).o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/apps/tests/suspend/suspend.c b/reactos/apps/tests/suspend/suspend.c new file mode 100644 index 00000000000..3f1e005ee43 --- /dev/null +++ b/reactos/apps/tests/suspend/suspend.c @@ -0,0 +1,73 @@ +#define UNICODE + +#define NTOS_MODE_USER +#include +#include + +#define DBG +#define NDEBUG +#include + +static volatile DWORD z; +static volatile DWORD x=0; + +static NTSTATUS STDCALL +thread_1(PVOID Param) +{ + DWORD y=0; + + for(;;) + { + z++; + if(x>50) + { + printf("I should have been suspended for years :-)\n"); + Sleep(100); + x=0;y++; + if(y==3) ExitProcess(0); + } + } +} + +int +main(int argc, char *argv[]) +{ + HANDLE thread; + DWORD thread_id; + CONTEXT context; + + context.ContextFlags=CONTEXT_CONTROL; + + z=0; + thread=CreateThread(NULL, + 0x1000, + thread_1, + NULL, + 0, + &thread_id); + + if(!thread) + { + printf("Error: could not create thread ...\n"); + ExitProcess(0); + } + + Sleep(1000); + + SuspendThread(thread); + + for(;;) + { + printf("%x ", z); + Sleep(100);x++; + if(x>100 && GetThreadContext(thread, &context)) + { + printf("EIP: %x\n", context.Eip); + printf("Calling resumethread ... \n"); + ResumeThread(thread); + } + } + + ExitProcess(0); + return(0); +}