Demonstrate that the algorithm works using two threads

Assignment Help Computer Engineering
Reference no: EM132200856

Write a java program for the following assignment.

Assignment:

Use threads to implement Peterson's algorithm for mutual exclusion. Demonstrate that the algorithm works using two threads. One of the threads should continually print "a".

The other thread should continually print "b". Each time a thread prints, it should update a character counter (which is protected using Peterson's algorithm).

After 30 characters have been printed, the thread that prints next should print a new line and reset the character counter to 0.

All access to the character counter should reside in a critical section protected by Peterson's algorithm. All code that does not require mutual exclusion should reside outside of critical sections.

Note: You must explicitly use threads. You must also explicitly implement Peterson's algorithm for mutual exclusion. Finding some language that implements threads, the algorithm (or general mutual exclusion), as a built-in function of some command/commands will not be acceptable.

Finally, you will write a report explaining your implementation and addressing the following question:

Does Peterson's Algorithm properly implement Mutual Exclusion of the critical code section?

Be sure to address each of the six requirements for Mutual Exclusion.

1. Mutual exclusion must be enforced: Only one process at a time is allowed into its critical section, among all processes that have critical sections for the same resource or shared object.

2. A process that halts in its noncritical section must do so without interfering with other processes.

3. It must not be possible for a process requiring access to a critical section to be delayed indefinitely: no deadlock or starvation.

4. When no process is in a critical section, any process that requests entry to its critical section must be permitted to enter without delay.

5. No assumptions are made about relative process speeds or number of processors.

6. A process remains inside its critical section for a finite time only.

Reference no: EM132200856

Questions Cloud

Write a program that reads ten characters into a linked list : Write a java program that reads ten characters into a linked list and displays them in the reverse of the order in which they were read.
Write a java program with two checkboxes : Write a Java program with two checkboxes, one labeled BLUE and the other labeled ORANGE.
Reverse the order of words and displays on the console : Write a Java program that reads a file, reverses the order of words and displays on the console. The words can be on the same or separate lines.
Display a list of distinct numbers in the input : Display a list of distinct numbers in the input and the occurrence of each distinct value.
Demonstrate that the algorithm works using two threads : Use threads to implement Peterson's algorithm for mutual exclusion. Demonstrate that the algorithm works using two threads.
Write a java program that creates a one-dimensional array : Write a JAVA Program that creates a one-dimensional array and fills it with the following numbers in this given order.
What role do portals play in : Are they still as relevant as they were a few years ago? More relevant? Support your conclusion with additional research on the web.
A program to calculate rectangular and right triangles : Write a java program that calculates of rectangular and right triangles. The main function then only outputs the areas of the two calculated areas.
Demonstrate deadlock without synchronized keywoord : Write a Java program that demonstrates deadlock WITHOUT synchronized keywoord.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Create a function that takes a picture and creates a movie

Create a function that takes a picture and creates a movie with the picture slowing turning into the negative from left-to-right.

  This assignment is a case project that will enable you to

this assignment is a case project that will enable you to put to work what you have learned in this course to apply

  Building a simple fss using a simple command line interface

You are charged with building a simple file sharing system (FSS) using a simple command line interface. The FSS consists of two types of entities.

  Determine heat transfer rate from the can surface

A can of engine oil with a length of 150 mm and a diameter of 100 mm is placed vertically in the trunk of a car.

  Write a program check luminance that will input red

Write a program check Luminance that will input red, green, and blue values, and compute the luminance using the weighted average.

  How many valid hosts can each customer actually allocate

What is the new submask in binary notation for each customer?How many valid hosts can each customer actually allocate?

  How does ecommerce trend combine hardware

Describe each component What kind of people/companies might make use of this trend?

  Configuring a database

Configuring a Database

  Data communication and net-centric computing

Data Communication and Net-Centric Computing - Explain the functions of devices used for data and signal transform, i.e. how the analog voice is converted to the digital or analog signals.

  Draw uml class diagram that show relationships among classes

Draw a UML class diagram that shows the relationships among the classes used in the PushCounter program.

  Create a crossword puzzle you need to identify letters

Create an array of that size called wordArray[]; Read all the words from the file into an array called wordArray[N].

  Questionto take advantage of a string means to change the

questionto take advantage of a string means to change the first letter of each word in the string to uppercase. for

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd