Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!