homework 1

7
Advance Operating System Homework Assignment: 1 Code: COSC-5302 Instructor: Dr. Lawrence Osborne

Upload: sandesh-kumar

Post on 16-Jul-2016

219 views

Category:

Documents


0 download

DESCRIPTION

A

TRANSCRIPT

Page 1: Homework 1

Advance Operating System

Homework Assignment: 1

Code: COSC-5302

Instructor: Dr. Lawrence Osborne

Page 2: Homework 1

P a g e | 2

1.3 A robot B wants to cross a road, while another robot A is moving from left to right (Figure 1.2). Assuming that each robot can determine the (x, y) coordinates of both the robots, outline the program for each robot, so that they do not collide with each other. Ref fig from textbook

You can assume that (1) the clocks are synchronized and (2) the robots advance in discrete steps—with each tick of the clock, they move one foot at a time.

Solution:

Let’s assume Coordinates of robot A are (X1,Y1) Coordinates of robot B are (X2,Y2)

We will use the concept of mutual exclusion property of Distributed Systems to achieve this solution.

In this algorithm Robot A is given higher priority than Robot B. Thus only Robot B comes to halt if there is any chance of collision and wait for A’s signal to pass.

pseudocode For robot B (X2,Y2) current position of robot B. robotB(){            Boolean stop; //either true or false depending on position of robotA            . . .            Go(); } Go(){            While(true)            {                         If(stop==true)                        {

stop();// stop the vehicleelse            move_oneStep();//one step forward

Advance operating System – Homework assignment 1

Page 3: Homework 1

P a g e | 3

}}

 } 

move_oneStep(){ (X2,Y2+one_step)//Code for robotB to take a unit step(Assuming robotB is going in y direction)} isColliding(){            if(Y1+unit_step==Y2-unit_step&&X1=X2+1)                        stop=true;                        //robotB will halt                         wait();//wait for robotA to signal                         if(signal())//if robotA signals                                    Go();                                    //update values of X2 and Y2                        else                                    wait();  }  For robot A robotA(){            If(X1=X2+one_step&&Y1+(2*one_step)=Y2)                        Message();//signal robotB to move                        //update X1,Y1            Else                        //continue moving through one_step } 

1.4 On a Friday afternoon, a passenger asks a travel agent to reserve the earliest flight next week from Cedar Rapids to Kathmandu via Chicago and London. United Airlines operates hourly flights in the sector Cedar Rapids to Chicago. In the sector Chicago–London, British Airways operates daily flights. The final sector is operated by the Royal Nepal Airlines on Tuesdays and Thursdays only. Assuming that each of

Advance operating System – Homework assignment 1

Page 4: Homework 1

P a g e | 4

these airlines has an independent agent to schedule its flights, outline the interactions between the travel agent and these three airline agents, so that the passenger eventually books a flight to Kathmandu.

Solution:

Below is the interaction between Travel agent and the three airline agents for the passenger to book a flight to Kathamandu.

A) CR to Chicago Sector Cedar Rapids to Chicago operated by United Airlines hourly1. Date and time for earliest flight available to with seat availability to arrive chicago from CR for Flight2 on / before from arrival terminal of Flight2+1/2 hour buffer time2.what is the Check in Time for Flight13. What is the duration of the Flight.

B) Chicago to London Sector Chicago to London operated by British Airways Daily1. what is departure date and time for earliest flight available to london from chicago with seat availability for Flight3 on Tuesday /Thursday before check in date &time taken to reach the departure terminal for Flight3 from arrival terminal of Flight2+1/2 hour buffer time 2.what is the Check in Time for Flight23. What is the duration of the Flight.

C) London to Kathamndu Sector operated by Royal Nepal Airline Tuesdays/Thursdays1.what is the departure time of flights to Kathamandu on tuesdays/thursdays from London with seat availability.2.what is the Check in Time for Flight33. What is the duration of the Flight.

1.7 KaZaA is a system that allows users to download music files in a transparent way from another computer that may belong to a next-door neighbor or to someone halfway around the world. Investigate how this file sharing is implemented.

KaZaA uses FastTrack protocol which is a peer-to-peer(P2P) protocol. P2P systems are used for file sharing between them.

Advance operating System – Homework assignment 1

Page 5: Homework 1

P a g e | 5

Songs are stored on the Peers rather than storing on the Centralized computer. There is huge amount of information present in the servers all over the world so to download the information we use KaZaA from other machine. It avoids using of Cetral Server. Napstar uses the centralized directory and also uses the P2P systems.

1.8 A customer wants to fly from airport A to airport B within a given period of time by paying the cheapest fare. She submits the query for flights and expects to receive the reply in a few seconds. Travelocity.com, expedia.com, and orbitz.com already have such services in place. Investigate how these services are implemented.

Customer goes to the flight book website and queries for flights between airport A and airport B. After submitting the query the website searches for all the flights in a centralized database located in different server where all the flights information is stored and lists the flights for the customer. The flight details are displayed according to the customer preferences like lowest price first or seat availability.

Trace of the service implementation in flight booking websites.

1)The website server sends the request to the centralized database(Server) and gets the details of flights between Airport A and Airport B

2)The database server gives the response to the website server with the details of flights and after getting the response the website server responds to the customer with available flights.

3) The pricing criteria depends on website used.

1.10 How can a single processor system be used to implement a unidirectional ring of N processes?

Solution:

Single processor can be used to implement a unidirectional ring of N processes by using Critical section .The critical section object is a synchronization object that can be used for mutual exclusion amongst threads of a single process.

Unidirectional processes are simply ring of sequential processes. Leader election is the process of designating a single process as the coordinator of some task distributed among several processes. From the ring of N processes we have to elect a leader which will coordinate the use of the processor.

Advance operating System – Homework assignment 1

Page 6: Homework 1

P a g e | 6

Ring algorithm can be used to elect a leader amongst the N processes. The election message is passed through the ring of processes to inform the election of leader.

Advance operating System – Homework assignment 1