Sample Exam 2
Sample Exam 2
Sample Exam 2
SECTION A
Attempt all multiple choice questions on the Test Answer Sheet. Each question is worth 1 mark.
For each question, you should select the alternative that BEST answers the question and then
record your answer on the mark sense sheet provided. There is no penalty marking employed, so
all questions should be answered, even if some responses are just your best guess. If more than
one answer is selected, the automatic marking system will treat the response as incorrect.
QUESTION 1
Which of the following is not a major reason for building distributed systems?
(a) To allow users at one site to make use of resources available at another site.
(b) To achieve computation speedup by distributing a large job across multiple machines.
(c) To allow users of the system to exchange information.
(d) To achieve greater reliability in the event of software or hardware failure.
(e) To achieve greater security than a standalone system.
QUESTION 2
Out of the following options, which one is not a valid reason for process migration?
(a) To even the workload by distributing processes (or subprocesses) across the network.
(b) To allow a process to run on a machine with specialised hardware appropriate for it.
(c) Software needed to run the process is only available on certain machines.
(d) To allow a process that is not multithreaded to be parallelised.
(e) The data accessed by the process is on a remote machine and it would be faster to move
the process than to move the data.
QUESTION 3
(a) Hazard avoidance - The system is designed so that some classes of hazard simply cannot
arise. For example, MISRA C uses a subset of the standard C language to avoid some
pitfalls in C coding.
(b) Hazard detection and removal - The system is designed so that hazards are detected and
removed before they result in an accident. For example, you need to conduct static code
analysis and remove potential risks.
(c) Damage limitation - The system includes protection features that minimise the damage
that may result from an accident. For example, you should limit the use of global
variables and always verify user inputs.
(d) MISRA C is a set of software development guidelines for developing safe software using
the C programming language. As long as you follow these guidelines, your system will
be guaranteed to be safe.
(e) None of the above
2
QUESTION 4
Which of the following statements regarding safety critical systems is false?
(a) Most accidents are a result of combinations of malfunctions rather than single failures.
(b) All software controlled complex systems have to achieve complete safety before putting
into use.
(c) Software is considered safety critical when its use in a system can result in unacceptable
risk such as death, injury, illness, damage to or loss of equipment or property, or
environmental harm.
(d) Software safety integrity level represents the required failure probability. The safety
integrity level of a function determines the development processes that should be
followed.
(e) None of the above
QUESTION 5
A file on a UNIX system has the permission value 0761. Assuming you are neither the owner of
the file, nor in the file’s group, what permissions do you have with respect to that file? (Reminder:
4=read, 2=write, 1=execute)
(a) read
(b) write
(c) execute
(d) read-write
(e) read-write-execute
QUESTION 6
A(n) _______ file is a sequence of bytes organised into blocks understandable by the system’s
linker:
(a) text
(b) source
(c) executable
(d) object
(e) data
3
QUESTION 7
int main(void) {
int arr[5];
arr[1] = 5;
arr[5] = 0;
return 0;
}
Which of the following statements is correct?
QUESTION 8
QUESTION 9
Which of the following is a unique tag, usually a number, used to identify a file within a file
system?
QUESTION 10
A(n) _______ file is a series of code sections that the loader can bring into memory and execute.
(a) text
(b) source
(c) executable
(d) object
(e) data
QUESTION 11
QUESTION 12
QUESTION 13
Which of the following statements about direct memory access (DMA) is untrue?
(a) The CPU supplies the address where memory is to be written to the DMA controller.
(b) The DMA controller triggers an interrupt on the CPU once the transfer has been
completed.
(c) Handshaking between the DMA controller and the device controller is performed via
DMA-request and DMA-acknowledge wired.
(d) The device controller signals the DMA controller when a word of data is available to
transfer.
(e) DMA requires the CPU to watch status bits and to feed data into a controller register one
byte at a time.
5
QUESTION 14
QUESTION 15
(a) files
(b) bytes
(c) sectors
(d) tracks
(e) blocks
QUESTION 16
One way to ensure that the circular wait condition never holds is ______.
(a) to impose a total ordering of all resource types and to determine whether one precedes
another in the ordering
(b) to never let a process acquire resources that are held by other processes
(c) to let a process wait for resources only if it isn’t currently holding any
(d) to allow processes to pre-empt other processes and “borrow” their resources while that
process is waiting
(e) All of the above.
6
QUESTION 17
QUESTION 18
How many more items can be inserted into the buffer (without any items being removed in the
interim)?
(a) 3
(b) 4
(c) 6
(d) 7
(e) 9
QUESTION 19
Consider a system consisting of m resources of the same type being shared by n processes. A
process can request or release only one resource at a time. This system is deadlock-free because
it does not have the necessary condition of:
QUESTION 20
Which of the following is not a valid criteria for comparing CPU scheduling algorithms?
SECTION B
QUESTION 21
Consider the following set of processes, with their arrival time and CPU burst time given in
milliseconds:
(a) Draw a Gantt chart to illustrate the execution of these processes using each of the
following CPU scheduling algorithms:
(i) FCFS (First Come, First Served)
(ii) SJF (Shortest Job First)
(iii) Shortest-remaining-time-first
(iv) RR (Round-Robin) (quantum = 1)
(v) RR (Round-Robin) (quantum = 2)
(vi) RR (Round-Robin) (quantum = 3)
(3 marks)
(b) What is the waiting time for each process in the execution of those processes using the
shortest-remaining-time-first algorithm in Part (a)?
(0.5 mark)
(c) What is the response time for each process in the execution of those processes using the
RR (quantum = 2) algorithm in Part (a)
(0.5 mark)
9
QUESTION 22
Inspect the following C code, which gets integers from the user and adds them up. Briefly
discuss which parts of the code violate MISRA C safe coding guidelines, why, and how to fix
them.
#include <stdio.h>
#define QUIT 0
#define SIZE_MAX 100
int main()
{
int num, sum;
do {
printf("Sum so far: %d\n", sum);
printf("Enter an integer number: ");
/* Read in an integer from the user */
scanf("%d", &num);
sum = sum + num;
} while (num != QUIT);
return 0;
}
(5 marks)
QUESTION 23
(a) Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB and 600 KB (in
order), how would each of the first-fit, best-fit and worst-fit algorithms place processes
of 212 KB, 417 KB, 112 KB and 426 KB (in order)? Which algorithm does the best job
at fitting these processes in memory?
(3 marks)
(b) Assuming a 1 KB page size, what are the page numbers and offsets for each of the
following address references (provided as decimal numbers):
(i) 2375
(ii) 19366
(iii) 30000
(iv) 256
(2 marks)
10
QUESTION 24
Consider the following snapshot of a system, where there are five (5) processes (P0 through P4)
which share four (4) types of resources (A through D), and matrices Allocation (defining the
resources allocated to each process), Max (defining the maximum demand of each process) and
Available (indicating the number of resources of each type).
END OF PAPER