[fpc-pascal] Threading in FPC DOS

Andreas Berger Andreas at TheBergerClan.org
Wed Jul 12 15:15:54 CEST 2006

thanks for your detailed reply :)


Vinzent Hoefler wrote:
> 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.
Now that you mention it, I have used these in the past :). BTW, The X 
version is available at what CPU's? Would it be acceptable to use this 
for FPC or should I use the normal FSAVE/FRSTOR functions? Does FPC have 
a function that tells me what processor I'm running on? In this case I 
could optimize.
>> 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.
You're right, better not to do this for a general library.

Ok, will be start to write the threads.


More information about the fpc-pascal mailing list