0% found this document useful (0 votes)
4 views2 pages

OS Final Spring'24

This document outlines the final exam for the Operating Systems course at the National University of Computer and Emerging Sciences, Karachi Campus. It includes instructions, a list of instructors, and five main questions covering topics such as synchronization, virtual memory management, system calls, mult-process architecture, and scheduling mechanisms. Each question specifies marks and requires answers in bullet points or code snippets.

Uploaded by

k230517
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

OS Final Spring'24

This document outlines the final exam for the Operating Systems course at the National University of Computer and Emerging Sciences, Karachi Campus. It includes instructions, a list of instructors, and five main questions covering topics such as synchronization, virtual memory management, system calls, mult-process architecture, and scheduling mechanisms. Each question specifies marks and requires answers in bullet points or code snippets.

Uploaded by

k230517
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

National University of Computer and Emerging Sciences

Karachi Campus

Operating Systems (CS 2006) Final Exam


Date: May 20, 2024 Total Time (Hrs.): 3
Course Instructor(s) Total Marks: 50
Dr. Nadeem Kafi, Dr. Nausheen Shoaib, Dr. Shahbaz Siddiqui, Ms.
Anaum Hamid, Ms. Safia Baloch, Ms. Mubashra Fayyaz, Ms. Atiya Total Questions: 5
Jokhio, Mr. Minhal Raza, Ms. Saeeda, Ms. Hania Shah

__________ __________ _____________________


Roll No Section Student Signature
Do not write below this line.
Attempt all the questions in order. Carefully read and follow all instructions. Each violation shall be penalized.

CLO # 4 - Understand synchronization and deadlocks. Implement synchronization using Mutex/Semaphores.

Q1. [15 marks] Instruction: Write answers as bullets points.

a) Consider a tcke booking sysem where he available number o tckes or
each program mus be mainained. A person who wishes o book a tcke calls
he bookTicke() uncton, which checks i tckes are available and hen
decreases he available tckes coun by one. This is illusraed in he code
shown. Now explain how a race conditon is possible in his siuaton. Also,
show a Phread library-based C program ha avoids race conditon using a muex. [1 + 3]

b) Explain synchronizaton issue(s) in producer and consumer in a producer-consumer problem. Wrie and explain C code
snippes ha use wo ypes o semaphores as a soluton or his problem. [2+2]

c) Wrie answers o he ollowing questons:


i. Why hardware aomic insructons are necessary in he implemenaton o locking primitves? [1]
ii. How do wo hreads become deadlocked while accessing resources? Wrie C code snippe using semaphores and a
sep-by-sep explanaton or any scenario. [3]

d) How busy waitng is implemened during synchronizaton? Wrie wo C code snippes showing wo dieren mehods.
Also, explain he working o any one snippe using a dry run wih variable values. Assume wo processes where one
is executng in is critcal secton and oher is waitng [2 + 1].

CLO # 5 - Understand virtual memory and its management.

Q2. [15 marks] Instruction: Write answers as bullets points. Make suitable assumptions, if needed.

a) Explain exernal ragmenaton in main memory using a labeled diagram. Wha causes inernal ragmenaton in a
page? Explain wih an example. [2 + 1]

b) Page auls are critcal in a virual memory sysem.


i. Explain Page aul processing using a labelled diagram. [2]
ii. In a compuer sysem, memory access tme is 40 nanoseconds and hard disk access tme is 1.25 milliseconds.
Calculae eectve memory access tme i page aul probabiliy is 0.000025. [2]

c) LRU is one o he many page replacemen algorihms. Explain is wo implemenatons as ollows:
i. Use a labelled diagram and sepwise hins o describe clock (second chance) algorihm. Show i does approximae
LRU unctonaliy. [2]
ii. Now, enhance he above algorihm o ensure ha diry victm pages are ushed o memory beore reuse. [2]

Spring 2024 Department of Computer Science Page 1 of 2


National University of Computer and Emerging Sciences
Karachi Campus

d) Suppose a program is accessing main memory in a virual memory sysem having a page size o 2K.
i. Sae he dierence beween paged and demand paged memory sysem? [1]
ii. Show a labelled diagram which show how a virual memory address generaed by a program is ranslaed ino a
physical address. Now, in your diagram, assume suiable values or page number and page ose and show how he
processor calculaes he physical address. [3]

CLO # 1 - Describe, discuss, and analyze, services provided by the modern Operating Systems.

Q3. [6 marks] Instruction: Avoid unnecessary details in your answers.

a) Creae a diagram illusratng he inerrup handling process in a ypical operatng sysem. Wha is he purpose o
tmer in operatng sysems and how i is relaed o inerrups. [1+2]

b) Describe executon seps o a (generic) sysem call using wo modes in a modern operatng sysem wih he help o
a labelled diagram. Wha problems do you expec i OS execues his sysem call in user mode only? Explain. [2+1]

CLO # 2 - Understand, design, and implement solutions employing concepts of Processes and Threads

Q4. [6 marks]

a) Consider Google’s Chrome browser as a mult-process archiecure. Wha bene would his implemenaton
provides o he user? [2]

b) Show how many processors are needed o gain a 3.5 tmes speedup i he serial porton is 20%. [2]

c) Explain dieren ypes o mapping beween user-level and kernel-level hreads. [2]

CLO # 3 – Understand mechanisms for scheduling of tasks in modern operating systems.

Q5. [8 marks] Instruction: Write answers as bullets points.

a) Consider Linux Compleely Fair Scheduler. Explain: i) he compuatons done o akes scheduling decisions, and ii)
give a diagram o show how CFS ecienly compues he nex runnable ask. [2+2]

b) Assume an Operatng Sysem uses FCFS scheduler. Suppose here are only wo processes: rs is running wih fy
hreads o compue he value o Pi using 5000K ieratons, and he second process is an Inerne browser where a
single ab is shown o he user. Explain how you change he code o frs process such ha he FCFS scheduler run
boh processes alernatvely in his case. Write precise answer in 2-3 lines only [2].

c) Compare and conras pre-emptve and non-preemptve scheduling [2].

Spring 2024 Department of Computer Science Page 2 of 2

You might also like