Professional Documents
Culture Documents
Section: D
Q1. Multiple choice questions (Select the correct option and make their color yellow). (20)
Note: Solve the Paper in Same sheet.
1) Working set model for page replacement is based on the assumption of ____________
a) modularity
b) locality
c) globalization
d) random access
1
9616 Abubakar
Section: D
10 Which of the following page replacement algorithms suffers from Belady’s anomaly?
(a) FIFO
(b) LRU
(c) Optimal Page Replacement
(d) Both LRU and FIFO
2
9616 Abubakar
Section: D
3
9616 Abubakar
Section: D
Section – (B)
Note: Attempt the following Questions. (Please write to the point answer) (40)
Q2. Define page fault and gave reason why page fault occurs?
Ans: PAGE FAULT:
A Page Fault is a type of exception upraised by computer hardware when a
running program accesses a new memory page that is not available on current Memory
Management Unit (MMU) into virtual address space of process called page fault.
OR
When a process accesses a page that is not available or not a part of current
working set or not present in the main memory is called page fault.
REASAON:
The main reason for page fault occurring is that when the Operating System cannot find
the data in virtual memory. Page fault usually happens when virtual memory or that virtual
addresses to real addresses becomes corrupt.
=====================================================================
Q3. Differentiate between a trap and an interrupt
ANSWER:
TRAP INTERRUPT
A signal raised from a user program. A signal to the processor emitted by
hardware.
Arrive after execution of any instruction. Can occur at the execution of any instruction.
Generated in the user program. Generated by hardware devices.
It transfers the control to trap handler. Triggers the processor to execute the
corresponding interrupt handler routine.
Also called a software interrupt. Also called a hardware interrupt.
=====================================================================
Q4. How Direct Memory Access (DMA) operations are performed?
Ans: DIRECT MEMORY ACCESS (DMA):
That feature of a computer systems that allows certain hardware subsystems to
access main system memory (RAM) independent to the central processing unit (CPU). DMA is
also used for intra-chip data transfer in multi-core processors.
HOW DMA ARE PERFORMED:
1) Initially, when any device has to send data between the device and the memory, the
device has to send DMA request (DRQ) to DMA controller.
2) The DMA controller sends Hold Request (HRQ) to the CPU and waits for the CPU to
assert the HLDA.
3) Then the microprocessor tri-states all the data bus, address bus and control over bus and
acknowledges the HOLD request through HLDA signal.
4) Now the CPU is in Hold state and the DMA controller has to manage the operations over
buses between the CPU memory, and I/O devices.
4
9616 Abubakar
Section: D
==================================================================
Q5. Differentiate between Process and threads.
ANSWER:
PROCESS THREADS
A program in execution. Part of a process.
Takes more time for creation. Takes less time for creation.
More time for context switch. Less time for context switch.
Consumes more resources. Consumes less resources.
Memory is not shared. Memory is shared.
Process communication in complex. Easy and efficient communication.
If one process crashes, it doesn’t affect other If one thread crashed all threads crashes.
processes.
=====================================================================
Section – (C)
Note: You can also solve the questions in notebook page and upload the answer. It can be
diagram or hand written.
Q6. Consider the following Reference string and apply the FIFO page replacement algorithm.
Assume that the main memory is consisting of three frames.
ANSWER:
P1 7 7 7 2 2 2 2 4 4 4 0 0 0 0 0
P2 0 0 0 0 3 3 3 2 2 2 2 1 1 1
P3 1 1 1 1 0 0 0 3 3 3 3 2 2
Page Hit = 3
FORMULA:
Page Faults = 12
Hit Ratio = No. of Hits / Total No. of References
SOLUTION:
5
9616 Abubakar
Section: D
=12/15*100
= 80% ANSWER
=====================================================================
Q7. Suppose a system has the following resources A,B and C where A represent “CPU”,B
represent “Memory” and C represent “Printers”. A= 10, B= 5, C=7. And there are five (5)
Processes. Apply the banker’s Algorithm to assign the resources to processes in a safe state.
ANSWER:
Allocated
Processes Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 4 2 2 2 1 1
P5 0 0 2 5 3 3 7 5 5 5 3 1
7 2 5 10 5 5
FORMULA:
10 – 7 = 3 for A
5 – 2 = 3 for B
7 – 5 = 2 for C
1. P1:
FOR A:
FORMULA:
Current Available = 7 – 0
FOR B:
Current Available = 5 – 1
6
9616 Abubakar
Section: D
FOR C:
Current Available = 3 – 0
2. P2:
FOR A:
Current Available = 3 – 2
FOR B:
Current Available = 2 – 0
FOR C:
Current Available = 2 – 0
3. P3:
FOR A:
Current Available = 9 – 3
FOR B:
Current Available = 0 – 0
FOR C:
Current Available = 2 – 2
7
9616 Abubakar
Section: D
4. P4:
FOR A:
Current Available = 4 – 2
FOR B:
Current Available = 2 – 1
FOR C:
Current Available = 2 – 1
5. P5:
FOR A:
Current Available = 5 – 0
FOR B:
Current Available = 3 – 0
FOR C:
Current Available = 3 – 2
Allocated
Processs Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 1 2 2
P3 3 0 2 9 0 2 6 0 0
P4 2 1 1 4 2 2 2 1 1
8
9616 Abubakar
Section: D
P5 0 0 2 5 3 3 5 3 1
7 2 5
For P1
Allocated
Processs Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 1 2 2
P3 3 0 2 9 0 2 6 0 0
P4 2 1 1 4 2 2 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
For P2
NOW,
3+2= 5 For A
3+0= 3 For B
2+0= 2 For C
Allocated
Processs Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 6 0 0
P4 2 1 1 4 2 2 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
9
9616 Abubakar
Section: D
For P3
Allocated
Processs Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 6 0 0
P4 2 1 1 4 2 2 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
For P4
Now,
5+2= 7 For A
3+1= 4 For B
2+1= 3 For C
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
For P5
Now,
7+0= 7 For A
10
9616 Abubakar
Section: D
4+0= 4 For B
3+2= 5 For C
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 7 4 5 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
For P3
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 7 4 5 2 1 1
P5 0 0 2 5 3 3 5 3 1
7 2 5
Now,
7+3= 10 For A
4+0= 4 For B
5+2= 7 For C
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 7 4 5 2 1 1
P5 0 0 2 5 3 3 10 4 7 5 3 1
7 2 5
11
9616 Abubakar
Section: D
For P1
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 7 4 5 2 1 1
P5 0 0 2 5 3 3 10 4 7 5 3 1
7 2 5
Now,
10+0= 10 For A
4+1= 5 For B
7+0= 7 For C
Allocated
Processs Max.Need Current Available Remaining need
Resources
A B C A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2 7 4 3
P2 2 0 0 3 2 2 5 3 2 1 2 2
P3 3 0 2 9 0 2 7 4 3 6 0 0
P4 2 1 1 4 2 2 4 2 2 2 1 1
P5 0 0 2 5 3 3 7 5 5 5 3 1
7 2 5 10 5 5
=====================================================================
12