ReactOS 0.4.15-dev-7961-gdcf9eb0
thread.c File Reference
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
Include dependency graph for thread.c:

Go to the source code of this file.

Macros

#define NR_THREADS   (10)
 

Functions

DWORD WINAPI thread_main1 (LPVOID param)
 
void showHelp (void)
 
int main (int argc, char *argv[])
 

Variables

ULONG nr
 

Macro Definition Documentation

◆ NR_THREADS

#define NR_THREADS   (10)

Definition at line 5 of file thread.c.

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 34 of file thread.c.

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}
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
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
ULONG nr
Definition: thread.c:7
DWORD WINAPI thread_main1(LPVOID param)
Definition: thread.c:9
#define NR_THREADS
Definition: thread.c:5
uint32_t ULONG
Definition: typedefs.h:59
#define CREATE_SUSPENDED
Definition: winbase.h:178

◆ showHelp()

void showHelp ( void  )

Definition at line 23 of file thread.c.

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}

◆ thread_main1()

DWORD WINAPI thread_main1 ( LPVOID  param)

Definition at line 9 of file thread.c.

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}
GLdouble s
Definition: gl.h:2039
GLfloat param
Definition: glext.h:5796
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by main().

Variable Documentation

◆ nr