0% found this document useful (0 votes)
86 views

COMP313 W1 2016 - Test One: UNIX

This document contains a practice test for the COMP313 course with questions in 4 sections: UNIX, Synchronization, Deadlock Prevention, and CPU Scheduling. The UNIX section contains questions about shell functions, file types, environment variables, and the Linux boot process. The Synchronization section defines semaphores and contains a question about fixing logical errors in a Producer/Consumer solution. The Deadlock Prevention section defines process deadlock and contains questions about drawing a resource allocation graph and applying the banker's algorithm. The CPU Scheduling section asks to create a Gantt chart for round robin scheduling and calculate average turnaround time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

COMP313 W1 2016 - Test One: UNIX

This document contains a practice test for the COMP313 course with questions in 4 sections: UNIX, Synchronization, Deadlock Prevention, and CPU Scheduling. The UNIX section contains questions about shell functions, file types, environment variables, and the Linux boot process. The Synchronization section defines semaphores and contains a question about fixing logical errors in a Producer/Consumer solution. The Deadlock Prevention section defines process deadlock and contains questions about drawing a resource allocation graph and applying the banker's algorithm. The CPU Scheduling section asks to create a Gantt chart for round robin scheduling and calculate average turnaround time.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COMP313 W1 2016 - Test One

[Total Marks = 60]

UNIX [26]
1. What are the main functions of the shell in UNIX operating systems? [2]
2. Name and describe three types of file found on UNIX operating systems. [3]
3. What does the following ACL mask indicate about a directory? rwx r-x --- [3]
4. Provide three common environment variables and describe their functionality. [3]
5. Provide three UNIX shell operators and an example for the use of each one. [3]
6. Describe the Linux boot process for PC BIOS hardware (excl. Runlevels). [8]
7. Explain what the following shell expression does: [4]
cat /data/comp313_marks | sort | head -n 10 > /data/smart_students&

Syncronisation [8]
8. Provide the formal definition of a semaphore. [3]
9. The following solution to the Producer/Consumer synchronisation problem contains logical errors.
Provide the corrections to the solution.
shared vars:
nrfull: semaphore = 1
nrempty: semaphore = N
mutexP: semaphore = 1
mutexC: semaphore = 1
buff: array [0..N-1] of message
in, out: 0..N-1 = 0
producer i: consumer j:
loop loop
... ...
create a message m P(mutexC)
P(mutexP) P(nrempty)
P(nrempty) m = buff[out];
in = in + 1 mod N out = out + 1 mod N
buff[in] = m V(nrfull)
V(nrfull) V(mutexP)
V(mutexP) consume message
... ...
endloop endloop
[5]
Deadlock Prevention [16]
10. Provide the formal definition for process deadlock. [4]
11. A system is composed of five processes, (p1, p2...p5), and two types of serially reusable resources, (R1,
R2). The system has two instances of R1 and three instances of R2.

Suppose that:
• p1 holds 1 instance of R1 and requests 1 instance of R2.
• p2 holds 1 instance of R2 and requests 1 instance of R1
• p3 holds 1 instance of R1 and requests 1 instance of R2.
• p4 requests 1 instance of R1 and holds 1 instance of R2.
• p5 requests 1 instance of R1 and requests one instance of R2.

a) Draw the resource-allocation graph for this state. [3]


b) Which, if any, of these processes are in deadlock? Provide an explanation for your answer. [3]

12. Consider the following resource allocation data for four processes competing for four resource types:
Available Max Alloc

1 4 2 0 2 2 1 2 1 1 1 0
1 0 2 1 1 0 1 0
0 1 1 2 0 1 0 2
3 2 1 3 1 2 1 0

Use the banker's algorithm to determine whether this system is in a safe state. Show all working.[6]

CPU Scheduling [10]


13. Consider a system with one processor, using round robin scheduling. In this system, new tasks are added
to the end of the ready queue. The time slice is value is 3. Now consider the following tasks:
Task Arrival Time Burst Time
T1 0 8
T2 2 8
T3 9 5
T4 15 6
T5 20 5

a) Create a Gantt chart illustrating the execution of these tasks. [5]


b) What is the average turnaround time for the tasks? [5]

You might also like