[fpc-pascal] Re: UnicodeString comparison performance

Sven Barth pascaldragon at googlemail.com
Tue Jul 24 14:27:59 CEST 2012


Am 24.07.2012 13:21, schrieb OBones:
> Thomas Schatzl wrote:
>> This code is not thread safe at all. A thread switch after the while
>> loop and before the increment will not prevent progress on other
>> threads, so multiple threads can enter the "critical section".
> Well, yes, even if under Windows it's rare that a thread is preempted
> right in the middle of its execution. At least that's what my own
> experience has told me and why I'm calling Sleep in the while loop, so
> that the thread yields to other ones.

Windows will preempt a thread once it's time slice has run out or it 
yields it's execution. In the first case it does not matter whether the 
thread is inside some function execution, because the sheduler does not 
know about such a concept.

Regards,
Sven



More information about the fpc-pascal mailing list