aavani at iust.ac.ir
Sun Nov 5 17:12:24 CET 2006
Thanks Michael, you are right!
I want to know how should I use Criticalsections to make my program to
print only one "here".
Michael Müller wrote:
> Am 05.11.2006 um 12:14 schrieb Colin Western:
>> Amir Aavani wrote:
>>> InitCriticalSection (cs);
>>> while true do
>>> EnterCriticalsection (cs);
>>> WriteLn ('Here!');
>>> LeaveCriticalsection (cs);
>> Each Enter.. must be matched by a Leave..., and you don't need the
loop. The standard way of doing this is:
> I'm sure that this is clear for Amir. But in his example he (and me too)
expects that the loop should stop at the second time it calls
EnterCriticalsection() because the old critical section wasn't left.
>> EnterCriticalsection (cs);
>> WriteLn ('Here!');
>> LeaveCriticalsection (cs);
> But this is not an example to show how a critical section stops another one.
> fpc-devel maillist - fpc-devel at lists.freepascal.org
More information about the fpc-devel