Your task is to tackle these problems above with your own dynamic job assignment implementation. You should write down your detailed implementation introduction in your report (5%) and run benchmark experiments on your program.
1. Your program should accept different numbers of workers to produce different number of cars. You should test your program with many combinations of input parameters (number of cars, number of spaces, number of workers) and make sure your program is bug free (10%). You need to draw a graph to show the scalability of your program with the number of workers and run time. Put the graph into your report (10%). You should analyse your output and explain the results you have (5%). Other graphs like showing the relationship of producing different number of cars with the given number of threads (Besides this one, you will get up to 5% bonus for meaningful graphs and their analysis to show the scalability of your program).
2. Your program should be able to handle deadlocks when given small number of storage space (Total 10% for this part. Coding is 5%. Explaining the reason why your implementation can handle deadlock in your report is 5%). You may include some screenshots to help you prove that without your deadlock handling code there’s deadlock and by adding your deadlock handling code there’s no deadlock. Here are some hints: a. Deadlock detection: you don’t know whether you will encounter deadlock or not ahead. But once your program detects that certain threads runs for unreasonable amount of time, you know that deadlock happens. Then you figure out a way to break the deadlock so that the production process can move on. sem_trywait() or sem_timedwait() may be useful here.
b. Deadlock prevention: once the production goal is set, you know the number of each part to achieve the goal. You also know how many spaces you have. Your program may analyse these data and assign jobs to workers properly so that deadlock will not happen for sure.
**Only Q3 and work on coding(no report) source code will be provide