La Pasticceria

A famous pastry shop in Pisa produces cream-puffs (in Italian:
bignè). The shop can store in its drawers at most N cream puffs. There
is only one baker in the shop. The baker produces new cream puffs (two
at a time) only when there is space in the drawers of the shop;
otherwise, it blocks.

Two kind of customers buy at the shop. Slim customers buy and eat only
one pastry at a time, whereas fat customers buy and eat 3 pastries at
a time.  The baker's policy is to give precedence to the fat
customers, (because they buy a lot of cream puffs, and also to avoid
their “starvation”).  The customers arrives to the shop, and buy cream
puffs. Customers are served one at a time.  If there are not enough
cream puffs, or if it’s not his turn, the customer blocks. The
precedence order between different customers of the same kind is not
important.  The candidate has to write some part of a multi-thread
program that simulates the pastry shop, along the following
guidelines:

– Model the number of cream puffs in the shop with an integer;

– all the people (baker and customers) are simulated by threads.

You have to:

– write the data structure shop_t that represents the status of the
  pastry shop and that is used to handle the concurrency between the
  baker and the customers (including the synchronization mechanisms
  that are necessary to block the threads).

– write the function confectioner_produce_two() called by the baker's
  thread;

– write functions slim_customer_buy_one(), and fat_customer_buy_three()
  called by the two different kind of customer's threads.

DO NOT

– write the main() function

– the code of the threads 
