ReactOS  0.4.13-dev-39-g8b6696f
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[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

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 }
ULONG nr
Definition: thread.c:7
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
#define CREATE_SUSPENDED
Definition: winbase.h:178
DWORD WINAPI thread_main1(LPVOID param)
Definition: thread.c:9
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
smooth NULL
Definition: ftsmooth.c:416
#define NR_THREADS
Definition: thread.c:5
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI SuspendThread(IN HANDLE hThread)
Definition: thread.c:604
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:529
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
#define printf
Definition: config.h:203

◆ showHelp()

void showHelp ( void  )

Definition at line 23 of file thread.c.

24 {
25 
26 printf("\nReactOS threads test program (built on %s).\n\n", __DATE__);
27 printf("syntax:\tthread.exe <seed>\n");
28 printf("\twhere <seed> is an integer number\n");
29 printf("\texample: thread.exe 100\n");
30 
31 
32 }
#define printf
Definition: config.h:203

◆ 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 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
ULONG nr
Definition: thread.c:7
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
unsigned int ULONG
Definition: retypes.h:1
#define printf
Definition: config.h:203

Referenced by main().

Variable Documentation

◆ nr