Guarded entries and deadlocks in Ada

  • Thread starter Thread starter Dafydd
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on the potential for deadlocks in Ada when using guarded entries with multiple tasks. Specifically, it examines a scenario involving three tasks: Alpha, Bravo, and Charlie, where Bravo calls Alpha, which is guarded by a condition. The user initially questioned whether Bravo could become stuck waiting for Alpha to accept its call, leading to a deadlock situation with Charlie. Ultimately, the user confirmed that a deadlock can occur under these conditions, highlighting the importance of understanding task synchronization in Ada.

PREREQUISITES
  • Understanding of Ada tasking model
  • Familiarity with guarded entries in Ada
  • Knowledge of task synchronization and potential deadlocks
  • Experience with Ada programming constructs such as select statements
NEXT STEPS
  • Research Ada task synchronization techniques
  • Learn about avoiding deadlocks in concurrent programming
  • Explore the use of protected types in Ada for safe task communication
  • Investigate the Ada 2012 features related to tasking and concurrency
USEFUL FOR

Software developers, particularly those working with concurrent programming in Ada, as well as systems engineers focused on task synchronization and deadlock prevention strategies.

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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 75 ·
3
Replies
75
Views
7K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 28 ·
Replies
28
Views
6K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 175 ·
6
Replies
175
Views
28K