The following problems are about deadlocks in Forklang programs: 1. Write a Forklang function that creates three
Question:
The following problems are about deadlocks in Forklang programs:
1. Write a Forklang function that creates three references and assigns them the name ‘a’, ‘b’, and ‘c’. After creating these three references, the program forks three concurrent tasks: the first task acquires a lock on ‘a’ and then a lock on ‘b’, the second task acquires a lock on ‘b’ and then a lock on ‘c’, and the third task acquires a lock on ‘c’
and then a lock on ‘a’. Will this program always terminate?
2. Write two Forklang programs that have a deadlock. Each program must share two locks among its threads and must use call, lock, or unlock expressions.
3. Modify your programs in the previous part such that these programs do not have deadlocks anymore.
Step by Step Answer:
An Experiential Introduction To Principles Of Programming Languages
ISBN: 9780262045452
1st Edition
Authors: Hridesh Rajan