X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Charles Sandmann Newsgroups: comp.os.msdos.djgpp Subject: Re: Hardware interrupt stack and task switching Date: Fri, 03 Oct 2003 09:42:22 CDT Organization: Rice University, Houston, TX Lines: 25 Message-ID: <3f7d8ace.sandmann@clio.rice.edu> References: NNTP-Posting-Host: clio.rice.edu X-Trace: joe.rice.edu 1065192638 26392 128.42.105.3 (3 Oct 2003 14:50:38 GMT) X-Complaints-To: abuse AT rice DOT edu NNTP-Posting-Date: Fri, 3 Oct 2003 14:50:38 +0000 (UTC) X-NewsEditor: ED-1.5.9 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > I can do task level switching, but it seems like one cannot do task > switching from a hardware interrupt routine. Not directly. This is outlined in the DPMI spec. > So my question: is the DPMI host allocating stacks for each HW ISR? Yes - it does this for stability. When a HW interrupt comes in, it needs to service the interrupt, even if the current user stack is corrupt, or paged out to disk, or too small. Same thing for exceptions. > If that is so, how can I do task switching from the ISR? Is it at > all possible? Yes, you can with some tricks. The DJGPP library has a feature which allows you to convert a hardware interrupt into a fake exception. It does this by invalidating the DS selector limit - so the next access to the stack or memory will allow you to task swap. The interval timer works this way (that's how we can support profiling and wakeup timers). You can either look at the signals support to do this in a portable way, or examine the source for the library routines (djdev203.zip) to see how to do the conversion from interrupt to exception yourself.