(5/5)

# 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
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() {

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?

(5/5)

## Related Questions

##### . Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

##### . The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

##### . 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. The LineItem class will represent an individual

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

##### . SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

##### . Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Hire Me

Hire Me