1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
TiliK225 [7]
3 years ago
13

5.14 Describe how the compare and swap() instruction can be used to provide mutual exclusion that satisfies the bounded-waiting

requirement. (15 pts)
Computers and Technology
1 answer:
Naddik [55]3 years ago
8 0

Answer:

Explained below

Explanation:

Compare and Swap(C&S) is simply an atomic operation whereby the compare and swap operations are automatically executed.

Now compare and Swap basically needs 3 arguments namely:

- 2 old values which we will label X and Y

- 1 new value which is written in X that we will call Z

Thus, we now have; C & S = {X, Y, Z}

To explain this well, let X be a variable where X has a value of 7.

Now, if a programmer gives a program me that X be multiplied by 2,then what C&S operation will do is;

I) Y = X where Y is a new variable.

II) Result = C&S(X, Y, X*7)

Variable X is global and this means that mere than one process and more than 1 thread can see the variable X.

Now, if a process named P1 wants multiply the variable X by 7 using C&S operation, it will first make a local copy of variable X (which in this case is now the new variable Y). After that it will atomically compare X & Y and if they are equal, it will replace X with 10X.

However, if they are not equal, P1 will re-read value of X into Y and carry of C&S instruction again.

You might be interested in
Which key should you press to leave the cell as it originally was?
GREYUIT [131]
The correct answer should be A. Delete
4 0
3 years ago
The Internet may best be compared to a/an
Usimov [2.4K]
A volcano because its always erupting
3 0
3 years ago
A final class can't be extended.TrueFalse
PIT_PIT [208]

Answer:

True

Explanation:

A final class is something like sealed one and no one can inherit that further.

it is useful to lock our code or functionality from others

4 0
3 years ago
The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
marta [7]

Answer:.......

void clear(int *array, int length){

 

  if (length == 0)return;  

 

  array[0] = 0;  

 

  clear(array + 1, length-1);

}

Explanation:

The void function accepts an integer array.

7 0
3 years ago
Write a program that calculates and displays the number of minutes in a month. This program does not require any user input, and
dimulka [17.4K]

Answer:

Code to the answer is shown in the explanation section

Explanation:

import java.util.Scanner;

public class Question {

   public static void main(String args[]) {

     Scanner scan = new Scanner(System.in);

     System.out.println("Please enter the days of the month: ");

     int daysOfMonth = scan.nextInt();

     int minuteOfMonth = daysOfMonth * 60 * 24;

     System.out.println(minuteOfMonth);

   }

}

// 60 represents the number of minutes in one hour

// 24 represents the number of hours in a day

4 0
3 years ago
Other questions:
  • Question 5
    5·1 answer
  • THE DOMAIN IN AN EMAIL MESSAGE TELLS YOU THE
    11·1 answer
  • If you delete a sent message on gmail does the person still get it
    14·1 answer
  • Could Anyone Please Explain To Me What Is Supervised Learning In Machine Learning? I encourage that you explain it in simple wor
    6·1 answer
  • Vhich economic impact of computers was mentioned in this lesson?
    6·1 answer
  • Data-as-a-service began with the notion that data quality could happen in a centralized place, cleansing and enriching data and
    7·1 answer
  • I need the answer ASAP. I’ll mark brainliest if right
    5·1 answer
  • Course Aggregation Many times, departments are only interested with how students have done in courses relative to a specific maj
    14·1 answer
  • Write a Python program that prints all the numbers from 0 to 6 except 3
    8·1 answer
  • Who is famous for his three laws of robotics?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!