COMP313 W1 2016 - Test One: UNIX
COMP313 W1 2016 - Test One: UNIX
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.
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]