Question 12

Implemented a bounded queue:

Read:

If queue is empty, wait till it can return a value with time out

If another thread is reading from the queue then wait till that thread is done

Remove the first element from the queue and return it

Do not block if a thread is writing into the queue

Write:

If queue is full, wait till one value is read with time out

If another thread is writing to the queue, wait till that thread is done

Write the element at the end of the queue

Do not block if a thread is reading from the queue.

[advanced_iframe securitykey=”undefined” src=”https://code.kodnest.com/” width=”100%” height=”600″]

KodNest Training New Batch is starting on 19th October 2020. Attend one week free demo classes.Register Now

New Report

Close