Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started