[fpc-pascal] Threading in FPC DOS
    Andreas Berger 
    Andreas at TheBergerClan.org
       
    Wed Jul 12 13:34:20 CEST 2006
    
    
  
> Since Dos can have multiple ways of multitasking (it could e.g. also plug in
> to DV or Win3.x or TopView via int 2FH etc) this model seems advisable to me.
>
> I assume you are implementing a basic fixed timeslicer?  What are you going
> to use it for btw?  This because DV/X (which is free nowadays) afaik gives
> you preemptive scheduling on Dos.
>   
DV is not suitable since it is a multi-tasker but does not have a 
multithreading library (at least I don't think so). I want to implement 
TThread so that I can have threads running in the background. Basically 
the threading system will have:
- Implement full TThread functionality.
- Protection of int21. When a thread is using int21, other threads that 
try to use it are blocked until the first thread releases int21. I will 
probably make keyboard reads non-blocking (of int21) as well.
- When the first thread is created, the main application becomes a 
thread as well. (ei. multi-treading is enabled). The main thread can not 
be deleted.
I already have a good threading library for Watcom C, but it is only for 
systems that don't use floating point since I don't know how to 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. Ideally I could also discover (via an exception on first FPU 
usage?) if a thread needs to save/restore the FPU. This would greatly 
speed up swapping of FPU-free threads.
Regards,
Andreas
    
    
More information about the fpc-pascal
mailing list