(5/5)

Hire Me
(/5)

Hire Me
(5/5)

Hire Me
(5/5)

Hire Me

# Implementation for Peterson’s Algorithm for three threads another version is below.  You can assume flag and victim are volatile in the Java sense suppose we have three threads using this newest version for locking.

INSTRUCTIONS TO CANDIDATES
###### ANSWER ALL QUESTIONS
1. I gave an incorrect implementation for Peterson’s Algorithm for three threads. Another version is below.  You can assume flag and victim are volatile (in the Java sense).   Suppose we have three threads using this newest version for locking.  Is this version safe (provides mutual exclusion) and deadlock-free?

1       class Peterson implements Lock {

2       private boolean[] flag = new boolean [3];  // initially false

3       private int victim;

4       public void lock() {

5           int i = ThreadID.get();   // will = 0,1,or 2

6           int j = (i+1)%3;  int k = (i+2)%3;   // other two indices

7           flag[i] = true;

8           victim = i;

9           while ((flag[j] || flag[k]) && victim == i) { } // wait

10       }

11      public void unlock() {

12          int i = ThreadID.get();

13          flag[i] = false;

14       }

15  }

1. (20 points) Concurrency Smith has finished CS470 and is now employed by an exciting startup company. Her first task is to architect the company’s new lead project – a recipe sharing app.  In this pandemic, recipes have become huge and the company expects this to be bigger than Pinterest supporting millions of people viewing new recipes every day.  Concurrency is concerned that the decisions she makes today will come back to haunt her after product launch.   In particular, she knows she needs to use replication to (1) provide fault tolerance and (2) to improve performance.   Help her make the following choices.
• Consistency Model: She is wondering whether to utilize Sequential Consistency or Eventual consistency. What are these models and what are the cost/benefits.  Thinking about how users might interact with such a system, geographic locations, availability, etc. – what is her best option?
• Failure model: We discussed crash-stop, partition and byzantine.  After describing each mode, which do you think Concurrency’s product should tolerate and why?

## Related Questions

##### . The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

##### . Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

##### . The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

##### . Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

##### . The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

313 Experts Online