程序代写代做代考 Java algorithm Candidate Number

Candidate Number

G6059

THE UNIVERSITY OF SUSSEX

BSc SECOND YEAR EXAMINATION
May/June 2016 (A2)

OPERATING SYSTEMS

Assessment Period: May/June 2016 (A2)

DO NOT TURN OVER UNTIL INSTRUCTED
TO BY THE CHIEF INVIGILATOR

Candidates should answer TWO questions out of THREE. If all three
questions are attempted only the first two answers will be marked.

The time allowed is ONE AND A HALF hours.

Each question is worth 50 marks.

At the end of the examination the question paper and/or answer book,
used or unused, will be collected from you before you leave the
examination room.

G6059 OPERATING SYSTEMS

1. (a) Briefly explain the three roles played by an operating system.
[10 marks]

(b) Explain the two abstractions provided by a Process. [10 marks]

(c) What resources are used when a thread is created? How do they differ
from those used when a process is created? [10 marks]

(d) Consider the following set of processes, with the length of the CPU burst
time given in milliseconds:

Process Burst Time Priority

P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2

The processes are assumed to have arrived in the order P1, P2, P3, P4,
and P5 , all at time 0.

i. Draw four Gantt charts that illustrate the execution of these
processes using the following scheduling algorithms: FCFS, SJF,
nonpreemptive priority (a smaller priority number implies a higher
priority), and RR (quantum = 1).

ii. What is the turnaround time of each process for each of the
scheduling algorithms in part (i)?

[20 marks]

2

OPERATING SYSTEMS G6059

2. (a) Race conditions are possible in many computer systems. Consider a
banking system with two methods: deposit(amount) and withdraw(amount).
These two methods are passed the amount that is to be deposited or
withdrawn from a bank account. Assume that a husband and wife share
a bank account and that concurrently the husband calls the withdraw()
method and the wife calls deposit(). Describe how a race condition is
possible and what might be done to prevent the race condition from
occurring. [20 marks]

(b) Describe the four necessary conditions for deadlock. [10 marks]

(c) Explain the difference between internal and external fragmentation.
[10 marks]

(d) Under what circumstances do page faults occur? Describe the actions
taken by the operating system when a page fault occurs. [10 marks]

3 Turn over/

G6059 OPERATING SYSTEMS

3. (a) Describe any three system calls that an operating system must provide
to perform operations on files. Also explain what the operating system
must do to perform these operations. [20 marks]

(b) Write Java code to show how the swap() instruction can be used to
provide mutual exclusion that satisfies the bounded-waiting requirement.

[30 marks]

4 End of Paper