Mail Archives: djgpp/2002/01/25/06:02:18
> From: "Baribaud, Christophe [JNJFR]" <CBARIBAU AT jnjfr DOT JNJ DOT com>
> 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.
- Raw text -