The learning outcomes that are assessed by this coursework are:
1.Analyse specific programming language and library support for the development of concurrent programs
2.Apply standard concurrent algorithm design patterns
Your marked coursework and feedback will be available to you on: If for any reason this is not forthcoming by the due date your module leader will let you know why and when it can be expected. The Associate Professor Student Experienshould be informed of any issues relating to the return of marked coursework and feedback.
Late submission of coursework policy: Late submissions will be processed in accordance with current University regulations which state:
“the time period during which a student may submit a piece of work late without authorisation and have the work capped at 40% [50% at PG level] if passed is 14 calendar days. Work submitted unauthorised more than 14 calendar days after the original submission date will receive a mark of 0%. These regulations apply to a student’s first attempt at coursework. Work submitted late without authorisation which constitutes reassessment of a previously failed piece of coursework will always receive a mark of 0%.”
About this assessment
This assignment has TWO (2) parts with a total 100 marks, which will constitute 60% of your final mark for the module. Answer both parts.
The objective of this assessment is for you to demonstrate your understanding of issues related to the design and use of concurrent algorithms.
Submit your work as a single Word document or pdf document through Turnitin via the portal available on Blackboard. Write your answers to the questions in the Word or pdf document.
DO NOT submit any code, either as separate files or within your document. Any code submitted will not be marked.
Please refer to the marking grid provided.
The assignment will be marked anonymously. You will compromise this anonymity if you put your name on the work. Please include your p-number on your assignment.
A bakery shop has to provide a stream of muffins for customers. The muffins are made by a baker in the kitchen and placed on a conveyor belt. The conveyor belt carries the muffins to where the customers are waiting to buy them.
This scenario has been simulated using two processes: the baker and customer, and a shared conveyor belt implemented as a circular array called conveyor, where each space in the array can hold one muffin. There are two shared general semaphores, empty and full, and a mutex buffer_mutex. In this scenario, there is only multiple bakers and a single customer.
The pseudo-code for the baker is as follows. The baker makes use of an integer variable in for noting the next available space on the conveyor belt.
The pseudo-code for the customer is as follows. The customer makes use of an integer variable out for noting the next location on the conveyor belt that contains a muffin.
This code should be familiar to you as it is similar to the example of the Producer-Consumer problem. Only a few sentences are required for each of the questions below.
(a)Explain, in words, the purpose of the mod n statement. Explain what is the purpose of mutex buffer_mutex. What problems solves? You may wish to include simple examples.
(b)Explain what will happen if the order of semaphores in the customer changes. So, we have in line 2 signal(empty) and in line 6 wait(full). Now assume that there is a single baker and a single customer, with an infinite buffer. Explain, in words, what changes should be made and why.
Some researchers are working in a lab. Due to safety regulations, only five people are allowed in the lab at the same time. The code for each researcher is given below. It uses a semaphore lab, to represent whether there is space left in the lab for more people. S1, S2 and S3 are labels identifying the line code.
(a) There are eight researchers, A, B, C, D, E, F, G and H, working in the lab. Each researcher operates according to the above code. Your task is to give an execution trace that contains both of the following:
·The trace should show what happens when there are less than five researches in the lab and one or more of them leave.
·The trace should show what happens when there are five researchers in the lab and another researcher or several researchers want to enter.
The trace must start with an empty lab and show all the steps of each of the researchers as they enter/leave.
You must show the value of lab after each wait or signal step. Ensure that you state the initial value of lab.
If a wait operation executes, indicate whether the process succeeds or is placed in the queue. If a signal operation executes, indicate whether the value is changed or a sleeping process is woken up.
Each line of your trace should have the following format:
Statement executed including which Researcher process (e.g., M.S1 means that the researcher named M executed statement S1); the value of the lab semaphore (e.g., lab=2); whether the wait succeeded or was placed in the queue/ whether the signal changed the semaphore value or a sleeping process woke up.