Question: c) Consider the following problem: you have implemented a ring buffer to store some incoming data. You are using an array of 56 bytes, and

c) Consider the following problem: you have implemented a ring buffer to store some incoming data.

You are using an array of 56 bytes, and each item of data is 8 bytes long.

To add data you are using the following pseudo-code:

for j=0 to 7:

buffer[i + j] = newData[j]

i = (i + 8) % 56

Later, the data specification has changed to 9 bytes long, so you change your code as follows

for j=0 to 8:

buffer[i + j] = newData[j]

i = (i + 9) % 56

but the program is producing garbage. Explain what has gone wrong. (1 mark)

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!