Guarded entries and deadlocks in Ada

  • Thread starter Thread starter Dafydd
  • Start date Start date
AI Thread Summary
The discussion revolves around a scenario involving three tasks: Alpha, Bravo, and Charlie, where Alpha is designed to accept calls from Bravo, which in turn accepts calls from Charlie. The entry to Alpha is conditionally guarded, preventing it from accepting calls while Bravo is executing a loop that either accepts a call from Charlie or performs a task if the call is not received. The main concern is whether Bravo could become deadlocked while waiting for Alpha to accept its call, thus blocking Charlie from proceeding. Initially, the user could not reproduce a deadlock but later confirmed that it is indeed possible, indicating that Bravo can get stuck waiting for Alpha when the entry condition is not met, leading to a situation where Charlie is also waiting for Bravo, creating a deadlock. The discussion highlights the importance of understanding task interactions and entry conditions in concurrent programming to avoid such deadlocks.
Dafydd
Messages
11
Reaction score
0
This is a pretty general question that I haven't found an answer to, so I'd really appreciate the help.

Let's say we have 3 tasks - Alpha, Bravo and Charlie, all within the one and same procedure.

Alpha takes calls from Bravo, which in turn takes calls from Charlie.

Alpha's entry is guarded by some condition, which prevents accepting a call from Bravo.

Meanwhile, Bravo has the following loop:

loop
select
accept Call_from_Charlie;
exit;
or
delay 0.0;
Alpha.Do_stuff;
end select;
end loop;

... and all Charlie does is call Bravo.Call_from_Charlie.

Now, my question is: will Bravo ever get stuck waiting for Alpha to accept its call, ignoring Call_from_Charlie until Alpha accepts the Do_stuff call, causing a deadlock with Charlie waiting for Bravo, which is in turn waiting for Alpha?

In other words, when Bravo reaches the line of code reading "Alpha.Do_stuff;", and Alpha won't accept the call because the entry is guarded, what does Bravo do?

I haven't been able to produce a deadlock this way, but I'd like to know whether it's at all possible.

EDIT: I have now been able to produce a deadlock this way. Don't know why it didn't happen the first time, but it does now.
 
Last edited:
Technology news on Phys.org
Glad to know that the logic worked out. Additionally, thanks for sharing the logic.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Replies
8
Views
800
Replies
28
Views
6K
Replies
16
Views
2K
Replies
20
Views
4K
4
Replies
175
Views
25K
Back
Top