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]
2 years ago
10

Here are the codes for producer and consumer problems.

Computers and Technology
1 answer:
melomori [17]2 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
What are the two types of electronic components
IrinaVladis [17]

Answer:

The two type of electronic components are Active components and passive components

Active components are parts of a circuit that rely on an external power source to control or modify electrical signals. ... - Passive components like resistors, transformers, and diodes don't need an external power source to function. These components use some other property to control the electrical signal.

5 0
2 years ago
Read 2 more answers
Molly, a technician, has been tasked with researching an emulator for the software developers to test cross-platform application
Tresset [83]

Answer:

Option (C) and (D) are the correct answers.

Explanation:

Because Hypervisor is an application or software that provides you a platform by which you can operate another application or software which is not supported to the current operating system just like, you can operate the mobile applications on your system with the help of Hypervisor software. In other words, it is an emulator that provides you the platform to operate different applications on your system.

8 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
Alekssandra [29.7K]

Answer:

kinesthetical

Explanation:

please give brainliest please and good luck :)

8 0
1 year ago
Is a MODEM required for Internet Connectivity ?<br> Yes<br> No
Pie

Answer:

you can connect to the wifi on your device it will say you are connected but the wifi will not be connected to the internet so you will be able to do nothing on it without the modem

Explanation:

4 0
2 years ago
Read 2 more answers
Systems such as smartphones, appliances, game controllers, cable set-top boxes and automobiles that contain small computers are
Setler [38]

I guess the correct answer is Embedded system.

Systems such as smartphones, appliances, game controllers, cable set-top boxes and automobiles that contain small computers are called Embedded systems.

8 0
2 years ago
Other questions:
  • Some financial institutions can be really bad about putting unexpected charges
    12·1 answer
  • A way to have cells in your spreadsheet change formats based on the value of the cells is called ________.
    8·1 answer
  • Multiple systems try to send data at the same time. The electrical impulses sent across the cable interfere with each other. Wha
    15·1 answer
  • What are the different components of the cloud architecture?
    5·2 answers
  • When does state law require drivers to use their headlights (6)
    11·2 answers
  • In real-world environments, risks and their direct consequences will most likely span across several domains. However, in the la
    12·1 answer
  • Create a loop that will output all the multiples of 5 that are greater than zero and less than 60 (do not include 60). 5, 10, 15
    10·1 answer
  • Please I need help.
    12·1 answer
  • Write any two disadvantage of First generations computers​
    14·1 answer
  • A form of segmentation that is based on user usage rate, user status, purchase occasion, and benefits sought is _________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!