CS代考 CS563 Assignment 6: Atomicity and Critical Sections

CS563 Assignment 6: Atomicity and Critical Sections
Instructor: Due: 11:59pm, March 8, 2020
1 Overview
The purpose of this assignment is to give you some practice on reasoning about atomicity, at-most- once property, and programming critical sections.

Copyright By PowCoder代写 加微信 powcoder

2 Atomicity
A process P uses three shared integer variables x, y, and z. The variable x is both read and written by other processes, whereas the variables y and z are read, but not written by other processes. Determine which of the following statements in P can be considered to be atomic, and explain why.
4. z “ x ` y;
5. await x ““ 1;
6. awaitx`y`zą0.

3 Critical Sections
Suppose a computer has atomic decrement DEC and increment INC instructions that also return the value of the sign bit of the result. In particular, the decrement instruction has the following effect:
DEC(var, sign):
=0) sign = 0; else sign = 1; >
INC is similar, the only difference being that it adds 1 to var.
Using DEC and INC, develop a solution to the critical section problem for n processes, i.e., implement the CSenter and CSexit protocols. Analyze if your solution satisfies the following properties:
• Mutual exclusion: at most one process at a time is executing its critical section;
• Absence of deadlock: if two or more processes are trying to enter their critical sections,
at least one will succeed;
• Absence of unnecessary delay: if one process is trying to enter its critical section and other processes are executing their non critical sections or have terminated, the first process is not prevented from entering its critical section;
• Eventual entry: a process that is attempting to enter its critical section will eventually succeed.
Note that the “eventual entry” property is not required for this problem, but you should still analyze it.
4 Submission
Submit the following on Blackboard:
1. A text or PDF file, with pseudo code and answers to the questions.

5 Grading Scheme
This assignment will be graded out of 100. For your information, the grading scheme is shown in the following table.
Percentage
Atomicity 30% Explanation 10% Critical Section Solution 40% Analysis 20%

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com