Understanding Scheduling Algorithms: FCFS vs

. SJF Explained
School
Middlesex UK**We aren't endorsed by this school
Course
CCM 4300
Subject
Computer Science
Date
Dec 11, 2024
Pages
11
Uploaded by CommodoreSummer12790
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 1of 12School of Science and TechnologyMay 20152014-15 Academic Year Term 1Examination Paper SolutionsSOLUTIONS – NOT FOR STUDENT EYESSolutions for Module Number: CCE 2020Module Title: Protocols and Network Performance SimulationModule Tutor’s Name: GLENFORD MAPPExaminer: Prof. Muttukrishnan RajaranTime allowed: 2 HOURSTotal number of questions: 5SOLUTIONS – NOT FOR STUDENT EYES
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 2of 12Example Solution FormatATTEMPT ANY THREEQUESTIONSEach question carries 25 marksQuestion 1a) Explain the concepts of FCFS and SJF scheduling when applied to operating systems.[4 Marks]With First-Come-First- Serve (FCFS) scheduling, jobs are scheduled in the same order they arrive. SJF stands for Shortest Job First; so with SJF the shortest job are scheduled before longer jobs are scheduled.b) Look at the following list of jobs to be scheduled:JobEst. run-time130260324100556Using the FCFS scheduling policy, calculate the wait-time/run-time ratio for each process. Show how these results help us to pinpoint the main weakness of using FCFS.[8 Marks]Solution as follows:JobEst. run-timeWaiting Time Wait-time/Run-time13000260300.53290 454100920.925519238.4These results show that using FCFS means that short jobs are penalised especially when they are placed right after fairly long jobs. This in turn points to the need to use a maximum time or quantum after which other jobs are run as this reduces the delay that short jobs will experience using FCFS.c) Repeat part b) by calculating the results using the SJF algorithm. Explain why theSJF algorithm is rarely used in practical operating systems and its use as an offline optimal algorithm.[8 Marks]
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 3of 12If we use SJF then the schedule will be:JobEst. run-timeWaiting Time Wait-time/Run-time32005520.41307 0.24 260370.62 4100970.97The results show that SJF has the best wait-time/run-time ratio that is possible given accurate run-time estimations and therein lies the problem: given the open programming environment that is part of today’s operating systems where it is possible to execute programs which are downloaded over the network with different input parameters, it is very difficult to estimate how long a particular job is going to take in the modern context. Hence SJF is generally not used in modern schedulers on open programming environments such as Linux but can be used in closed environments such as small real-time systems.d) Discuss the differences between the schedulers of traditional operating systems such as Linux or Windows and a real-time operating system such as QNX.[5 Marks]Real-time Operating Systems work by maintaining a situation where key deadlines are always met. This is called hard deadline scheduling, whereas in traditional operating systems such in Linux or Windows, a soft deadline approachis used. Missing a hard deadline may result in catastrophic system failure, while missing a soft deadline usually does not end in disaster.Question 2a) Explain the ARP and RARP mechanisms as used in the TCP/IP Protocol Suite.[5 Marks]ARP is a mechanism that converts a logical address such as an IP address to a Physical Address such as an Ethernet MAC address. This is done by using a Request/Reply mechanism in which the ARP Request is broadcast at the link layer and asks for the target MAC address given that it knows the target’s IP address. The machine with the target’s IP address replies with its Ethernet MAC address allowing data to be forwarded to that machine. This reply is a unicast reply. In order to cut down on the cost of using the ARP mechanism, each device uses an ARP cache which is used to store the latest logical-to-physical address mappings.
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 4of 12RARP is a mechanism that is the opposite of ARP: it does a physical to logical mapping. For example, when a machine boots, knows its physical/MAC address; however, in order to communicate over the Internet it needs an IP address hence the RARP mechanism is used. RARP requests are also broadcast and the reply is sent as a unicast message. The reply is usually sent from a RARP Server which stores the relevant information.b) I have two local Ethernet networks, Network A and Network B, which are connected by a Wide-Area Network (WAN) also using Ethernet. The details of the arrangement is given in the Table below:MachineNetworkMAC AddressIP AddressMachine XNetwork AA4:6E:F4:59:83:EA157.124.16.20Router ANetwork AB2:34:55:10:22:10157.124.16.254Router AWANAC:AE:32:45:73.42111.17.5.8Router BWANE3:45:73:24:2A:CA111.17.5.200Router BNetwork B45:73:42:AC:AE:3296.23.56.254Machine YNetwork B45:73:E3:24:2A:CA96.23.56.25Draw a diagram showing these three networks with routers and machines.[4 Marks] The required diagram is shown below:c) If I want to send a message from Machine X to machine Y, assuming none of these machines have an ARP cac0he, how many ARPs do I need to transfer that message?[4 Marks]Machine X will have to do an ARP to find out the MAC Address of Router A. Router A will have to do an ARP to find out the MAC address of Router B. Router B will have to do an ARP to find out the MAC address of Machine Y. So, 3 ARPs are required.d) Show the format of the ARP Requests and Replies required for the transfer.[12 Marks]
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 5of 121stARP Request from Machine XSource hardware address: A4:6E:F4:59:83:EASource IP address: 157.124.16.20Target hardware address: 0.0.0.0Target IP address: 157.124.16.254The ARP reply from Router A:Source hardware address: B2:34:55:10:22:10Source IP address: 157.124.16.254Target hardware address: A4:6E:F4:59:83:EATarget IP address: 157.124.16.20==========================================2ndARP Request from Router ASource hardware address: AC:AE:32:45:73.42Source IP address: 111.17.5.8Target hardware address: 0.0.0.0Target IP address: 111.17.5.200The ARP reply from Router B:Source hardware address: E3:45:73:24:2A:CASource IP address: 111.17.5.200Target hardware address: AC:AE:32:45:73.42Target IP address: 117.17.5.8===========================================3rdARP Request from Router BSource hardware address: 45:73:42:AC:AE:32Source IP address: 96.23.56.254Target hardware address: 0.0.0.0Target IP address: 96.23.56.25The ARP reply from Machine Y:Source hardware address: 45:73:E3:24:2A:CASource IP address: 96.23.56.25Target hardware address: 45:73:42:AC:AE:32Target IP address: 96.23.56.254==========================================[4 Marks for each ARP Request/Reply] Question 3a) Discuss the concept of a sliding window protocol. [6 Marks]A sliding window protocol is a concept that ensures the steady and timely transfer of data being two endpoints. The size of the window specifies the amountof data that can be sent before the sender must wait for an acknowledgement.
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 6of 12So packets that have been sent and not acknowledged are within the window. If the window is not FULL, then new packets can also be sent. When acknowledgements are received the window “slides” over the acknowledged packets allowing more data to be sent. The size of the window is a minimum of (rwnd, cwnd); where rwnd is set according to the buffer size at the receiver and cwnd is the congestion window at the sender.b) Explain the slow start and congestion-avoidance mechanisms used in TCP[6 Marks]The slow start algorithm works by defining a window threshold called ssthresh. Starting with a cwnd of 1, the amount of data sent is doubled after every acknowledgement until ssthresh is reached. So the algorithm starts by sending one packet and then waits for an acknowledgement, it then sends two packets and then waits of an acknowledgement, etc. If there is a timeout because data or acknowledgements are lost, then the slow start algorithm is restarted. If ssthresh is reached then the algorithm is changed to a congestion avoidance algorithm. If timeout occurs, then the ssthresh value is halved and the slow start algorithm is restarted.[3 Marks]With a slow start algorithm, it is easy for congestion to be caused by several streams staring simultaneously. With the congestion avoidance algorithm, the window size is increased monotonically instead of exponentially. The congestion algorithm is employed after the slow start algorithm reaches the desired ssthreshvalue. It is also used when the three duplicate ACKs are received by the sender, indicating that the most recent data packets have been lost. In this case, ssthreshis halved and the congestion avoidance algorithm is implemented.[3 Marks]c) I have 8 packets to send on a TCP connection. Each packet is 400 bytes long. I have a congestion window size (cwnd) of 1200 bytes. However, the receiver has advertised a receive window (rwnd) of 800 bytes as this is the maximum buffer size it has allocated for this connection. Assuming that the system is not using the slow start algorithm, show how these packets will be transferred using a sliding window protocol.[6 Marks]According to the rules, my sliding window is the minimum of (cwnd, rwnd). Hencefor this example, the sliding window size is the minimum of (800, 1200) which is 800 bytes. So assuming we are not in slow start, the sender will send the first twopackets. If all two packets are correctly received, the sender’s sliding window glides over the 2 packets sent and another two packets can then be sent. This process is repeated until all the packets are sent.d) Discuss how this sequence changes if the fourth packet is lost.[7 Marks]
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 7of 12So the first two packets will be sent and they will be acknowledged. Then packets3 and 4 will be sent. At this point the sender must wait for a reply from the receiver as the window is full. The received will send an ACK acknowledging receipt of packet 3 but not packet 4. The sender will then send packet 5 and then must wait for an acknowledgement. So the receiver will send packet an acknowledgement for packet 3. The window is full, so a timeout will occur and then the sender will retransmit packets 4 and 5.The receiver acknowledges 4 and 5 so after those are acknowledged, the sender sends packets 6 and 7. After these arc acknowledged the sender send packet 8.Question 4a) Describe the concept of link-state routing.[3 Marks]In link-state routing, each node is periodically given the entire topology of the network and the nodes uses Dijkstra’s algorithm to work out its own routing table. There is no communication of routing information between nodes.b) Explain how Dijkstra’s algorithm works.[4 Marks][4 Marks]The flow diagram for Dijkstra’s algorithm is shown above:Each node has a tentative list and a permanent list. The node sets itself as the root node and then calculates the shortest distance to its neighbours using the shortest distance. If there are multiple routes to given node, if possible, the node will replace a route in the tentative table if the new route is shorter,c) Consider the following network:
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 8of 12Show how the routing table of Node A is developed using Dijkstra’s algorithm. [10 Marks]
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 9of 12d) The link between B and E now goes down. What is the new routing table for NodeA?[8 Marks]First neighbours are exactly the same, hence there is no change.
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 10of 12Question 5a) Discuss how simulation is used in:1) Academia2) Industrial companies[6 Marks, 3 Marks each]In academia, simulation is primary used to go from a prototype to an analytical model. What tends to happen is that the academics would have money to build a crude prototype. They then use simulation based on that crude prototype to buildan analytical model.In industry, simulation tends to be used to refine the analytical model in order to build a very sophisticated prototype.b) Explain the concept of Little’s Law as applied the Queuing Theory.[3 Marks]Little’s law states that number of people in the system is the product of the average arrival rate and the average time customers spend in the system. This can be represented by the equation: N = λT.c) Use Little’s Law to explain:1) Why fast food restaurants such as McDonalds are smaller than luxury restaurants like Garfunkels.[2 Marks]2) Why train stations are crowded on very rainy days.[2 Marks]1) In fast food restaurants food is produced much more quickly than more luxurious restaurants. So since T is small for fast food chains, N, the average number of people in the system = λT. So N is smaller and hence fast food places tend to be smaller than luxury restaurants. 2) On very rainy days most people go by public transport. So λ goes up. Hence since N = λT. If λ is high then N will also be high,c) An Ethernet system can be modelled as a simple queuing system. Assuming thatthere is a packet rate of 400 packets per second and each packet is displaced in 0.002 seconds. Calculate the average number of packets in the system using an M/M/1 queuing model.[9 Marks]The number of people in the system using M/M/1 queuing theory is given by:N = pho/ (1 – pho)
Background image
Solutions – not to be given to studentsCCE 2020 ExamMAY 2015Page 11of 12:where pho is the ratio of the number of packets arriving per second divided by the number of packets being server per second.So N = 400/500 /(1 – 400/500) = 0.8/0.2 = 4 packets are in the queue on average.d) Calculate by how much the service rate must be changed in part c) to reduce the average waiting time in the system by a half.[6 Marks]The average response time T = N/λSo T = 4/400 = 1/100 = 0.01 secondsIn order to halve the average waiting time means that we have an average waiting time of 0.005 seconds.So the number of people in the systems is:N= λTN = 400 * 0.005 = 2 packetsN = pho/ (1 – pho)2 = pho/(1 – pho)2(1-pho) = pho2 = 3pho: pho = 2/3But pho = λ/mu: where lamba = arrival rate and mu = service rate.2/3 = λ/mumu = (400 * 3)/2 = 600 packets per second.Hence the service rate must be increased by 100 packets per second.
Background image