Download Suppose that a disk drive has 10,000 cylinders, numbered 0 to 9999

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

Distributed operating system wikipedia , lookup

DNIX wikipedia , lookup

Unix security wikipedia , lookup

VS/9 wikipedia , lookup

Spring (operating system) wikipedia , lookup

Burroughs MCP wikipedia , lookup

Process management (computing) wikipedia , lookup

CP/M wikipedia , lookup

Memory management unit wikipedia , lookup

Paging wikipedia , lookup

Transcript
King Saud University
College of Computers sciences and Information
Information Technology Department
40
Final Exam (1st semester 1428h/1429h)
CAP 332 – Introduction to Operating Systems
Student Name : ……………………..
Section Number :…………………….
Student ID : ……………………..
Serial number : …………………….
________________________________________________________________________
Q1. Fill out the crossword puzzle with the appropriate words described in the table below
[5 points]:
I
R
S
P
E
ACROSS
DOWN
2. A process waits for a long time to make progress.
1. Each process can be identified using a
unique number called.
4. What is a persistent, named collection of data?
5. State where a process is waiting to be assigned to a processor.
6. An intermediate data structure that connects between user and
kernel thread.
7. Provides an object-oriented way of implementing file systems.
8. What is the smallest addressable piece of data on a disk drive?
9. What UNIX structure is used to keep track of the sectors
allocated to a given file?
Page 1 of 10
2. A flag used to indicate that a routine
cannot proceed if a shared resource is
already in use by another routine.
3. A condition where a process is spending
more time paging than executing.
Q. State wither the following statements are true (T) or false (F) [6 points]
Binding of code and data to memory can be done at compile-time, load-time,
or execution-time.
An address generated by a CPU is referred to as a physical address
The vfork() system call in UNIX allows the child process to use the address
space of the parent.
Belady's Anomaly states that giving more memory to a process will improve
its performance.
The proportional allocation algorithm allocates available memory to each
process according to its size.
If the page-fault rate is too high, the process may have too many frames.
Paging avoids the problem of external fragmentation of memory in a multiprogramming environment.
A TLB is essential to the performance of virtual memory.
A thread may share data space with its parent.
Deadlocks can always be detected by finding a cycle in a resource allocation
graph.
In an operating system that provides virtual memory, the kernel must be
invoked to resolve every memory reference.
Increasing the page size will likely decrease working set size (in bytes).
Belady’s Anomaly is a problem that is present with all page replacement
algorithms, but it is more of a problem with First-in-First-Out (FIFO).
Threads are heavyweight processes that are generally considered much
more efficient than processes.
Page 2 of 10
The list of open files is stored in the process control block.
An inode includes a count of the number of symbolic links pointing to the
file.
The deadlock avoidance approach to eliminating deadlock does so by
requiring programs to obey certain “rules” that ensure that one of the
necessary conditions of deadlock cannot occur.
Race conditions cannot occur on a uniprocessor.
If the TLB does not contain a mapping for a page in a virtual address space
then it is known that that page does not have a corresponding frame in
physical memory.
A victim page is a page selected for swap-in to main memory.
Dining philosophers’ problem can be solved using Peterson’s solution.
Type is a file attribute.
A sequential file is a file in which any record or block can be read next.
Symbolic links are soft links.
Page 3 of 10
Q. Choose the correct answer [12 points].
1) The principle of locality of reference justifies the use of:
A) Interrupts
B) DMA
C) Cache memory
D) Virtual memory.
2) The total time to prepare a disk drive mechanism for a block of data to be read from it
is:
A) latency
B) seek time
C) transmission time
D) latency + seek time
E) latency + seek time + transmission time
3) The working set theory of program behaviour of processes running within an operating
system involves:
A) combining holes in memory
B) assigning I/O resources to processes
C) assigning the CPU to processes
D) disk scheduling mechanisms
E) the collection of pages a process uses
4) Page fault frequency in an operating system is reduced when the:
A) processes tend to be CPU bound
B) locality of reference is applicable to the processes
C) processes tend to be I/O bound
D) shortest remaining time scheduling is used
E) size of pages is reduced
5) A disk scheduling mechanism in an operating system causes the disk arm to sweep
back and forth across the disk surface servicing all requests in its path. This algorithm is:
A) First Come First Served (FCFS)
B) Shortest Seek Time First (SSTF)
C) LOOK
D) SCAN
E) none of the above.
6) The primary difference between user-level threads and kernel threads is:
A) User level threads do not use OS services via system calls, where kernel
threads require system calls.
B) User level threads are independent of each other, whereas kernel threads can
write into each other’s memory space.
C) User level threads require memory management where kernel threads do not.
D) none of the above.
Page 4 of 10
7) In a virtual memory computer system, when a virtual address is translated that is not
currently mapped to real storage, we call this a ___.
A) page fault
B) segmentation violation
C) out of bounds memory access violation
D) bus error
8) P and V are the only operations permitted on ___.
A) Condition Variables
B) Semaphores
C) Signals
D) Critical regions
E) None of the above
9) On an Intel architecture machine, Windows XP uses a page size of (hint: remember
your assignment):
A) 1KB
B) 2KB
C) 4KB
D) 8KB
E) 16KB
10) Which is the correct definition of a valid process transition within an operating
system?
A) Dispatch: ready --> running
B) Wakeup: ready --> running
C) Block: ready --> waiting
D) Timer run out: ready --> waiting
E) Timer run out: running --> waiting
11) The fairest disk-scheduling algorithm is.
A) SCAN
B) C-SCAN
C) SSTF
D) FCFS
E) LOOK
12) Operating system for which the “FAT” file system was developed:
A) DOS
B) UNIX
C) NT
D) Mac
Page 5 of 10
13) A system that requests all of its non-sharable resources in advance of execution is
preventing deadlock by denying:
A) Mutual exclusion.
B) No-preemption.
C) Hold and wait.
D) Circular wait.
14) Indirect interprocess communication takes place:
A) Directly between processes.
B) Through mailboxes.
C) Through exception conditions.
D) Through timeouts.
15) When we have a message-passing scheme between processes P and Q as: send (P,
message) and receive (Q,message), this has the following property:
A) The link may be unidirectional or bidirectional.
B) The link is associated with only one process.
C) There can be more than one link between a pair of processes.
D) The processes do not need to know each other’s identities.
16) In paging system where page size is 2048 words and the available physical memory
is equal to 2 17 = 128 K words, the length of the physical address is equal to:
A) 16 bits
B) 28 bits
C) 17 bits
D) None of the above
17) If normal memory access time is 100 nanoseconds and the cache search time is 20
nanoseconds and all 80% of the page table entries are found in the cache memory the
paged memory access time is equal to:
A) 100 ns
B) 120 ns
C) 140 ns
D) 200 ns
18) Assume a page reference string for a process with m frames (initially all empty). The
page reference string has length p with n distinct page numbers occurring in it. For any
page replacement algorithms, what is a lower bound on the number of page faults?
A) m
B) p
C) n
D) None of above
Page 6 of 10
19) The modified (dirty) bit is used for the purpose of:
A) Dynamic allocation of memory used by one process to another
B) Implementing FIFO page replacement algorithm
C) To reduce the average time required to service page faults
D) None of the above
20) If there are 64 segments, and the maximum segment size is 1024 words, the length of
logical address is:
A) 12 bits
B) 14 bits
C) 16 bits
D) 18 bits
21) In which case is trashing occurring?
A) 13% CPU and 3% disk utilization
B) 87% CPU and 3% disk utilization
C) 13% CPU and 97% disk utilization
D) None of the above
22) Which file allocation method suffers from disk fragmentation (except for internal
fragmentation in the last block)?
A) Linked list allocation
B) Contiguous allocation
C) I-nodes
D) None of the above
23) The type of paging where a page is never rolled (or swapped) into memory unless
needed is referred to as:
A) Lazy paging
B) Lazy swapper
C) Demand paging
D) None of the above
24) Which is not an operation to be performed on directories?
A) Search for a file
B) create a file
C) list a directory
D) None of the above
Page 7 of 10
Q. Suppose that a disk drive has 10,000 cylinders, numbered 0 to 9999. The driver is
currently serving a request at cylinder 1400. The queue of pending requests is, in the
order received:
100, 1200, 900, 8000, 8100, 100, 8200, 1000, 4200
Starting from the current head position, what is the total distance (in cylinders) that the
disk arm moves to satisfy all the pending requests for the following scheduling
algorithms. (For the algorithms in which the head is in constant motion, indicate the
direction in which you assume it is moving initially.) [4 points]
(a) FCFS
(b) SSTF
(c) SCAN (head moving from left to right)
(d) C-LOOK (head moving from right to left)
Q. Answer “YES (means possible)” or “NO (means impossible)” for the four empty slots
in the following table: [2 points]
Internal Fragmentation
With paging
Without paging
Page 8 of 10
External Fragmentation
Q. Consider the following information about resources in a system:
 There are two classes of allocatable resource labelled R1 and R2.
 There are two instances of each resource.
 There are four processes labelled P1 through P4.
 There are some resource instances already allocated to processes, as follows:
– one instance of R1 held by P2, another held by P3
– one instance of R2 held by P1, another held by P4
 Some processes have requested additional resources, as follows:
– P1 wants one instance of R1
– P3 wants one instance of R2
a) Draw the resource allocation graph for this system. Use the style of diagram from the
lecture notes. [3 points]
b) What is the state (runnable, waiting) of each process? For each process that is waiting,
indicate what it is waiting for. [1 point]
c) Is this system deadlocked? If so, state which processes are involved. [1 point]
Page 9 of 10
Q. The OS keeps track of free disk space by using a free-space-list. The following figure
resembles a disk drive with free spaces; you need to fill out the two tables a) and b) wit
free-pace-list, taking into account the way the algorithms use to manage free-spaces. In
part c) you need to write down the bit map for the free-space-list. [4 points]
a) Grouping ( n = 3 ).
Starting Block
Block 2
Block(s)#
3,4,5
b) Counting.
Starting Block
Block 2
Block(s)#
4
c) Bit Vector (where 1 means free space and 0 means used space).
Q. How many processes will be created when the following program is executed?
Assume that all fork system calls are successful. What will be printed? (Hint: Be careful
and draw a picture.) [2 points]
main()
Answer:
{
int i=1;
int ret_val = 1;
while(i <= 2)
{
if (ret_val == 0) { /* Child’s code */
printf("In child %d. \n", i);
exit(0);
} else { /* Parent’s code */
fork();
printf("In parent %d. \n", i);
i = i + 1;
}}}
Page 10 of 10
___________ Parent process(es)
___________ Child process(es)