Operating System Questions With Their Answer
Operating System Questions With Their Answer
net/publication/279060822
CITATIONS READS
0 25,495
1 author:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Qasim Mohammed Hussein on 23 June 2015.
Memory management
Q1: Why does the computer must keep several processes in main memory?
Answer Q1
To improve both the utilization of the CPU and the speed of its response to users
Q6: Consider a user program of logical address of size 6 pages and page size is 4
bytes. The physical address contains 300 frames. The user program consists of
22 instructions a, b, c, . . . u, v . Each instruction takes 1 byte. Assume at that
time the free frames are 7, 26, 52, 20, 55, 6, 18, 21, 70, and 90.
Find the following? (10 degrees)
A) Draw the logical and physical maps and page tables?
B) Allocate each page in the corresponding frame?
C) Find the physical addresses for the instructions m, d, v, r?
D) Calculate the fragmentation if exist?
Answer Q6
Physical map
The physical address = page size * frame number + offset
The physical address of m = 4*20 +0 = 80
The physical address of d = 4*7+3 = 31
The physical address of v = 4* 6 +1 = 25
The physical address of r = 4*55+ 1= 221
The external fragmentation = 0
The internal fragmentation = 2
Q7: Consider a program consists of five segments: S0 = 600, S1 = 14 KB, S2= 100
KB, S3 =580 KB, and S4 = 96 KB. Assume at that time, the available free
space partitions of memory are 1200–1805, 50 – 150, 220-234, and 2500-3180.
Find the following:
1. Draw logical to physical maps and segment table?
2. Allocate space for each segment in memory?
3. Calculate the external fragmentation and the internal fragmentation?
4. What are the addresses in physical memory for the following logical
addresses: 0.580, (b) 1.17 (c) 2.66 (d) 3.82 (e) 4.20?
Answer Q7
S4 = 96
S0 = 600 S3 = 580
S2 = 100 S1 = 14
Logical map
External fragmentation =0.
virtual memory
Q8: Define the virtual memory? What are its advantages?
Answer Q8
Virtual memory is a technique that allows the execution of processes that are not
completely in memory.
Advantages:
1) Enables users to run programs that are larger than actual physical memory.
Q10: What are the advantages of using pager (i.e. demand paging)?
Answer Q10
1) Less swap time
2) Less I/O needed
3) Less amount of physical memory needed
4) More users
5) Faster response time
Q11: What are the differences between pager and swapper?
Answer Q11
Pager Swapper
Pager Swaps a page into memory swapper swaps the entire processes
1 when this page will be needed into memory
into memory.
Q12: How can the system distinguish between the pages that are in main memory
from the pages that are on the disk?
Answer Q12
The system uses valid-invalid bit is used. This bit is set to "valid" when the page
in memory, while it set to "invalid" when the page either not valid or is the page is
valid but is on the disk, as in the following figure.
Q13: When will the page faults occur? What is the procedure for handling the
page fault?
Answer Q13
The page fault will occur when the process tries to access a page which was not
into main memory.
The procedure for handling the page fault is:
1) Check an internal table for this process to determine whether the reference
was a valid or an invalid memory access.
2) If the reference was invalid, we terminate the process. If it was valid, but we
have not yet brought in that page, we now page it in.
3) Find a free frame.
4) Schedule a disk operation to read the desired page into the newly allocated
frame.
5) When the disk read is complete, we modify the internal table kept with the
process and the page table to indicate that the page is now in memory.
6) Restart the instruction that was interrupted by the trap. The process can now
access the page as though it had always been in memory.
Answer Q14
To measure the demand paging , the effective access time for a demand –paged
memory is calculated by:
Effective access time = (1 – p) x ma + p x page fault time
Where p: The probability of page fault, 0 < p < 1;
ma: Memory access time , ranges from 10 to 200 nanosecond.
Q16: What are the steps to modify the page-fault service routine to include page
replacement?
Answer Q16
1. Find the location of the desired page on the disk.
2. Find a free frame:
a) If there is a free frame, use it.
b) If there are no free frames, use a page-replacement algorithm to select a
victim frame.
c) Write the victim frame to the disk, change the pages table.
3. Read the desired page and store it in the free frame. Adjust the page table.
4. Restart the user process.
Q17: What are the operations of page replacement algorithm?
Answer Q17
Every page replacement algorithm is operated by the following three operations:
1) Search: To search required pages from main memory.
2) Delete: To delete the evict page from main memory.
3) Insert: To insert the page into main memory.
Q19: Consider the following page reference using three frames that are initially
empty. Find the page faults using FIFO algorithm, where the page reference
sequence: 7,0,1, 2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1?
Answer Q19
Page fault
Answer Q20
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 4 4 4 0 0 0 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0 0
1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7 7
Page fault= 12
Process synchronization
Q21: Define (1) Cooperating process (2) Independent process (3) Race condition
(4) Critical section (5) Semaphore
Answer Q21
Answer Q22
To guard against the race condition, we need to ensure that only one process at a
time can be manipulating the variable count. We require that the processes by
synchronized in some way.
Answer Q23
Each process must request permission to enter its critical section. The section of code
implementing this request is the entry section. The critical section may be followed
by an exit section. The remaining code is the remainder section. The general
structure of a typical process Pi is shown in following figure
Q24: What are the requirements of solution the critical-section problem?
Answer Q24