Download Midterm-2006-7-1-Solution

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

RSTS/E wikipedia , lookup

Spring (operating system) wikipedia , lookup

Distributed operating system wikipedia , lookup

DNIX wikipedia , lookup

Unix security wikipedia , lookup

Burroughs MCP wikipedia , lookup

CP/M wikipedia , lookup

VS/9 wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
UNIVERSITY OF BAHRAIN
COLLEGE OF INFORMATION TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE
ITCS 322 – Operating Systems
Midterm
Semester I, 2006-2007
Date: November 9, 2006
Time Allowed: 1 Hour
Student Name
Student I.D.
[1] 9:00-10:00
[2] 11:00-12:00
Section
Question 1
10
Question 2
10
Question 3
10
Question 4
10
TOTAL
40
Please tick one
1
Question 1 [6+4 points]: Correct answers are in BOLD
Part 1: Select the most appropriate answer.
1. Which of the following is correct?
i. An OS is responsible for allocating resources to programs that are run
by a single user only.
ii. Files and CPU are two examples of virtual resources that are created
by the operating system from the underlying hardware
iii. An OS resolves conflicts for resource contention
iv. A user can directly interact with some components of operating
system
a. All of the above
b. (i) and (ii)
c. (iii) and (iv)
d. (i), (iii), and (iv)
2. In a multilayer view of operating systems, when a user program makes a call to an
operating system function, it is called a
a. System request
b. System response
c. Hardware instruction
d. Input
3. Which of the following were the major problems with the simple batch system?
i. I/O and processing could not be overlapped
ii. They were very secure
iii. Have high CPU utilization
iv. Have low memory utilization
a. All of the above
b. (i) and (ii)
c. (i) and (iv)
d. (ii) and (iv)
4. CPU scheduler is required in both the simple batch systems and timer sharing
interactive systems.
a. True
b. False
5. Which of the following features are required in both multi-programmed batch
systems and timesharing systems?
i. CPU scheduling
ii. Memory management
iii. On-line file system
iv. job synchronization
b. All of the above
a. (i) and (ii)
b. (iii) and (iv)
c. (i), (ii) and (iii)
6. An operating system that allows a machine to communicate with other machines
over the network as well as work independently when not connected to the
network is called?
a. Real time system
b. Distributed operating system
c. Network operating system
d. None of the above
2
Part 2
How SPOOLING technique works to overlap the CPU and I/O operations?
In spooling, jobs are read from the card reader and stored on a disk and location of
card images are kept in a table by the operating system. The output of the running
program is also sent/saved on the disk and when the job is completed then the output
was actually printed. Therefore, I/O and computations were overlapped as follows.
While executing one job, the OS: reads next job from card reader into a storage area
on the disk (job queue) and at the same time the prints the of previous job from disk
to printer.
Question 2 [7+3 points]
Part 1 Select the most appropriate answer.
1. Which of the following instructions should be privileged instructions in order to
protect memory, CPU and I/O devices?
i. Read timer
ii. Update the value of base register
iii. Push a value in a stack
iv. IN (to read directly from the keyboard)
a. All of the above
b. (i), (ii) and (iii)
c. (ii) and (iii)
d. (ii) and (iv)
2. Under which of the following conditions, a trap is generated?
i. If ( address > (base + limit) )
ii. If an overflow happens while executing a program
iii. If a keyboard sends an interrupt
iv. If printer sends an interrupt after completing a print
a. All of the above
b. (i) and (ii)
c. (i), (ii) and (iii)
d. (iii) and (iv)
3. In a dual mode operation, when a interrupt is generated, the system switches to
user mode.
a. True
b. False
4. In which of the following types of I/O, a wait instruction is required?
a. Synchronous
b. Asynchronous
3
5. When we perform a read operation from a disk, the disk controller first moves the
data
a. From disk to the local buffer of the I/O controller
b. From disk to main memory by the I/O controller
c. From main memory to local buffer of the I/O controller
d. From local buffer of the I/O controller to the CPU
6. Which
a.
b.
c.
d.
of the following I/O technique has better CPU utilization?
Programmed I/O
Interrupt-driven I/O
Loader technique
Multiprogramming I/O technique
7. Different components of the OS work independently.
a. True
b. False
Part 2. What are the major functions of file manager (file management part of an OS)?
The major functions of a file manager are:
1. File creation and deletion.
2. Directory creation and deletion.
3. Support of primitives for manipulating files and directories.
4. Mapping files onto secondary storage.
5. File backup on stable (nonvolatile) storage media.
Question 3 [6+4 points]
Part 1 Select the most appropriate answer.
1. In Unix/Linux operating system, when a process is loaded in the memory then a free
space is kept between
a. Text and data
b. Data and stack
2. Under which of the following conditions, a process may be moved from running
state to ready state?
i. When a process needs to do some I/O
ii. When a timer interrupt comes
iii. When a process completes
iv. When a high priority process come
a. All of the above
b. (i) and (ii)
c. (ii) and (iv)
d. (i), (ii) and (iv)
4
3. A medium term scheduler selects a process that is
a. In ready queue
b. In job queue
c. In Device queue
d. Swapped out
4. A short term scheduler is invoked every time
i. A process terminates
ii. a process moves to the I/O queue
iii. A process is submitted
iv. A process is interrupted due to a timer interrupt
a. All of the above
b. (i), (ii), and (iii)
c. (i), (ii), and (iv)
d. (ii), (iii), and (iv)
5. A process switch may occur when
i. A process terminates
ii. a process moves to the I/O queue
iii. A process makes a supervisor call
iv. A process is interrupted due to a timer interrupt
a. All of the above
b. (i) and (ii)
c. (i), (ii), and (iv)
d. (ii), (iii), and (iv)
6. A process that is created through a call to fork() runs independently from the
parent process.
a. True
b. False
Part 2
What is a PCB? What information is stored in it?
Each process in the operating system is represented by a process control block (PCB) –
also called a task control block. The PCB is special data structure that stores various
information related to a process. The information stored in the PCB includes:
 Process state – new, ready, running, waiting...
 Process identification information
 Unique process identifier (PID) - indexes (directly or indirectly) into
the process table.
 User identifier (UID) - the user who is responsible for the job.
 Identifier of the process that created this process (PPID).
 Program counter – To indicate the next instruction to be executed for this
process.
 CPU registers – include index registers, general purpose registers etc. so that
the process can be restarted correctly after an interrupt occurs.
 CPU scheduling information – Such as process priority, pointers to scheduling
queues etc.
 Memory-management information – Include base and limit register, page
tables etc.
 Accounting information – Amount of CPU and real time used, time limits,
account number, job or process numbers and so on.
 I/O status information – List of I/O devices allocated to this process, a list of
open files etc.
5
Question 4 [3+4+3 points].
Part 1 Select the most appropriate answer.
1. A process that has a few long CPU burst and some small I/O burst is called a
a. A CPU bound process
b. An I/O bound process
c. A ready queue process
d. A running process
2. Aging is used in which scheduling algorithm to solve the problem of starvation?
a. Shortest job first
b. Shortest remaining time first
c. Priority scheduling
d. First come first serve
3. After invoking short term scheduler, which component of the operating perform
context switching?
a. Medium term scheduler
b. Assembler
c. Long term scheduler
d. Dispatcher
Part 2 [6 points]. Consider the following set of processes to be executed on a system that
uses shortest remaining time first scheduling algorithm.
Process
Arrival time
P1
P2
P3
P4
P5
0
4
5
10
12
CPU burst
(in ms)
16
3
1
12
5
1. Show the Gantt chart.
P1
0
P2
4
P3
5
P2
6
P1
8
P5
12
P1
17
P4
25
37
6
Part 3 Consider the processes given in part 2. Some algorithm was used to do the
scheduling and the following Gantt chart was obtained.
P1
0
P2
14
P3
15
P2
16
P1
18
a. What is the waiting time for process P1?
P4
19
P1
29
P5
30
P4
35
37
[2 points]
Waiting time for P3=0+ (18-14)+(29-19)=14 ms
b. What is the turn around time of process P3 if it have the only one CPU burst?
Turn around time= waiting time+CPU burst=(15-5)+1=11 ms
7