TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Phil Crown
date: 1995-10-19 21:46:24
subject: _beginthread too fast

Hello All!

I posted a message earlier about a problem with DosKillThread() not killing
my thread started with _beginthread().  I found the problem there, I was not
keeping track of the thread's id properly (was not delcared as static).
So DosKillThread() now works fine since I delcared my TID static. :-)

However, I have another problem with _beginthread().  In my PM terminal
program, if I don't call DosSleep(400) after calling _beginthread(), the
thread fails to start.  Anything less than 400 and the thread will not
always start, and even at 400 it sometimes doesn't start the very first time
I call _beginthread(), but will start after the first call to
_beginthread().

Before you all dismiss this as crap... :-) consider the following from the
Xr_W010.Rm2 APAR for fixpack #10

APAR= PJ16508
 DOSCONNECTNPIPE() FAILS ON A FAST SYSTEM WITHOUT A DOSSLEEP.

Maybe there is a similiar problem with _beginthread()??  I'm not sure what
is considered a fast system, I'm running a 486-66 DX-S.

Here is a code snippet to show a little of how I am calling _beginthread().
RunRexxScript calls RexxStart to run a Rexx *.cmd file.  That part works
once the thread is started.  The problem is the thread won't start without
the call to DosSleep(400);

case IDM_SCRIPT_RUN:
    if(tidScr != 0) {
      Msg(0, ProgName, "Script already running\nAbort current script
first");
      break;
    }
    rc = SelectRexxScript(pdata, fname); // FileDlg to select *.cmd file
    if(rc == TRUE) {
      tidScr = _beginthread(RunRexxScript, 16384, (PVOID)fname);
      if(tidScr == 0xffff) {
        Msg(0, ProgName, "%s %d\nError starting script thread",
        __FILE__, __LINE__);
        tidScr = 0;
      }
      else
        DosSleep(400);  // without this the thread won't start
    }
    break;

This one really has me stumped!  The only thing I can think of is that the
FileDlg displayed by SelecRexxScript is causing a problem somehow, I will
try bypassing that part of it and hope that will give me a clue.

phil.crown{at}bluecafe.com

--- Blue Wave/Max v2.21a Beta
* Origin: * MacSavvy * Dallas * Mac * OS/2 * (214)250-4479 * (1:124/1208)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 124/1208 1 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.