Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following code is an endeavor to write queueing functions without disabling interrupts. Assuming that 1) all ofthe writes to the variables are atomic in

image text in transcribed

The following code is an endeavor to write queueing functions without disabling interrupts. Assuming that 1) all ofthe "writes to the variables" are atomic in the following code, and 2]) the code runs in a 32-bit processor, do you find bugs in the code? How to fix it? int iQueuel 1001 int iHead = 0; /* Place to add next item */ int iTail = 0; /* Place to add next item */ void interrupt Sourcelnterrupt(void) /* if the queue is full if ((Head + 1 == "Tail) l l iHead == 99 && iTail=0)) /* throw away the oldest element./ ++iTail: if (Tail 100) iTail = 0; iQue [iHead]= !!next value; ++iHead if (i Head =-100) i Head = 0; void SinkTaskvoid) int iValue; while (TRUE) if (iTail - iHead) iValue iOueue iT ail]; ++iTail: if (iTail100) iTail-0; !! Do something with iValue; The following code is an endeavor to write queueing functions without disabling interrupts. Assuming that 1) all ofthe "writes to the variables" are atomic in the following code, and 2]) the code runs in a 32-bit processor, do you find bugs in the code? How to fix it? int iQueuel 1001 int iHead = 0; /* Place to add next item */ int iTail = 0; /* Place to add next item */ void interrupt Sourcelnterrupt(void) /* if the queue is full if ((Head + 1 == "Tail) l l iHead == 99 && iTail=0)) /* throw away the oldest element./ ++iTail: if (Tail 100) iTail = 0; iQue [iHead]= !!next value; ++iHead if (i Head =-100) i Head = 0; void SinkTaskvoid) int iValue; while (TRUE) if (iTail - iHead) iValue iOueue iT ail]; ++iTail: if (iTail100) iTail-0; !! Do something with iValue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago