implemented producer-consumer with semiphore