mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Checked in a test application which does various operations on a
terminated thread. svn path=/trunk/; revision=5212
This commit is contained in:
parent
b9185cc4c4
commit
15550bfef3
3 changed files with 95 additions and 1 deletions
|
@ -10,7 +10,7 @@ TEST_APPS = alive apc args atomtest bench bitblt button button2 \
|
|||
combo consume copymove count dump_shared_data edit event file \
|
||||
gditest hello isotest lineclip lpc messagebox mstest mutex nptest pteb \
|
||||
regtest sectest shm thread tokentest vmtest winhello dibtest lock \
|
||||
hivetest shaptest wm_paint multiwin icontest suspend tests/volinfo
|
||||
hivetest shaptest wm_paint multiwin icontest suspend tests/volinfo terminate
|
||||
|
||||
TEST_MISC =
|
||||
|
||||
|
|
19
reactos/apps/tests/terminate/Makefile
Normal file
19
reactos/apps/tests/terminate/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
# $Id: Makefile,v 1.1 2003/07/21 21:44:28 dwelch Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = terminate
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
75
reactos/apps/tests/terminate/terminate.c
Normal file
75
reactos/apps/tests/terminate/terminate.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
#define UNICODE
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ntos.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define DBG
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static volatile DWORD z;
|
||||
static volatile DWORD x=0;
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
thread_1(PVOID Param)
|
||||
{
|
||||
DWORD y=0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
z++;
|
||||
if(x>50)
|
||||
{
|
||||
Sleep(100);
|
||||
x=0;y++;
|
||||
if(y==3) return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE thread;
|
||||
DWORD thread_id;
|
||||
CONTEXT context;
|
||||
DWORD z = 0;
|
||||
|
||||
context.ContextFlags=CONTEXT_CONTROL;
|
||||
|
||||
while (z < 50)
|
||||
{
|
||||
TerminateThread(thread, 0);
|
||||
z++;
|
||||
thread=CreateThread(NULL,
|
||||
0x1000,
|
||||
thread_1,
|
||||
NULL,
|
||||
0,
|
||||
&thread_id);
|
||||
|
||||
if(!thread)
|
||||
{
|
||||
printf("Error: could not create thread ...\n");
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
|
||||
printf("T");
|
||||
if ((z % 5) == 0)
|
||||
{
|
||||
TerminateThread(thread, 0);
|
||||
}
|
||||
printf("C");
|
||||
GetThreadContext(thread, &context);
|
||||
printf("S");
|
||||
SuspendThread(thread);
|
||||
printf("R");
|
||||
ResumeThread(thread);
|
||||
}
|
||||
|
||||
ExitProcess(0);
|
||||
return(0);
|
||||
}
|
Loading…
Reference in a new issue