1.1)
a)
The dining philosophers is a theory thought up by E.W Dijkstra. He said that five philosophers sit at a circular dinner table with five chairs and five forks. Each philosopher wants to eat so they pick up 2 forks and after a while place them back on the table when they’re done.
Deadlock will be caused if every philosopher tries to pick up the fork to their left, as it will result in circular waiting. If the chain of waiting can be broken, deadlock will be prevented. If a philosopher picks up his left chopstick first he is known as a left and vice versa.
Preventing deadlock can be done through picking a single philosopher and making him a righty while the rest are all lefties. This can be done with numerous as long …show more content…
Process 2 requires 100ms and is entered 50ms after the first.
Process 2 will be completed first assuming each process receives 100ms of processing time per round.
Batch processing is the execution of multiple programs without the need for human interaction or intervention. Once the job has been setup it can be completed fully without the need for any additional information required from the user. Any inputs required from the user will be entered before the processing is done. An interface or script will be used to collect all the required data. Once everything is collected it will process it and return a final output.
This form of processing can have a few benefits such as being able to process information when the cpu isn’t occupied with other tasks. It doesn’t make the cpu wait mid process if more user interaction is required. Overhead is reduced due to a program only being run once for initial data collection instead of each time a new transaction is entered.
Spring batch is a batch processing framework that is designed to optimise large scale batch applications used in enterprise solutions. It includes logging, statistics, resource management and allows the user to restart or skip certain …show more content…
Only one writer may access the critical area at any time. If there is no writer busy in the critical area any number of readers can access it. In this case we use a mutex to allow concurrent threads access to shared data.
The shown solution uses a semaphore with a counter initialised to set how many readers can access the critical section at once. The writer reduces the semaphore number by the number of readers and waits for all readers to complete their process. While waiting it prevents other readers from starting. The problem with this solution is that it requires the writer to know how many readers there are and it contains a linear loop dependant on the number of readers.
This causes the writer to starve while it is waiting for all the readers to finish their job. A common solution to the problem would be to add a semaphore that waits before the write, checks if readers are 1 then signals with the previous semaphore. On the writer side it waits and signals the same as the 1st semaphore would.
Here is an