www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/29/21:00:51

Message-Id: <199612300146.CAA29051@math.amu.edu.pl>
Comments: Authenticated sender is <grendel AT ananke DOT amu DOT edu DOT pl>
From: "Mark Habersack" <grendel AT ananke DOT amu DOT edu DOT pl>
Organization: Home, sweet home (Poznan, Poland)
To: "Paul Cunningham" <paul_c AT onaustralia DOT com DOT au>
Date: Mon, 30 Dec 1996 02:45:52 +0100
MIME-Version: 1.0
Subject: Re: Section registers, save them?
Reply-to: grendel AT ananke DOT amu DOT edu DOT pl
CC: djgpp AT delorie DOT com

Once upon a time (on 26 Dec 96 at 17:17) Paul Cunningham said:

> I've written a thread package using djgpp. It works fine at the
> moment but I was wondering if its necessary to save the section
> registers, EG. %cs %ds %ss %es %fs and %gs when I swap threads.
It depends on some factors. If you allocate separate stacks for every 
thread then yes, you have to save %ss among switches. %cs doesn't 
change unless you allocate separate segment (btw. there's no such 
thing as 'section' in Intel CPU nomenclature) for every thread. %es & 
%fs should be saved since you cannot tell whether any of the threads 
uses them or not (and DJGPP libc uses them at times - esp. %es). 
%gs is rather unlikely to be used, but better be safe than sorry ;-)) 
%ds should be saved for the same reason %es is.

> As I said, it works fine with all the tests I've thrown at it
> without saving them and just using their current values but I'm not
> sure if they change in certain circumstances.
Oh yes! They change. %es is being used in all the string operations. 
%fs is used when emulating far pointers, %ds might be used to access 
various segments out of the common 'flat' one used by default. %ss 
changes everytime any RMCB is called and at many other times. 

So the conclusion is: save them.

_http://ananke.amu.edu.pl/~grendel_________________________
We buy fresh bagels from the corner store where swastikas
are spat from areosols. I sit in the bar sipping iced white
russians, trying to score but nobody's pushing. And everyone
looks at everyone's faces, searching for signs and praying
for traces of a conscience in residence, are we sitting on
a barbed wire fence chasing the clouds home?

- Raw text -


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