www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/18/08:12:44

From: achessa AT fiar DOT finmeccanica DOT it (Chessa Alberto)
To: <djgpp AT delorie DOT com>
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
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.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019