a). Does this algorithm enforce mutual exclusion? Explain.
b). Does this algorithm avoid dead lock? Explain
c). What is the primary deficiency with this algorithm?
b). Yes, since they take turns one process should always be able to enter the critical section
c). It forces the processes to take turns in a strict alternation, so if one process wants to enter the critical section more frequently than the other, it cannot. Finally, it wastes time busy waiting
Sets found in the same folder
Other sets by this creator
(Math: The Complex class) A complex number is a number in the form , where and are real numbers and is . The numbers and are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas:
You can also obtain the absolute value for a complex number using the following formula:
(A complex number can be interpreted as a point on a plane by identifying the values as the coordinates of the point. The absolute value of the complex number corresponds to the distance of the point to the origin, as shown in Figure .)
Design a class named Complex for representing complex numbers and the methods add, subtract, multiply, divide, and abs for performing complex-number operations, and override tostring method for returning a string representation for a complex number. The tostring method returns as a string. If is , it simply returns a. Your Complex class should also implement Coneable and Comparable. Compare two complex numbers using their absolute values.
Provide three constructors Complex(a, b), Complex(a), and Complex(). Complex( ) creates a Complex object for number , and Complex(a) creates a Complex object with for . Also provide the getRealPart () and getImaginaryPart() methods for returning the real part and the imaginary part of the complex number, respectively.
Draw the UML class diagram and implement the class. Write a test program that prompts the user to enter two complex numbers and displays the result of Figure (a) The program takes a string argument that consists of operand1, operator, and operand2 from the command line and displays the expression and the result of the arithmetic operation. (b) A complex number can be interpreted as their addition, subtraction, multiplication, division, and absolute value. Here is a sample run:
Enter the first complex number: 3.5 5.5 Enter the second complex number: –3.5 1 (3.5 + 5.5i) + (–3.5 + 1.0i) = 0.0 + 6.5i (3.5 + 5.5i) – (–3.5 + 1.0i) = 7.0 + 4.5i (3.5 + 5.5i) * (–3.5 + 1.0i) = –17.75 + –15.75i (3.5 + 5.5i) / (–3.5 + 1.0i) = –0.5094 + –1.7i |(3.5 + 5.5i)| = 6.519202405202649