[fpc-pascal] Threading in FPC DOS

Vinzent Hoefler JeLlyFish.software at gmx.net
Wed Jul 12 14:20:05 CEST 2006

On Wednesday 12 July 2006 11:34, Andreas Berger wrote:

> save and restore the floating point unit. I will need to do this for
> FPC, so if someone knows how to save and restore the FPU, I would
> apreciate the help.


The X-Versions are more efficient, but only available on newer CPUs.

> Ideally I could also discover (via an exception
> on first FPU usage?) if a thread needs to save/restore the FPU.

Well, I'd say, this is quite hard to do in an efficient way, because you 
need to detect the usage of MMX instructions, too. As you may recall, 
Intel decided to implement another brain damaged design and mapped the 
MMX registers onto the FPU registers.

I have to dig deep in my memory now, so take the following paragraphs 
with caution, I may be wrong (it's just too long ago):

In theory it is possible to do, but only if you have write access to the 
EFLAGS register (where you could temporarily set a flag to raise an 
exception on MMX usage). But the usual DOS-target means DPMI, which 
means privilege level 3 which means: You're just not allowed to fiddle 
around with those. IIRC, there's a ring0-mode DPMI-Host available 
(should be CWSDPR0.EXE), but this only works in real plain DOS, so the 
option to run the program inside a Windows-DOS-Box would be out 
completely, I guess.

Depending on your needs this might be ok, but as a general solution for 
FPC/GO32V2 this wouldn't be acceptable, I think.


More information about the fpc-pascal mailing list