[fpc-pascal] Threading in FPC DOS
XHajT03 at mbox.vol.cz
Wed Jul 12 12:57:29 CEST 2006
Marco van de Voort wrote:
>> On 12 jul 2006, at 11:25, Marco van de Voort wrote:
>> > I doubt it. Note that it also probably needs enhancing of the
>> > threadinterface with a giveuptimeslice functionality, something for
>> > which
>> > now sleep(0) is abused.
>> sleep(0) is quite bad, because it may not necessarily give up any
>> timeslice. At least very short nanosleeps seem to be implemented as
>> spinning loops on Mac OS X, so maybe sleep(0) is the same.
> Do you know a correct way of doing this on *nix?
> (it is a hack nevertheless, but a much used one in Delphi code because
> Windows guarantees it, the better uses are to emulate blocking I/O, the
> worse parts for uh, everything, including updating time on a form)
I certainly don't know a general solution for *nix. However, even old
"single-task" DOS provides such a function and it's a great help that can
be provided by programmer to scheduler in the underlying OS, so *nix
systems should provide such function too, right? If they don't, you
probably don't have anything better than sleep(0) anyway.
More information about the fpc-pascal