X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Date: Fri, 25 Jan 2002 12:59:18 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: CBARIBAU AT jnjfr DOT JNJ DOT com Message-Id: <3277-Fri25Jan2002125917+0200-eliz@is.elta.co.il> X-Mailer: emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: djgpp AT delorie DOT com In-reply-to: <0BA32251E589D2118EA60008C70DDCAB025F9187@JNJFRISEXS1.eu.jnj.com> (CBARIBAU AT jnjfr DOT JNJ DOT com) Subject: Re: multi-threading References: <0BA32251E589D2118EA60008C70DDCAB025F9187 AT JNJFRISEXS1 DOT eu DOT jnj DOT com> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "Baribaud, Christophe [JNJFR]" > Date: Fri, 25 Jan 2002 07:49:47 +0100 > > I don't succeed in sending messages to newsgroup including files ;-(( Yes, you do: sending email to djgpp AT delorie DOT com has the effect of posting to the news group, because djgpp AT delorie DOT com is an email gateway into the news group. > Here is the pre-alpha version of minimalistic multi-threading routines, if > it is of some interest for anybody :-) That code doesn't modify SS, so there should be no problems with it. It also doesn't do preemptive threading (which is where the problems with doing multitasking in DPMI are). These are two aspects of multitasking that I was trying to warn you about. For what you did in the code you posted, you don't need any assembly, just use longjmp (possibly augmented with a single inline assembly line that switches SP to the right stack). Finally, this part of your code seems to be wrong: > // Now we compute segment limit. Cf. dpmi documentation > unsigned long StackSize = buffer[0]; // segment limit field > StackSize |= ((buffer[3] & 0x000F)<<16); // 4 high order bits > if ((buffer[3] & 0x0080) != 0) // page granular > StackSize = StackSize << 12; > printf("Total stack space : = > [%lx:%lx]\r\n",StackSize-_stklen,StackSize); > // Stack space is between StackSize-_stklen and StackSize You seem to assume that the limit of the segment whose selector is loaded into SS is entirely for the stack space. That's not true: the DJGPP run-time memory arena is arranged so that the stack and the data segment span the same memory, and thus the stack is only a _part_ of that segment. The stack top is at __djgpp_stack_limit, and its bottom is _stklen bytes below that. __djgpp_stack_limit is an offset into the data segment. > InternalThreadTable[i].sp = (char*)StackSize; Thus, this line is also wrong.