producer-consumer with cyclic buffer