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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

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