Mostrando entradas con la etiqueta T1. Mostrar todas las entradas
Mostrando entradas con la etiqueta T1. Mostrar todas las entradas

lunes, 12 de septiembre de 2011

domingo, 11 de septiembre de 2011

Consumer-Producer (Unbounded buffer)

For the problem of the consumer-producer there are many solutions, with the condition that the buffer where unbounded we reach to the next one.

function main

function producer

function consumer


How this algorithm will solve the problem? Well in this solution the producer is free to create items at any time, the cosumer doesn't care at all.
But if the consumer want to take an item, he need to check the amount of items in stock, if the amount is zero, he will do nothing.