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
mojhsa [17]
3 years ago
10

Here are the codes for producer and consumer problems.

Computers and Technology
1 answer:
melomori [17]3 years ago
3 0

Answer:

If a switch happens during counter++ or counter--, we will get a wrong value for the counter.

Explanation:

counter++ counter--

register1 = counter register2 = counter

register1 = register1 + 1 register2 = register2 - 1

counter = register1 counter = register2

Lets consider this example, lets assume that counter=4, this simply means that there are 4 items which are produced already. Lets look at the following steps and value of counter after each step.

a) Producer process is updating counter++, this takes place at machine level, also, during that when it completed register1=counter counter=4

b) Supposing we have a context switch happen to consumer process and it is trying to update counter--, this takes place at machine level, also when it completed

register2=counter counter=4

register2=register2-1

counter=register2 counter=3

c) Lets assume that context switch happened back to producer process and it continues from where it stopped, look at step a

register1=register1+1

counter=register1 counter=5

This will make the value of counter variable to become 5. Consumption of one item is not reflected in the counter variable. To avoid this we need to allow the atomic execution of all these instructions. This implies completion of any updates on the counter, while others wait for its completion.

d) In the event a producer executes all these machine level instructions at once,then there is no inconsistency on this.

You might be interested in
How to become a web developer ?​
statuscvo [17]

Explanation:

1.By Learning web development Fundamentals.

2.Choose a development specialization.

5 0
3 years ago
Write the name of the tab, the command group, and the icon that you need to use to justify
Dafna11 [192]

Answer:

Tab: Home Tab

Command Group: Paragraph

Icon: Justify Icon

<em>The icon has no name; rather it is represented by 4 horizontal lines that are aligned on both edges</em>

<em />

Explanation:

To answer this question, I'll make use of the following attachment

<em>Where</em>

<em>1- represents the home tab</em>

<em>2 - represents the paragraph</em>

<em>3 - represents the justify icon</em>

<em />

3 0
3 years ago
A software computer error, is a error produced by the malfunctioning of a computer part. E.g. RAMImmersive Reader
Andru [333]

Answer:

? is this you question true or false because i dont know the answer yet

Explanation:

4 0
3 years ago
A(n) ___ is an action that causes something to happen.
Luden [163]
Event is an action that causes something to happen
5 0
3 years ago
Evolution of management​
Alex Ar [27]

Answer:

Evolution of Management and Evolution of Management Science. ... Evolution of the management thought is a process that began in the earlier days of humans. It began when the man found the need to live in the groups. Then, mighty men soon organized the masses and distributed them among the groups.

Explanation:

HOPE IT HELPS

6 0
2 years ago
Read 2 more answers
Other questions:
  • What is master slide and tell about master slide
    6·1 answer
  • A program that contains the following method: public static void display(int arg1, double arg2, char arg3) { System.out.println(
    15·1 answer
  • Write a C program to implement a command called ​displaycontent ​that takes a (text) file name as argument and display its conte
    9·1 answer
  • C++
    11·2 answers
  • Digital cameras always create great photographs. <br>True <br>False
    14·2 answers
  • What framework provides a simple API for performing web tasks?
    13·1 answer
  • Which of the following operating systems includes a virtual assistant?<br> Group of answer choices
    8·1 answer
  • If you can name this you get 15 points: ↑↑↓↓←→←→βα
    10·1 answer
  • Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll
    5·1 answer
  • The _________________ can be used to repair common causes of unbootable operating systems. It is based on the Windows Preinstall
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!