Date: Wed, 13 Nov 1996 09:09:22 +0200 (IST) From: Eli Zaretskii To: "Alaric B. Williams" Cc: djgpp AT delorie DOT com Subject: Re: True Processor-aided PM multitasking In-Reply-To: <847822218.17951.1@abwillms.demon.co.uk> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 12 Nov 1996, Alaric B. Williams wrote: > The compiler has been adjusted to insert "Should I yield?" > instructions at frequent points in the code (one per loop construct, > certainly, and one per 100 or so instructions). > > The "Should I yield?" is a simple compare-the-flag, and if the switch > flag is set, PUSHAD (save all registers to the stack) and invoke the > task switch function, then POPAD and continue execution. > > The "should I yield?" thus clobbers no registers, ever. For truely general-purpose multitasking, you should also do an FSAVE on behalf of the yielding task and FRSTOR on behalf of the task which gets control. Otherwise, the threads will crash and burn if they use FP instructions.