Johann "Myrkraverk" Oskarsson

05.11.2007, 14:09 |
HX: Sleep() + thread == hang? (DOSX) |
Hi all,
I tried to run the following application with HX, and for me, it hangs with the following output:
d:\dos\src>nt_thr.exe
Creating second thread...
second thread 0
third thread 0
third thread 1
:
third thread 9
Is this a bug in HX? I believe I have the very latest version. I don't have NT so I can't test the app in "Real Windows", and I compiled it with the following command line:
wcl386 -l=hx -bt=nt -bm nt_thr.cpp
Here is ther source, adapted from an example I found on the web:
#include <windows.h>
#include <winbase.h>
#include <stdio.h>
#include <process.h>
unsigned Counter;
void SecondThreadFunc( void* pArguments )
{
for ( int i = 0; i < 10; i++ )
{
printf( "second thread %d\n", i );
Sleep( 10 );
}
}
void ThirdThreadFunc( void* pArguments )
{
for ( int i = 0; i < 10; i++ )
{
printf( "third thread %d\n", i );
//Sleep( 10 );
}
}
int main()
{
HANDLE hThread2;
HANDLE hThread3;
unsigned threadID;
printf( "Creating second thread...\n" );
// Create the second thread.
hThread2 = (HANDLE)_beginthread(&SecondThreadFunc, 0, NULL);
hThread3 = (HANDLE)_beginthread(&ThirdThreadFunc, 0, NULL);
// Wait until second thread terminates. If you comment out the line
// below, the second thread will have no chance to finish
WaitForSingleObject( hThread2, INFINITE );
WaitForSingleObject( hThread3, INFINITE );
// Destroy the thread object.
CloseHandle( hThread2 );
CloseHandle( hThread3 );
}
EDIT by rr: added {code} tags for better readability |
Japheth

Germany (South), 05.11.2007, 18:08
@ Johann "Myrkraverk" Oskarsson
|
HX: Sleep() + thread == hang? |
> I tried to run the following application with HX, and for me, it hangs
> with the following output:
>
> d:\dos\src>nt_thr.exe
> Creating second thread...
> second thread 0
> third thread 0
> third thread 1
> :
> third thread 9
>
> Is this a bug in HX? I believe I have the very latest version. I don't
> have NT so I can't test the app in "Real Windows", and I compiled it with
> the following command line:
>
> wcl386 -l=hx -bt=nt -bm nt_thr.cpp
For me it doesn't hang with hxrt 2.12, running under MS-DOS 7.1 and/or FreeDOS. I also tried MS VC++ Toolkit 2003, no problems either. --- MS-DOS forever! |
myrkraverk
13.11.2007, 19:53
@ Japheth
|
HX: Sleep() + thread == hang? |
> For me it doesn't hang with hxrt 2.12, running under MS-DOS 7.1 and/or
> FreeDOS. I also tried MS VC++ Toolkit 2003, no problems either.
Thank you. After setting up real FreeDOS on real hardware, it works ;)
Johann |