0% found this document useful (0 votes)
18 views10 pages

Sample Exam 2

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

1

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

Which of the following statements regarding achievement of safety is false?

(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

Regarding the following C code:

int main(void) {
int arr[5];
arr[1] = 5;
arr[5] = 0;
return 0;
}
Which of the following statements is correct?

(a) The code will result in integer overflow.


(b) The code cannot be compiled successfully.
(c) The code will have expected behaviours when executed.
(d) The code will result in a buffer overflow.
(e) None of the above

QUESTION 8

System calls are used to:

(a) Open files for reading/writing


(b) Read from files
(c) Write to files
(d) Close files that are currently open
(e) All of the above

QUESTION 9

Which of the following is a unique tag, usually a number, used to identify a file within a file
system?

(a) File name


(b) File identifier
(c) File attribute
(d) File type
(e) File extension
4

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

A shared lock ________.

(a) behaves like a writer lock


(b) ensures that a file can only have a single concurrent shared lock
(c) behaves like a reader lock
(d) will prevent all other processes from accessing the locked file
(e) is provided by all operating systems

QUESTION 12

Which of the following is not considered a file attribute?

(a) File name


(b) Resolution
(c) File type
(d) Protection codes
(e) Accounting information

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

Which is the following is not a necessary condition for deadlock:

(a) Multiple processes have a shared lock on the same resource.


(b) At least one resource is held in a non-shareable mode.
(c) A process must be holding at least one resource and waiting to acquire additional resources
currently being held by other processes.
(d) Resources can only be released voluntarily by the process holding it after that process has
completed its task.
(e) A set of waiting processes {P0, P1, …, Pn} exists such that process P0 is waiting on a
resource held by P1, P1 is waiting on a resource held by P2 and so forth up to Pn, which is
waiting on a resource held by P0.

QUESTION 15

Transfers between memory and disk are performed in units of __________.

(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

A mount point is ____________.

(a) the root of the file system


(b) only appropriate for shared file systems
(c) a symbolic link between two directories
(d) the location within a file structure where a file system is attached
(e) required to be an empty directory

QUESTION 18

A multithreaded program implements a bounded-buffer solution to the producer-consumer


problem with a BUFFER_SIZE of 10. At one moment in time, the bounded-buffer variable in is
set to 7 and out is set to 4. The bounded-buffer solution is a two-variable solution that can store
BUFFER_SIZE – 1 items. The producer advances the in variable and the consumer advances the
out variable. The buffer is considered to be empty if in == out.

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:

(a) Multiple shared locks


(b) Mutual exclusion
(c) Hold and wait
(d) No preemption
(e) Circular wait
7

QUESTION 20

Which of the following is not a valid criteria for comparing CPU scheduling algorithms?

(a) CPU utilisation


(b) Throughput
(c) Turnaround time
(d) Serial processing time
(e) Response time
8

SECTION B

Attempt all questions in the examination booklets. Marks are as indicated.

QUESTION 21

Consider the following set of processes, with their arrival time and CPU burst time given in
milliseconds:

Process ArrivalTime BurstTime


P1 0 9
P2 2 2
P3 3 1
P4 5 4

(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);

printf("FINAL TOTAL: %d\n", sum);

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).

Allocation Max Available


A B C D A B C D A B C D
P0 0 0 1 2 0 0 1 2 1 5 2 0
P1 1 0 0 0 1 7 5 0
P2 1 3 5 4 2 3 5 6
P3 0 6 3 2 0 6 5 2
P4 0 0 1 4 0 6 5 6

Answer the following questions using the banker’s algorithm:


(a) What is the content of the matrix Need?
(1 mark)
(b) Is the system in a safe state, and why?
(2.5 marks)
(c) If a request from process P1 arrives for (0, 4, 2, 0), can the request be granted immediately,
and why/why not?
(2.5 marks)

END OF PAPER

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy