Hi all,
I've build the x86 version of CE gcc and now I'm running a small
threading test (thanks Danny!).
This test starts two separate threads and logs the thread ids for both
threads. It appears that they are the same!
After some investigation it seems that the thread ids are the same as
the current Process ID (GetCurrentProcessId).
See attachements for details.
I'm using the latest svn version of CE gcc.
Thanks,
Marcel Smit,
Remedy IT.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int a = 0, b = 0, c = 0;
HANDLE h[2];
DWORD thread_fun1(void *param)
{
int i;
printf ("I am %d\n", GetCurrentThreadId ());
for (i=1; i<=9; i++) {
Sleep(700);
a++;
// fprintf(stderr, "Fun1 : %d\n", i);
}
}
DWORD thread_fun2(void *param)
{
int i, *j = NULL;
printf ("I am %d\n", GetCurrentThreadId ());
for (i=1; i<=10; i++) {
Sleep(1000);
b++;
// fprintf(stderr, "Fun2 : %d\n", i);
}
}
main(int argc, char *argv[])
{
int i;
printf ("Starting process with id %d\n", GetCurrentProcessId());
fprintf(stderr, "Start\n");
h[0] = CreateThread(NULL, 0, thread_fun1, NULL, 0, NULL);
h[1] = CreateThread(NULL, 0, thread_fun2, NULL, 0, NULL);
for (i=0; i<10; i++) {
Sleep(500);
c++;
fprintf(stderr, "Main %d %d %d\n", a, b, c);
}
fprintf(stderr, "After for loop\n");
WaitForMultipleObjects(2, h, FALSE, 0xFFFFFFFF);
fprintf(stderr, "Stop\n");
}
Starting process with id 550314189
Start
I am 550314189
I am 550314189
Main 0 0 1
Main 1 0 2
Main 2 1 3
Main 2 2 4
Main 3 2 5
Main 4 3 6
Main 5 3 7
Main 5 4 8
Main 6 4 9
Main 7 5 10
After for loop
Stop
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel