From: Cherniavsky Beni Newsgroups: comp.os.msdos.djgpp Subject: Re: multitasking/threading in DJGPP Date: Thu, 22 Jun 2000 09:55:56 +0200 Organization: Technion Lines: 62 Message-ID: <3951C68C.97B8437A@crosswinds.net> References: <394F7CEF DOT C3B04F13 AT crosswinds DOT net> <200006202002 DOT XAA00101 AT alpha DOT netvision DOT net DOT il> NNTP-Posting-Host: 132.68.54.8 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.06 [en] (WinNT; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > > > From: Cherniavsky Beni > > Newsgroups: comp.os.msdos.djgpp > > Date: Tue, 20 Jun 2000 16:17:19 +0200 > > > > Isn't there a way to check at run-time with what size of stack the > > program is configured? > > Yes, there is: look at the value of _stklen. My newsgroups access is from campus, while DJGPP is installed&used at home. It's my fault that I was too impatient to go home and dig things up myself. I just opened the FAQ online and complained about the (wrong) way I understood it. ;-( > > The idea is that the library should allocate > > more stack per thread in programs needing much stack space. > > What library? the DJGPP standard library, libc.a? I don't think it's > library's business to decide how much stack to allocate. It doesn't > have enough information for that, not in the startup code anyway. I meant the preemptive multithreading lib that batchex is writing - you advised him to use the default stack size of DJGPP programs for the per-thread stack allocated by his lib and I suggest it would be better to snarf the actual size used by libc (which is anyway decided by the program author/user, not libc). > > It would be nicer if > > the startup code updated _stklen with the actual value it used. > > It does; please try it and tell if it doesn't work for you. (The > startup code in crt0.S clearly updates _stklen with the actual value.) Same as first; I didn't test it nor looked at he source - my fault. The only conclusion is that maybe you should note in the FAQ (15.9) that _stklen is updated if a larger value from the stub is used - at least I didn't understand it that way and possibly others won't. BTW, now I also checked the (online :-) libc reference for _stklen and it's not clear from there too. > > Anyway a better solution might be to allow the stack size for the > > thread as a parameter when creating a thread. > > That won't help: the stack of a DJGPP program is allocated in its > entirety during startup, and its size cannot be changed later. So the > maximum stack size must be determined statically at compile time, or > changed by STUBEDIT. Same as second; I meant the stacks the multithreading lib allocates per thread. They are allocated somehow or the disscussion of their size would be meaningless. PS: accept my appreciation for the effort you spend on answering posts :-) -- Beni Cherniavsky (also scben AT t2 in technion) What's the exterior of a domain? When one takes a bath we shout "Man overboard!".