Reference no: EM133002031
COMP6240 Operating Systems
Problem 1: WAR controlling:
Daintree warehouse uses small robots called WARs (Warehouse Assistance Robot) for carrying its goods between storage and docks for loading and unloading. The partial layout of the warehouse with two outbound docks and two storage sections is shown below. Track 1 and Track 2, which connect Storage 1 with Dock 1 and Storage 2 with Dock 2, respectively, intersect with each other.
WARs are simple robots which repeatedly travel back and forth in the same track, being ‘Loaded' in their trip from Storage to Dock and return ‘Unloaded' in the return trip. Each WAR has a unique number for identification but its status changes between ‘Loaded' and ‘Unloaded' from trip to trip. After initial setup, it was immediately identified that WARs operating in both tracks can collide in the intersection, therefore, Daintree employed you to solve the problem. The assigned task is as follows:
1. The intersection can become deadlocked if two WARs from different directions enter the intersection (WARs can only go forward). Collison is evident if more than one WAR enter the intersection simultaneously. So, for safety purpose, not more than one WAR is allowed to enter the intersection.
2. The solution should be starvation free. I.e. a stream of WARs from any one direction should not prevent WARs from other directions to cross the intersection.
3. There are three checkpoints (sensors) in the intersection to which each WAR reports. Add 200 ms delay after each checkpoint to simulate the time to pass the checkpoint. The system keeps track of WARs passing in each track (i.e. counts every time a WAR in a track crosses the intersection).
4. Loading and unloading of goods happen instantly (i.e. the assumption is no time is required) after a WAR crosses the intersection.
Using semaphores, design and implement an algorithm that prevents deadlock. Use threads to simulate multiple/concurrent WARs and assume that the group of WARs are constantly attempting to use the intersection from all four directions (N, S, W, E). Your program should input parameters at runtime to initialise the number of WARs from each direction. For example, the input "N=3 S=1 E=1 W=1" would indicate that the simulation should start with 3, 1, 1 and 1 WARS starting from north, south, east and west direction respectively. WARs should be numbered continuously starting from 1 (e.g. WAR-1, WAR-2 etc.) You may choose how to number the WARs but the total number of WARs from each direction (N, S, E, W) must match the input. Depending on whether a WAR is going towards the Dock or towards the Storage it will be "Loaded" or "Unloaded", respectively.
Problem 2 : Monitor Colour and Monochrome Printing:
The newly established School of Information and Physical Sciences (SIPS) at UoN bought a new multi-printer that can print both in colour and in monochrome. The multi-printer has three printing heads which can print up to three jobs in parallel. We classify a job as either Monochrome (M) or Colour (C) based on its mode of printing. However, the printer can operate in either of its two modes (Monochrome or Colour) at a time. If a Monochrome job is currently printing in the printer then the other two vacant printing heads can be used for Monochrome printing only - a Colour printing job must wait. A printing job (Monochrome or Colour) must specify beforehand the number of pages it will be printing. So the assumptions in operating the multi- printer are
• Monochrome and Colour jobs cannot be printed at the same time.
• No more than three jobs can use the printer simultaneously.
• Printing a single page takes the same time (1 sec) in all jobs.
• Each job can have different number of pages to print, therefore, can take different time to print.
• A Monochrome job with ID y (i.e. My) should NOT be served before a Monochrome job with ID x (i.e. Mx) where x < y. And the same for the Colour jobs.
• No time is wasted in job selection and dispatching.
Using monitor, design and implement an algorithm that ensures the operation of the multi-printer according to the above characteristics. Use threads to simulate multiple concurrent printing jobs. Your solution should be fair - stream of Monochrome printing jobs should not cause the Colour Printing jobs wait forever or vice versa.
Problem 3 : Colour and Monochrome Printing with semaphore:
You will need to implement a solution for Problem 2 (Colour and Monochrome Printing) using semaphore.
Using semaphore, design and implement an algorithm that ensures the operation of the multi-printer according to the above characteristics. Use threads to simulate multiple concurrent printing jobs. Your solution should be fair - stream of Monochrome printing jobs should not cause the Colour Printing jobs wait forever or vice versa.
Additional Task for COMP6240 Students: [NOT for COMP2240 students]:
In the lecture, two algorithms, namely Dekker's algorithm and Peterson's algorithm, were discussed as software approaches to mutual exclusion. A couple of other algorithms exist in the literature for the same purpose. You are asked to perform a survey on the software approaches to mutual exclusion and prepare a report on that. Your survey should include at least four different algorithms (may and may not include the above two). You should discuss the design principle, suitability of generalisation for n processes, suitability for multiprocessor/multi-core environment, relative advantages/disadvantages.
Your survey report should be between 4 and 6 pages (single space) of content, excluding cover and references.
Attachment:- Operating Systems.rar