[fpc-pascal] Use sleep in thread

Henry Vermaak henry.vermaak at gmail.com
Thu Feb 26 14:38:14 CET 2015


On Thu, Feb 26, 2015 at 09:23:33PM +0800, Xiangrong Fang wrote:
> ​I use rtlevent, but only meant to maintain a pool of threads, while there
> is no task for a thread it is blocked waiting for an event.
> 
> 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?  That way, it only consume a tiny amount of
> computing power while sleeping. This, in my view, is the price I have to
> pay to achieve my purpose?

How can a thread decide how it should be scheduled, without any
knowledge about the number of other threads and the load of the system?

I still think that doing the scheduling yourself, you'll be fighting
against the operating system.  If you have threads that are more urgent
than others, use the operating system specific method to help the
scheduler decide how much CPU time to give a thread.

Henry



More information about the fpc-pascal mailing list