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
The _______ contains the most commonly used commands.
expeople1 [14]
The quick access toolbar contains the most commonly used commands.
8 0
3 years ago
Read 2 more answers
Any changes done to the software during the operational phase of the software before project wind up is called as maintenance. S
ruslelena [56]

Any changes done to the software during the operational phase of the software before project wind up is called as maintenance is a false statement.

<h3>What are operational phases?</h3>

The operational phase is known to be that phase in course of the making or construction where a given flow of the stresses is known to be mad in the medium via which the tunnel advances that is deviated.

Hence, Any changes done to the software during the operational phase of the software before project wind up is called as maintenance is a false statement because any change that is made to the software after it is deployed is known as maintenance.

Learn more about software from

brainly.com/question/28400365

#SPJ1

5 0
1 year ago
Where are my files shortcut in documents folder.
faust18 [17]

Answer: Search File Explorer: Open File Explorer from the taskbar or right-click on the Start menu, and choose File Explorer, then select a location from the left pane to search or browse. For example, select This PC to look in all devices and drives on your computer, or select Documents to look only for files stored there.

Explanation: hope this helps :)

4 0
2 years ago
3. When code tracing, why is it important to iteratively test parts of the program?
GenaCL600 [577]

Answer:

A. To isolate errors in the outcomes of code.

<em>Hope this helps! ^-^</em>

<em>-Isa</em>

7 0
3 years ago
Your computer is crashing on a regular basis. Which of the following is an operation available to the user that should help rese
Neko [114]

Answer

System restore

Explanation

System restore is a recovery feature that helps restore your system to the previous condition or point. Most computers have system restore disks which are an advantage to the users especially when the computer clashes.These disks are very effective when it comes to restoring the system to its initial state.

6 0
3 years ago
Read 2 more answers
Other questions:
  • The True Confessions of Charlotte Doyle begins with what is called a(n) _____.
    15·1 answer
  • If you've been a victim of identity theft, what should you do after contacting the company that reported the suspicious charge a
    9·1 answer
  • How to determine if the function f(x) = x^2 + 3 from real numbers to real numbers is Injective, surjective, or bijective
    13·1 answer
  • What is Brainly?<br><br> A.Yes<br> B.No
    12·2 answers
  • A barcode is a Select one: a. coded instruction needed to control computer hardware. b. confidential computer code required by H
    7·1 answer
  • Write a Racket two-way selection structure that will produce a list '(1 2 3) when the first element of a list named a_lst is ide
    13·1 answer
  • Why are default parameters useful? *This is JavaScript*
    7·1 answer
  • What is Stefen Salvators mom name? For the tvd fans
    12·2 answers
  • What is the meaning of FTTH
    9·2 answers
  • What is the answer ????​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!