From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Suspicious reentrant semaphore
Date: Wed, 30 Apr 2003 12:39:08 -0500
Date: 2003-04-30T12:39:08-05:00 [thread overview]
Message-ID: <vb02ga5bun2lcc@corp.supernews.com> (raw)
In-Reply-To: MPG.19191554aff631919896ed@News.CIS.DFN.DE
Jano wrote in message ...
>Hello everybody,
>Leaving aside why I have done that (yes, poor design, I'm removing it
>anyway ;-), I would like to know if my package is right or really is
>there some race condition. Please comment on it. I know that
>Current_Task shouldn't be called inside entries (in fact Gnat doesn't
>allow it, I tried :-P) but doesn't complain about it being used in
>barriers. Anyways, I have a (maybe wrong) feel about that being related
>to the deadlock.
Why don't you use the attribute defined for this purpose? E'Caller
returns the task-id of the caller.
Claw uses a lock much like this one, and it uses E'Caller, not
Current_Task (which may not be the caller).
Here's the body of the "Get" entry from Claw:
entry Get when True is
use type Ada.Task_Identification.Task_Id;
begin
if Use_Count = 0 then
Owner_Task_Id := Get'Caller;
Use_Count := 1;
elsif Owner_Task_Id = Get'Caller then
Use_Count := Use_Count + 1;
else
requeue Wait_for_Free with abort; -- Let any timeouts
expire.
end if;
end Get;
And Wait_for_Free looks like:
entry Wait_for_Free when Use_Count = 0 is
begin
Owner_Task_Id := Wait_for_Free'Caller;
Use_Count := 1;
end Wait_for_Free;
Randy Brukardt.
next prev parent reply other threads:[~2003-04-30 17:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-29 22:04 Suspicious reentrant semaphore Jano
2003-04-30 8:06 ` Dmitry A. Kazakov
2003-05-01 12:33 ` Jano
2003-05-02 7:28 ` Dmitry A. Kazakov
2003-05-02 11:24 ` Jano
2003-05-02 20:29 ` tmoran
2003-05-05 11:24 ` Michal Morawski
2003-05-05 17:42 ` Simon Wright
2003-05-05 18:03 ` Jano
2003-05-05 20:18 ` Micha� Morawski
2003-04-30 13:07 ` Ian Broster
2003-05-01 12:33 ` Jano
2003-04-30 17:39 ` Randy Brukardt [this message]
2003-04-30 23:21 ` Peter Richtmyer
2003-05-01 4:59 ` Simon Wright
2003-05-01 12:46 ` Jano
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox