Ask Java Expert


Home >> Java

Operating Systems Assignment -

Problem 1: Sharing the Bridge

A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge to deliver produce to the other island, return back to their island and this is repeated indefinitely. It takes a farmer carrying produce 20 steps to cross the bridge. Once a farmer (say a North Island farmer identified as N_Farmer1) crosses the bridge (from North Island to South Island) he just attempts to cross the bridge in the opposite direction (from South Island to North Island) and so on. Note that the ID of the farmer does NOT change.

The bridge can become deadlocked if a northbound and a southbound farmer are on the bridge at the same time (New Zealand farmers are stubborn and will not back up). The bridge has a large neon sign above it indicating the number of farmers that have crossed it in either direction. The neon sign counts multiple crossing by the same farmer.

Using semaphores, design and implement an algorithm that prevents deadlock. Use threads to simulate multiple/concurrent farmers and assume that the stream of farmers are constantly attempting to use the bridge from either direction. Your program should input parameters at runtime to initialise the number of farmers from each direction. For example [N=5, S=5] would indicate a constant stream of 5 farmers from each direction wanting to use the bridge. You also make sure that the solution is starvation-free (the situation in which northbound farmers prevent southbound farmers from using the bridge, or vice versa should not occur).

Problem 2: Ice-cream time

A new ice-cream parlour has been opened at Shortland Student Hub. The parlour does not offer take away service but there is only five seats in the parlour to eat in. A customer may arrive to the parlour at any time and may take a certain time to finish his ice-cream. The manager chooses a peculiar rule to serve his customers. If a customer arrives when there is an empty seat, then the customer can immediately take a seat. However, if all the five seats are occupied (i.e. there are five customers enjoying their ice-creams at any instant) then all the arriving customers have to wait for the entire party (all current customers) to leave before they can get their seats.

Using semaphores design and implement an algorithm that manages the customers entering and leaving the ice-cream parlour in line with manager's rules. Use threads to simulate multiple/concurrent customers. Your solution must be fair - starvation free. Assume no time is wasted in taking seat, serving/starting eating ice-cream and leaving the parlour.

Problem 3: Hot or Iced Coffee?

School of EEC, UoN bought a coffee machine that can serve both iced and hot coffee for the staffs. The coffee machine has three dispensing heads which can serve three clients (staffs) in parallel. We call a staff Hot Client (H) if (s)he is looking for hot coffee and a Cold Client (C) if (s)he is looking for cold coffee. However, the machine can operate in either of its two modes (hot or cold drink) at a time. If a Hot Client has started to make coffee in the machine then the other two vacant dispersers can serve hot coffee only - a Cold Client must wait. A client (Hot or Cold) can choose the brew strength by choosing the brew time at the beginning. So the assumptions in operating the coffee machine are

  • Hot and Cold clients cannot use the machine at the same time.
  • No more than three clients can use the machine simultaneously.
  • Each client can choose different time to brew his coffee.

Using monitor, design and implement an algorithm that ensures the operation of the coffee machine according to the above characteristics. Use threads to simulate multiple/concurrent clients. Your solution should be fair - stream of Hot Clients should not prevent a Cold Client from using the coffee machine or vice versa. A Hot Client with ID y (i.e. Hy) should not be served before a HOT Client with ID x (i.e. Hx) where x < y. And the same for the cold clients.

Programming Language: The preferred programming language is Java.

If you wish to use any language other than the preferred programming language, you must first notify the course demonstrator.

User Interface: There are no marks allocated for using or not using a GUI - the choice is yours.

Input and Output: Your program should accept data from an input file of name specified either as a command line argument (for non-GUI solutions) or using a file dialogue (for GUI solutions). The sample inputs are shown above to demonstrate the expected formatting for inputs. Your submission will be tested with the above data and with other input files.

Your program should output to standard output (for non-GUI solutions) or to a text area (for GUI solutions). Output should be strictly in the shown output format.

Attachment:- Assignment File.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M93122958

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As