Message-Id: <9805190821.AA00045@gcef.gc.maricopa.edu> Date: Tue, 19 May 1998 01:21:56 -0700 (MST) From: "Joshua James Turpen" <44699 AT ef DOT gc DOT maricopa DOT edu> To: djgpp AT delorie DOT com Subject: Threading Precedence: bulk > Joshua James Turpen <44699 AT ef DOT gc DOT maricopa DOT edu> wrote in message > <9805182355 DOT AA23366 AT gcef DOT gc DOT maricopa DOT edu>... > >PDMLWP (based on LWP) does indeed use the DJGPP signal mechanism for task > >switching. If one thread spawns "command.com", threading safely stops > >until command.com returns, due to the nature of signal handling under DJGPP. > > How does it manage this, using a timer interrupt to plant a signal whose > handler manages task switching? What signal is used? Yes, that's the basic premise. The interrupt handler calls __djgpp_hw_exception. When the interrupt handler returns to user space, a *fake* exception is thrown (GPF), which is caught by the djgpp exception handler. ___djgpp_hw_exception sets a flag before the exception is thrown saying it's a fake exception and it's treated specially by the exception handler. All of this slight-of-hand is needed because the DPMI spec doesn't allow for changing the return address of an interrupt handler (i.e. for task switching), but it does for an exception handler (i.e. so the instruction that caused the exception may be restarted). See $DJGPPDIR/src/libc/go32/exceptn.S and $DJGPPDIR/src/libc/go32/dpmiexcp.c Kudos to Charles Sandmann for coming up with such clever code. > > >AFAIK It's pretty much the only 'legal' way under DPMI to change > >contexts in an asynchronous manner. I was forced to go to great lengths > >and use nasty DPMI tricks in order to do it any other way. > > How so... are there any other mechanisms? Which if any wouldn't bomb under > WIndows, or Desqview, or some other non-CWSDPMI environment? Is there a way to I came up with a way, but scrapped it. Basically, it just bypasses the DPMI server altogether and sets the interrupt gate by writing directly to the IDT. The DPMI server doesn't even know the interrupt is hooked. It was interesting, but definately not portable. It worked under CWSDPMI and Win95, but not NT or dosemu. Also, it requires insider knowledge. Win95 remaps the hardware IRQs to interrupts 0x50-0x5F. It's all a hack at best ;). > at least run multiple DJGPP programs using such a scheme, or would it be easier > to design a method of dynamically loading modules? It would probably be easier, and more worthwhile to help fix the EMM386 in OpenDOS :). Or better, get dosemu :). Josh 44699 AT ef DOT gc DOT maricopa DOT edu