A simple game
• Two volunteers to play two threads
– Producer: produce 1 KitKat snack bar per iteration
• Step1: increment the counter on the board
• Step2: put one cookie on the table
– Consumer:
• Step1: read the counter LOUD
• Step2a: if the counter is zero, go back to step1
• Step2b: if the counter is nonzero, take a cookie from the table
• Step 3: decrement counter on the board
– Rule: only one should “operate” at any time
• You are the OS
– You decide who should operate, who should freeze
– Can you get them into “trouble” before KitKat run out?