TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Edwin Groothuis
from: Mike Bilow
date: 1995-01-05 04:31:16
subject: _beginthread() versus DosCreateThread()

On 95 Jan 02 at 13:12, Edwin Groothuis of 2:284/205.1 wrote:

 EG> I have a very serious problem...

No, you don't.  :)

 EG> In the redbook of os/2 v2.0 there is the following text:

 EG> ``The _beginthread() function provided by the C compiler 
 EG> should be used to create secondary threads that will contain 
 EG> object windows or that contain code which calls C run-time 
 EG> library functions. This function maintains certain internal 
 EG> C library control data that is, by default, not maintained 
 EG> by the DosCreateThread() function.''

 EG> Easy... but how about the following text:

 EG> ``The DosCreateThread() function provided by OS/2 may be 
 EG> used to create secondary threads that will not contain 
 EG> object windows and that do not call C run-time library 
 EG> functions.''

 EG> I understand the part of the object windows, but what do 
 EG> they mean with the ``C run-time library functions?''

"C run-time library functions" are functions in the C run-time library.

Here's how it works.  The _beginthread() call does some stuff, and then
calls DosCreateThread().  If you don't need that other stuff done first,
then you can just call DosCreateThread() directly.

What is that other stuff for?  If you are going to call any functions which
are part of the C run-time library that comes with the compiler, such as
malloc() or strcpy(), then you need to have that other stuff done and you
must use _beginthread().

Considering the amount of overhead involved and the fact that creating
threads is not something you should be doing a lot of, it is probably good
practice to always use _beginthread() and never call DosCreateThread()
directly.
 
-- Mike
 

--- Msgedsq/2 2.2e
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 229/2 12/2442 711/409 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™.