Concurrent Processes

Last week (15th March 2017) I handed in my COMP104 Concurrent Processes assignment. (I aim to leave at least five days after the deadline before dicussing assignments online as that is the point at which no more submissions can be made.)

This was a variation of the Dining Philosophers Problem, a common test for concurrency algorithms.

Copyists = Philosophers

Copying & Checking ~ Thinking & Eating (Except have to copy before you can check)

Pencil & Eidograph ~ Chopsticks/Spoons (Except different tool in each hand)

copyists 7 and 0 share pencil 3
1       2                           0
3      4                            1
5      6                            2
copyists 0 and 1 share egraph 0
2         3                         1
4         5                         2
6         7                         3


The Copyists had to work in synch until each Copyist had copied and checked 5 drawings.

There were also other restrictions, such as the length of time each copyist took but the details of the assignment are beside the point.

This task was… a rollercoaster

I started off very slowly, always forgetting to take my latest version of the program to labs with me so kind of working on two versions simultaneously (or, some might say, concurrently haha). I then stopped doing any work on it whilst I worked on my COMP106 assignment. When I got back to working on this assignment, at first I struggled to work out how to synchronise the threads but, using a combination of the lecture notes; a sample assignment on the Producer-Consumer problem from previous years; and trial and error…(s, many errors…), I eventually had a working solution which I happily handed in two days early after sorting out the output display. The next day, however, I suddenly realised that Copyists 7, 0, and 1 were all sharing Pencil 0! This didn’t take long to fix but I cannot stress enough how important it is to check for logic errors. Sometimes getting the program to compile in the first place is so difficult that I’m almost afraid to check for logic errors- but, as anyone who has ever played with a Rubik’s Cube is well aware, sometimes the only way to get perfect results is to mess stuff up a bit first.

console output