1. Homepage
  2. Exam
  3. [2021] Swansea - CS210 Concurrency - Final Exam - Q6 Software Transactional Memory

[2021] Swansea - CS210 Concurrency - Final Exam - Q6 Software Transactional Memory

This question has been solved
Engage in a Conversation

 6. You are given the code below for a Pot - a monitor class - in a diner problem. Here, customers can take servings and when the pot is empty a chef can refill the pot. Your task is to use the multiverse library for software transactional memory (STM) to make the following code thread safe. [5 marks]
CourseNana.COM

  CourseNana.COM

1 public class Pot { CourseNana.COM

2 private int servingCount ; CourseNana.COM

3 private int capacity ; CourseNana.COM

4 Pot ( int capacity ){ CourseNana.COM

5 this . capacity = this . servingCount = capacity ; CourseNana.COM

6 } CourseNana.COM

7 public void take () throws Exception { CourseNana.COM

8 if ( servingCount > 0){ CourseNana.COM

9 servingCount -= 1; CourseNana.COM

10 } CourseNana.COM

11 else { CourseNana.COM

12 throw new Exception (" Pot is empty ."); CourseNana.COM

13 } CourseNana.COM

14 } CourseNana.COM

15 public void refill () throws Exception { CourseNana.COM

16 if ( servingCount == 0){ CourseNana.COM

17 servingCount = capacity ; CourseNana.COM

18 } CourseNana.COM

19 else { CourseNana.COM

20 throw new Exception (" Pot is not empty yet."); CourseNana.COM

21 } CourseNana.COM

22 } CourseNana.COM

23 } CourseNana.COM

(a) Write the Finite State Process (FSP) code that models the system. Show the LTS for the SuperStore process composed of all component processes. [6 marks] CourseNana.COM

(b) Specify a safety property in FSP that ensures that there are at most three shoppers in the store at any point in time, and check the SuperStore system. Take a snapshot of the safety run using the LTSA tool, and show the results of the test. [6 marks] CourseNana.COM

(c) Provide Java code for the monitor in this problem. [5 marks] CourseNana.COM

CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Swansea University代写,CS210代写,Concurrency代写,Swansea University代编,CS210代编,Concurrency代编,Swansea University代考,CS210代考,Concurrency代考,Swansea Universityhelp,CS210help,Concurrencyhelp,Swansea University作业代写,CS210作业代写,Concurrency作业代写,Swansea University编程代写,CS210编程代写,Concurrency编程代写,Swansea Universityprogramming help,CS210programming help,Concurrencyprogramming help,Swansea Universityassignment help,CS210assignment help,Concurrencyassignment help,Swansea Universitysolution,CS210solution,Concurrencysolution,