Re: [fpc-devel] Mutex!

2006-11-06 Thread Amir Aavani
What you suggested is a kind of busy waiting. But I want a suspension. In a message , i described my main problem which was a while like this. while true do begin ReadLn (S); /// Lock Mutex AThread:= TMyThread.Create (True);//Suspended AThread.Prepare (S); AThread.Resume; ///UnLock Mutex end; A

Re: [fpc-devel] Mutex!

2006-11-05 Thread Vinzent Höfler
Amir Avani wrote: Thanks Michael, you are right! I want to know how should I use Criticalsections to make my program to print only one "here". By not using them at all? count := 0; while true do begin if count = 0 WriteLn ('Here!'); count := 1; end {while}; Critical sections do

Re: [fpc-devel] Mutex!

2006-11-05 Thread Amir Avani
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 >>> begin >>>EnterCr

Re: [fpc-devel] Mutex!

2006-11-05 Thread Michael Müller
Am 05.11.2006 um 12:14 schrieb Colin Western: Amir Aavani wrote: InitCriticalSection (cs); while true do begin EnterCriticalsection (cs); WriteLn ('Here!'); end; LeaveCriticalsection (cs); Each Enter.. must be matched by a Leave..., and you don't need the loop. The standard wa

Re: [fpc-devel] Mutex!

2006-11-05 Thread Colin Western
Amir Aavani wrote: InitCriticalSection (cs); while true do begin EnterCriticalsection (cs); WriteLn ('Here!'); end; LeaveCriticalsection (cs); Each Enter.. must be matched by a Leave..., and you don't need the loop. The standard way of doing this is: EnterCriticalsection (cs);

Re: [fpc-devel] Mutex!

2006-11-05 Thread Peter Vreman
At 06:09 5-11-2006, you wrote: Let me explain the problem with more details, consider the following code: while true do begin ReadLn (S); /// Lock Mutex AThread:= TMyThread.Create (True);//Suspended AThread.Prepare (S); AThread.Resume; ///UnLock Mutex end; ... To understand the EnterCriti

Re: [fpc-devel] Mutex!

2006-11-04 Thread Amir Aavani
Let me explain the problem with more details, consider the following code: while true do begin ReadLn (S); /// Lock Mutex AThread:= TMyThread.Create (True);//Suspended AThread.Prepare (S); AThread.Resume; ///UnLock Mutex end; ... To understand the EnterCriticalsection, I write the followin

Re: [fpc-devel] Mutex!

2006-11-04 Thread Ales Katona
There's no "visible" mutex interface in fpc right now. ATM all non-windows platforms have semaphores in the ThreadManager but the windows ones afaik don't. I think you can simply use CriticalSection instead of mutex to achieve what you need. Ales ___ f

[fpc-devel] Mutex!

2006-11-04 Thread Amir Aavani
Is there any implementation for Mutex in FPC? I have a piece of code in a procedure that I want to be accessible from one of many available threads, at a time. While searching I found a post that announced Mutex is not implemented in FPC and suggest to use RTLCiticalSection (http://lists.free