[fpc-devel] TMultiReadExclusiveWriteSynchronizer does not allow "read lock" promoting to a "write lock"

Inoussa OUEDRAOGO inoussa12 at gmail.com
Mon Feb 22 12:20:00 CET 2010


2010/2/19 Nikolai Zhubr <n-a-zhubr at yandex.ru>:
> 19.02.2010 23:02, Inoussa OUEDRAOGO:
>>
>> Hi
>>
>> The TMultiReadExclusiveWriteSynchronizer implementation does not allow
>> "read lock" promoting
>> to a "write lock". The program above hang in FPC 2.4 and 2.5.x while
>> working in Delphi and
>> FPC 2.2.x. It hangs at the "x.Beginwrite();" instruction. The
>> implementation clearly does
>> not support this scenario. It will be helpfull to note this in the
>> documentation.
>
> AFAIK entering exclusive lock without releasing multiple-read lock is very
> unsafe regarding deadlocks (Almost deadlock-guaranteed). Of course it is
> safe in the example, but why bother about special 1-thread scenario if
> multithreaded code will be unsafe anyway?

The case here is to note that the FPC 2.4.0 (and trunck)
implementation does not allows lock upgrading while Delphi, FPC 2.2.x
does. This will free people
some debugging time , I talking from experience.   The sample is just
a test case to show the problem.

-- 
Inoussa O.



More information about the fpc-devel mailing list