You are on page 1of 10

Mid-Term Exam (Take-Home) Fall - 2020

Subject: Operating System Submission Day: Saturday

Instructor: M.Sufyan / Mr. Sabeeh / Dr. Aysha Submission Date: 28-11-2020

Program: BSCS Max. Marks: 25

Department of _Computer Science

Please follow the instructions carefully:

1. Write your answers in a Word file and upload the file before the due date on BlackBoard.

2. Write your name and registration ID on the first page of your Word file.

3. Answer scripts can be uploaded on BlackBoard any time before its deadline. Therefore,
do not wait for the last hour to avoid any unforeseen problems.

4. Submission of answer copy(ies) will be considered acceptable through BlackBoard only.


Therefore, do not submit your document through email or any other medium.

5. Use 12 pt. font size and Times New Roman font style along with 1-inch page margins.

6. Follow the requirements of the word limit and the marking criteria while writing your answers.

7. Provide relevant, original and conceptual answers, as this exam aims to test your ability to
examine, explain, modify or develop concepts discussed in class.

8. Do not copy answers from the internet or other sources. The plagiarism of your answers may be
checked through Turnitin.

9. Recheck your answers before the submission on BlackBoard to correct any content or language
related errors.

10. Double check your word file before uploading it on BlackBoard to ensure that you have
uploaded the correct file with your answers.
Question # 1 [marks 4]

Indicate whether the following statements are true or false. Justify your selection by providing a
brief explanation.

a) Privileged instructions cannot be executed in monitor mode (T / F). False


(because privileged instructions can be executed in monitor mode or kernel mode)

b) A process can be in one of the following states:


New, Running, Waiting, Ready, Terminated. These names are arbitrary, and they vary across
operating systems (T/F) True
(because of portability, easy to use, it also provides some type of security to the kernel.

c) In message passing if message is of variable size that is easy to implement. (T/F) False (because
the algorithm can easily be augmented to implement message broadcast)

d) An application programmer prefers programming according to an API rather than actual system
calls. (T/F) True (because an application programmer prefer programming according to an API
rather than invoking actual system.

Question # 2 [marks 4]

Discuss the possible risks associated with open source operating system, how would you be
affected?

ANSWER:

However, open source raises two unique risks: the risk of infringement and the risk of license
restriction. There is a somewhat higher risk, compared to proprietary software, that open source
violates third-party intellectual property rights, and open source users receive no contract protection
for this higher risk. Let consider the risks one by one:

1. Risk of license Restriction: Open source comes with unusual license restrictions that may impact a
company's strategies, particularly the risk that its own proprietary software may be "tainted" by a duty
to open its source code to others. This risk is different from the infringement risk. Open source is not
in the public domain but instead is available for use only under one of a variety of licenses that
impose restrictions on users. These licenses differ, and it is important to know and observe their term

2. Risk of Infringement: any programmer can add infringing code to open source because it is
developed without the usual commercial controls. Moreover, most providers of open source do not
offer the warranty protections customarily given for commercial products. As a result, a higher risk of
infringement, and the consequent exposure to injunctions and damages, rest entirely on the user.

Linux has been distributed under the General Public License (GPL). One risk under the GPL stands
out: the possibility that a user's proprietary code will be "tainted" by a duty to make its source code
open. If a user of GPL code decides to distribute or publish a work that "in whole or in part contains
or is derived from the [open source] or any part thereof," it must make the source code available and
license the work as a whole at no charge to third parties under the terms of the GPL (thereby allowing
further medication and redistribution). In other words, this can be a trap for the unwary: a company
can unwittingly lose valuable rights to its proprietary code.

On the other hand, if a company does choose to distribute or publish GPL code that it has somehow
modified, these general rules will apply to that published software:

1. If the company modifies GPL software, or if a part of GPL software is added to some proprietary
code, then the modified work must be made freely available.

2. If the company combines proprietary code with GPL software, and the resulting product is
published as a whole work, then the same result follows. What is considered a "whole work" will
likely turn on a number of technical issues, such as how closely the programs interact, how they are
linked, and how the proprietary program loads with the Linux kernel.

3. On the other hand, if the company's proprietary code combined with GPL software is identical and
reasonably considered independent and separate, then it may remain free of the GPL taint when
distributed as a separate work. In addition, merely placing a proprietary program on the same storage
medium with GPL software does not taint the proprietary code.

b) Explain some of the challenges of designing operating systems for mainframe computer
system as compared with designing operating systems for traditional PCs.

Ans: b

1. Inability to user for upgrade hardware in order to speed up device

2. os in mainframes have to manage power consumption since in mainframes system power


consumption is more

3. Memory limitation

4. Size of the device of mainframe system we have to keep small as well as must maintain all the
functionality.

Question # 5 [marks 4]
a) For what reason is synchronization important among processes when every one of them
are executing on a single CPU machine and just one of them can really execute at any
one moment?

ANSWER:

During the executing of multiple processes at a time, the method of synchronization will help this
process to maintain data consistency and cooperating process execution. In this concurrent access to
shared data does not create inconsistencies. Here synchronization will avoid conflict among processes
for accessing the same resource.
a) There are several way to design an operation system but let suppose an organization need to
design an operating system for their server machine and multiple user will be allowed to
access the resources through network. Which technique would you like to suggest to design
process communication module? What is the advantages of your selected technique?
Explain your answer briefly.

ANSWER:

Multi-user operating system is the best option for this organization for its server machine and multiple
users. This will allows multiple users to have access to the same computer simultaneously.
Advantages:
In this type, if a computer is damaged then it won't affect the working of any other computer in the
network. By using this type of OS we can back up the data In this, servers are systematic and stable
High speed We can reduce expenditure by using minimum machines for the maximum number of
users.

Question # 3 [marks 4]

a) Why everything cannot be handled at user mode and they need to be transferred at kernel
mode. Explain the scenario in which mode shifting taking place.

Answer:
Although most system only distinguish between user and kernel modes, some CPUs have supported
multiple modes. Multiple modes could be used to provide a finer-grained security policy. For example
rather than distinguishing between just user and kernel mode, you could distinguish between different
types of user mode. Perhaps user belonging to the same group could execute each other’s code. The
machine would go into a specified mode when one of these user was running code. When the machine
was in this mode, a member of the group could run belonging to anyone else in the group.
Another possibility would be to provide different distinction within kernel code. For example a
specific mode could allow USB device drivers to run. This would mean that USB device could be
serviced without having to switch to kernel mode, thereby essentially allowing USB device drivers to
run in a quasi-user/kernel mode

b) From the given scenario in question 5(b), which treading model allows system to run an
application that fetches data continuously and simultaneously over network? Justify your
answer.

ANSWER: Here we can use the model named multitasking. It can handle multiple programs at a time.
In this new task arrived will distract the process that is currently executing rather than waiting for it to
complete.
It will use computer hardware more efficiently. Suppose a program is waiting for some external event
such as user input with the help of a peripheral to complete, the central processor can still be used
with another program.

Question # 4 [marks 4]

A) Explain the activities taken by a kernel to perform process switching in time sharing
environment.
Ans:

Actions taken by a kernel to context-switch between processes are -

 The OS must save the PC and user stack pointer of the currently executing process, in
response to a clock interrupt and transfers control to the kernel clock interrupt handler
 Saving the rest of the registers, as well as other machine state, such as the state of the
floating-point registers, in the process PCB is done by the clock interrupt handler.
 The scheduler to determine the next process to execute is invoked the OS.
 Then the state of the next process from its PCB is retrieved by OS and restores the registers.
The restore operation takes the processor back to the state in which the previous process was
previously interrupted, executing in user code with user-mode privileges.
Many architecture-specific operations, including flushing data and instruction caches also must be
performed by Context switches.

b) What are the two differences between user-level threads and kernel-level threads? Under
what circumstances is on type is better than the other?

Answer:

 Kernel-level threads are scheduled by the OS, and each thread can be granted its own time
slices by the scheduling algorithm. The kernel scheduler can thus make intelligent decisions
among threads, and avoid scheduling processes which consist of entirely idle threads (or I/O
bound threads). A task that has multiple threads that are I/O bound, or that has many threads
(and thus will benefit from the additional time slices that kernel threads will receive) might
best be handled by kernel threads.
 User-level threads are much faster to switch between, as there is no context switch; further, a
problem-domain-dependent algorithm can be used to schedule among them. CPU-bound tasks
with interdependent computations, or a task that will switch among threads often, might best
be handled by user-level threads.

 User-level threads are threads that the OS is not aware of. They exist entirely within a
process, and are scheduled to run within that process's time slices.

 The OS is aware of kernel-level threads. Kernel threads are scheduled by the OS's scheduling
algorithm, and require a "lightweight" context switch to switch between (that is, registers, PC,
and SP must be changed, but the memory context remains the same among kernel threads in
the same process).

Question # 6 [marks 5]

Consider the following set of processes, with the length of the CPU burst given in seconds:

Process Burst time Arrival time


P1 10 1
P2 04 2
P3 05 3
P4 03 4

a) Draw four Gantt charts that illustrate the execution of these processes using the
following scheduling algorithms: FCFS, SJF preemptive and Round Robin
(quantum = 3).
b) What is the turnaround time of each process for each of the scheduling algorithms
in part a?
c) What is the waiting time of each process for each of these scheduling algorithms?
d) Which of the algorithms results in the minimum average waiting time (over all
processes)?
e) Which of the algorithms results in the minimum average turnaround time (over all
processes)?

ANSWER:

You might also like