You are on page 1of 12

9616 Abubakar

Section: D

City University of Science & Information Technology


FINAL TERM PAPER Spring 2020

COURSE: OPERATING SYSTEM COURSE CODE (CSC-217)

Time Allowed 3 Hrs. Total Marks (100)

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

2) Cashing and buffering are always the same functions.


a) True.
b) False.
3) Spooling is required for devices such as:
a) Disks.
b) Network adopters.
c) Printers.
d) A computer cannot bot if it does not have the _________________.

4) Time sharing of resources by users is:


a) Based on time slices.
b) Based on input.
c) Event driven.
d) Operated by spooling.
5 Swap space exists in ____________
a) primary memory
b) secondary memory
c) cpu
d) none of the mentioned
6 List of programs waiting to be run are in :
a) Page frames.
b) Shells.
c) Background.
d) Queues.

1
9616 Abubakar
Section: D

7 Which of the following types of resources can create dead lock?


a) Shared.
b) Consumable.
c) Reusable.
d) All.
8 _____ is the concept in which a process is copied into the main memory from the secondary
memory according to the requirement.
a) Paging
b) Demand paging
c) Segmentation
d) Swapping
9 Thrashing occurs when
(a) When a page fault occurs
(b) Processes on system frequently access pages not memory
(c) Processes on system are in running state
(d) Processes on system are in waiting state

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

11 Operating System maintains the page table for ____________


a) each process
b) each thread
c) each instruction
d) each address
12 The following are valid process state:
a) Next ,running, halting.
b) Terminating , waiting, threshing.
c) Running , blocked , waiting.
d) None.
13 Long term scheduling Is performed_____:
a) Typically on submitted jobs.
b) When process must be mode from waiting to ready state.
c) On process and the ready queue.
d) All of the above.
e) What is compaction?
14 What is compaction?
a) a technique for overcoming internal fragmentation
b) a paging technique

2
9616 Abubakar
Section: D

c) a technique for overcoming external fragmentation


d) a technique for overcoming fatal error

15 The two modes of operation of in operating system are called .


a) Process in kernel.
b) Ready and running.
c) Interrupt and system.
d) Kernel and user.
16 Process is:
a) Program in high level language.
b) Contains of main memory.
c) Program in execution.
d) A job in secondary memory.
17 A program is:
a) Another name of process.
b) An active entity.
c) Passive entity.
d) All of the above.
18 The page table contains ____________
a) base address of each page in physical memory
b) page offset
c) page size
d) none of the mentioned
19 The address of a page table in memory is pointed by ____________
a) stack pointer
b) page table base register
c) page register
d) program counter
20 The threading model supported by Linux operating system is
a) Many-to-one
b) One-to-one
c) One-to-many
d) Many-to-Many

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: Attempt the given questions (40)

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.

Reference String: ( 701 203 042 303 120)

a) Calculate Page Fault Ratio


b) Page Hit Ratio

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

P P P P Hit P P P P P P Hit P P Hit

Page Hit = 3
FORMULA:
Page Faults = 12
Hit Ratio = No. of Hits / Total No. of References
SOLUTION:

PAGE FAULT RATIO

5
9616 Abubakar
Section: D

=3/15*100 => 20%

Putting the Values in the Formula of Hit Ratio:

=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:

Current Available = Total Resources – Currently Allocated

10 – 7 = 3 for A

5 – 2 = 3 for B

7 – 5 = 2 for C

1. P1:
 FOR A:

FORMULA:

Remaining Need = Max. Need – Allocated

Current Available = 7 – 0

Current Available = 7 For A

 FOR B:

Current Available = 5 – 1

6
9616 Abubakar
Section: D

Current Available = 4 For B

 FOR C:

Current Available = 3 – 0

Current Available = 3 For C

2. P2:
 FOR A:

Remaining Need = Max. Need – Allocated

Current Available = 3 – 2

Current Available = 1 For A

 FOR B:

Current Available = 2 – 0

Current Available = 2 For B

 FOR C:

Current Available = 2 – 0

Current Available = 2 For C

3. P3:
 FOR A:

Remaining Need = Max. Need – Allocated

Current Available = 9 – 3

Current Available = 6 For A

 FOR B:

Current Available = 0 – 0

Current Available = 0 For B

 FOR C:

Current Available = 2 – 2

Current Available = 0 For C

7
9616 Abubakar
Section: D

4. P4:
 FOR A:

Remaining Need = Max. Need – Allocated

Current Available = 4 – 2

Current Available = 2 For A

 FOR B:

Current Available = 2 – 1

Current Available = 1 For B

 FOR C:

Current Available = 2 – 1

Current Available = 1 For C

5. P5:
 FOR A:

Remaining Need = Max. Need – Allocated

Current Available = 5 – 0

Current Available = 5 For A

 FOR B:

Current Available = 3 – 0

Current Available = 3 For B

 FOR C:

Current Available = 3 – 2

Current Available = 1 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 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

Remaining need is less than Current available so it cannot complete.

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

Remaining need is greater than Current available so it has completed.

NOW,

Calculating Current Available for P2:

Current available For P 2=Current Available for P 1+ Allocated for P 2

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

Remaining need is less than Current available so it cannot complete.

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

Remaining need is greater than Current available so it has completed.

Now,

Calculating Current Available for P4

Current available For P 4=Current Available for P 2+ Allocated for P 4

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

Remaining need is greater than Current available so it has completed.

Now,

Calculating Current Available

Current available=Current Available for P 3+ Allocated for P 5

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

Remaining need is greater than Current available so it has completed.

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,

Calculating Current Available

Current available=Current Available for P 4+ Allocated for P 3

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

Remaining need is greater than Current available so it has completed.

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,

Calculating Current Available

Current available=Current Available for P 5+ Allocated for P 1

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

You might also like