From: achessa AT fiar DOT finmeccanica DOT it (Chessa Alberto) To: Subject: How to switch threads ? Date: Fri, 18 Dec 1998 10:50:40 +0100 X-MSMail-Priority: Normal X-Priority: 3 X-Mailer: Microsoft Internet Mail 4.70.1161 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <19981218093836051.AAA445@chessa> Reply-To: djgpp AT delorie DOT com A follow the last thread on task switching since I'm involved in writing a real-time multi-thread enviroment running on PC based embedded HW. It is possible/reasonable to use the following approach ? - DPMI at ring 0 with virtual memory disable, as CWSDPR0, that do not switch stack on HW interrupt - Write a custom routine to install raw protected-mode interrupt handlers directly in the CPU Interrupt Table (get IDT base address, translate to logical, change the required slot). Of course, the handler must be written in assembler - Install a raw interrupt handler to manage the timer interrupt and use this handler to change stack (only SP) by changing the return address of the intr handler (writing onto the stack) to a routine that perform the stack switching. The IRET will return to the dispatcher instead of the interrupted point. The dispatched change stack and RET to the new thread or simple RET to the old thread (I'm writing the code - the cooperative task switching just work - but it is not yet ready to run) Thanks, Alberto.