This question evaluates concurrency and synchronization skills, including thread-safe design, inter-thread communication, state tracking, and correctness properties such as race-condition avoidance and deadlock freedom.
Design and implement a thread-safe simulation for a restaurant that:
order_id
(unique integer)
item_name
(string)
cook_time_ms
(positive integer)
placeOrder(order_id, item_name, cook_time_ms)
startKitchen(num_chefs)
(starts background processing)
pickupOrder(order_id)
blocks until the specified order is ready, then returns it
shutdown()
stops background threads gracefully
N
orders with concurrent placement and pickup.
(You may assume a single process and shared memory; no networking required.)