[fpc-pascal] Use sleep in thread

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sat Feb 28 20:20:49 CET 2015


Marco van de Voort wrote:
> In our previous episode, Xiangrong Fang said:
>> BUT, that cannot be used to prioritize a thread. While you block a thread
>> using rtlevent, it can only be unblocked from another thread. While you use
>> sleep(), it still get time share of the CPU, only that it does nothing
>> until sleep finishes, right?
> 
> No, basically a sleeping thread is marked in the scheduler as "do not schedule for nn
> ticks". The thread doesn't run to evaluate if it should contiue. That is the
> scheduler/kernel's task.

Looking at the TThread documentation, since  Suspend  and  Resume  are 
deprecated should  Suspended  be similarly annotated?

Looking at 
http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization 
there are dire warnings that  TThread.Create()  shouldn't be overridden. 
Should this be in the documentation if it's a significant issue?

Sorry about the niggles, I'm currently trying to track down a race 
condition.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list