Re: Semaphores in Delphi
- From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx>
- Date: Mon, 05 May 2008 19:43:28 -0400
Locke wrote:
I'm trying to implement a simple semaphore to protect critical sections of code with the following procedures.It's very possible that it can slip through.
Question is are these safe, or is it possible that 2 threads could slip through EnterCritical at the same time?
Thanks
procedure EnterCritical;
begin
while semaphore do sleep(30);
semaphore:=true;
end;
procedure ExitCritical;
begin
semaphore:=false;
end;
if you use the Systems provided API's for criticalsection control,
you'll have a much better chance at handling it.
--
"I'd rather have a bottle in front of me than a frontal lobotomy"
"Daily Thought:
SOME PEOPLE ARE LIKE SLINKIES. NOT REALLY GOOD FOR ANYTHING BUT
THEY BRING A SMILE TO YOUR FACE WHEN PUSHED DOWN THE STAIRS.
http://webpages.charter.net/jamie_5"
.
- References:
- Semaphores in Delphi
- From: Locke
- Semaphores in Delphi
- Prev by Date: Re: Delphis End ?
- Next by Date: Re: Delphis End ?
- Previous by thread: Semaphores in Delphi
- Next by thread: Re: Semaphores in Delphi
- Index(es):