Link to home
Start Free TrialLog in
Avatar of sunnybrad
sunnybrad

asked on

Circular queue using arrays and thread safe

Hi All:

I have to implement a circular queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Please suggest ideas to make it thread safe.

Regards

sunnybrad
Avatar of sleep_pilot
sleep_pilot

Make use of mutex to protect sections (known as critical sections) of your code that access/modify the parts of your class's data structure.  This will get you thread-safety.

As jkr mentioned, we can't do your homework for you, but we can help with specific questions.
Avatar of sunnybrad

ASKER

Its not a homework new to things, please specify pseudo code or ideas.

-sunnybrad
ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> - a int member for the current circular start
>> - a int member for the current circular end

isn't that redundant since the queue is circular?
never mind. i was thinking of circular linked list while yours was array based implementation.