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
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
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
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
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);
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
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
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
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