ReactOS 0.4.16-dev-88-ga65b6ae
thread.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <windows.h>
3#include <stdlib.h>
4
5#define NR_THREADS (10)
6
8
10{
11 ULONG s;
12
13 printf("Thread %ld running\n", (DWORD)param);
14 s = nr = ((nr * 1103515245) + 12345) & 0x7fffffff;
15 s = s % 10;
16 printf("s %ld\n", s);
17 Sleep(s);
18 printf("Thread %ld finished\n", (DWORD)param);
19 return 0;
20}
21
22// Shows the help on how to use these program to the user
23void showHelp(void)
24{
25
26printf("\nReactOS threads test program (built on %s).\n\n", __DATE__);
27printf("syntax:\tthread.exe <seed>\n");
28printf("\twhere <seed> is an integer number\n");
29printf("\texample: thread.exe 100\n");
30
31
32}
33
34int main (int argc, char* argv[])
35{
36 DWORD i=0;
37 DWORD id;
38 ULONG nr;
39 HANDLE ThreadHandle[NR_THREADS];
40
41 // The user must supply one argument (the seed). if he/she doesn't
42 // then we show the help.
43 // if(argc < 2) {
44 // showHelp();
45 // return 1;
46 // }
47
48 // nr = atoi(argv[1]);
49 nr = 500;
50 printf("Seed %ld\n", nr);
51
52 printf("Creating %d threads...\n",NR_THREADS*2);
53 for (i=0;i<NR_THREADS;i++)
54 {
55 ThreadHandle[i] = CreateThread(NULL,
56 0,
58 (LPVOID)i,
60 &id);
61
62 }
63
64 for (i=0;i<NR_THREADS;i++)
65 {
66 ResumeThread(ThreadHandle[i]);
67 }
68
69 for (i=0;i<NR_THREADS;i++)
70 {
71 SuspendThread(ThreadHandle[i]);
72 }
73
74 for (i=0;i<NR_THREADS;i++)
75 {
76 ResumeThread(ThreadHandle[i]);
77 }
78
79 printf("All threads created...\n");
80 return 0;
81}
static int argc
Definition: ServiceArgs.c:12
#define NULL
Definition: types.h:112
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
DWORD WINAPI SuspendThread(IN HANDLE hThread)
Definition: thread.c:642
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:137
int main()
Definition: test.c:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
GLdouble s
Definition: gl.h:2039
GLfloat param
Definition: glext.h:5796
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void showHelp(void)
Definition: thread.c:23
ULONG nr
Definition: thread.c:7
DWORD WINAPI thread_main1(LPVOID param)
Definition: thread.c:9
#define NR_THREADS
Definition: thread.c:5
#define argv
Definition: mplay32.c:18
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
uint32_t ULONG
Definition: typedefs.h:59
#define CREATE_SUSPENDED
Definition: winbase.h:178
#define WINAPI
Definition: msvc.h:6