You are on page 1of 17

DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

Subject Name: Operating Systems Subject Code: CSH206B-T

MAHIMA KUMARI
2K21CSUN01128
Tutorial :3

Aim: To gain familiarity with introductory concepts of OS


Course Outcome : CO2
Blooms Taxonomy: BT1,BT2, BT3, BT4

1. Differentiate between
Ans.
a. Kernel and Operating System:
The kernel is the core part of an operating system that manages system resources
and provides low-level services to the system and user applications. The operating
system, on the other hand, refers to the complete package of software components
that manage a computer system's hardware and software resources, including the
kernel, device drivers, user interface, and system utilities.

b. Kernel and Shell:


The kernel is the central part of an operating system that interacts with the
hardware, manages system resources, and provides services to other software
components. The shell, on the other hand, is a user interface that allows users to
interact with the operating system and run commands by providing a command-line
interface or graphical user interface.

c. Monolithic Kernel and Micro Kernel:


A monolithic kernel is an operating system architecture where the entire kernel runs
in kernel space and provides all the operating system services, including device
drivers, file systems, and networking. A microkernel, on the other hand, is an
operating system architecture that separates the kernel into small, modular
components that run in user space and provide only essential services like inter-
process communication, memory management, and scheduling.
d. System Call and System Program:
A system call is a mechanism that allows user-level programs to request services
from the operating system kernel. It is a software interrupt that switches the CPU's
execution mode from user mode to kernel mode and transfers control to a specific
kernel function. A system program, on the other hand, is a program that provides
services to other programs, including system utilities like file management, process
management, and network management. System programs use system calls to
request services from the kernel.

2. Define the Following: -


Ans.
a. Trap:
In operating systems, a trap is a mechanism that enables the operating system to
intercept and handle hardware or software exceptions generated by user-level
programs. A trap is an interrupt that is triggered by an exception, such as a system
call or a memory access violation. When a trap occurs, the CPU switches from user
mode to kernel mode, and control is transferred to the operating system's trap
handler, which then performs the necessary actions to handle the exception.

b. IVT:
In operating systems, the Interrupt Vector Table (IVT) is a data structure that
contains a list of interrupt handlers for each interrupt or exception that can occur in
a computer system. The IVT is located in a reserved area of system memory and is
used by the operating system to manage interrupt requests from hardware devices
and software exceptions generated by user-level programs. Each entry in the IVT
contains the address of the interrupt handler, which is a routine that is executed
when the corresponding interrupt or exception occurs.

c. ISR:
In operating systems, an Interrupt Service Routine (ISR) is a function that is
executed in response to an interrupt or exception generated by hardware or
software. When an interrupt or exception occurs, the CPU interrupts the current
process's execution and transfers control to the appropriate ISR, which then
performs the necessary actions to handle the interrupt or exception. ISRs are
typically short and fast-running routines that perform only essential operations to
minimize the interruption of the CPU's normal operation. After the ISR completes,
control is returned to the interrupted process, which continues its execution from the
point where it was interrupted.

3. The services and functions provided by an operating system can be


divided into two main categories. Briefly describe the two
categories and discuss how they differ.
Ans.
The services and functions provided by an operating system can be broadly
classified into two categories: system services and user services.

System Services:
System services are the services provided by an operating system that are primarily
intended to manage the computer system's resources and provide a platform for
running other software applications. System services are typically provided in
kernel mode and include services such as memory management, process
management, device management, file system management, and security
management. System services are designed to provide a low-level interface to the
computer hardware and provide a foundation for higher-level software components
to run on.

User Services:
User services are the services provided by an operating system that are intended to
support user-level applications and enable users to interact with the computer
system. User services are typically provided in user mode and include services such
as user interface management, program execution, input/output management, and
communication services. User services are designed to provide a high-level
interface to the computer system and enable users to interact with the system in a
more user-friendly manner.

The main difference between system services and user services is that system
services are designed to manage the computer system's resources and provide a
platform for running other software applications, while user services are designed to
support user-level applications and enable users to interact with the computer
system. System services are typically provided in kernel mode and are more low-
level and technical in nature, while user services are typically provided in user
mode and are more user-friendly and interactive.

4. What is an Interrupt? Provide some examples where hardware and


software interrupt is generated.
Ans.
In computing, an interrupt is a signal sent to the CPU by a device or software
component to request its attention. Interrupts are used to handle events that require
immediate attention, such as input/output operations, hardware failures, or
exceptions.

Examples of hardware interrupts include:

 Timer Interrupts
 Keyboard Interrupts
 Network Interrupts

Examples of software interrupts include:

 System Call Interrupts


 Exception Interrupts

Interrupts are essential for the proper functioning of computer systems, as they
enable the system to handle events that require immediate attention and prevent the
CPU from being tied up with time-consuming tasks. By using interrupts, the CPU
can quickly switch between tasks and handle events as they occur, improving the
overall performance and reliability of the system.

5. Explain the following: -


Ans.
a. Dual Mode Operation:
Dual mode operation is a mode of operation in an operating system where the
system can switch between two modes, known as user mode and kernel mode. User
mode is a mode in which user-level applications execute, while kernel mode is a
mode in which the operating system executes. In user mode, the system provides
limited access to system resources, such as memory and hardware devices, while in
kernel mode, the system provides full access to all system resources. Dual mode
operation is designed to protect the operating system and prevent user-level
applications from accessing system resources that they are not authorized to use. By
switching between user mode and kernel mode, the operating system can ensure
that only authorized programs can access critical system resources.

b. Memory Protection:

Memory protection is a feature of an operating system that ensures that each


process or application has its own isolated memory space and cannot access the
memory space of other processes or the operating system itself. Memory protection
is essential for ensuring system stability and preventing malicious programs from
accessing or modifying critical system data. Memory protection is implemented
using hardware features such as memory management units (MMUs) and page
tables, which map virtual memory addresses to physical memory addresses and
provide access control and permissions.

c. I/O Protection:

I/O protection is a feature of an operating system that ensures that each process or
application has its own isolated I/O space and cannot access the I/O space of other
processes or the operating system itself. I/O protection is essential for ensuring
system stability and preventing malicious programs from accessing or modifying
critical system data through hardware devices. I/O protection is implemented using
hardware features such as input/output memory management units (IOMMUs) and
interrupt controllers, which provide access control and permissions for hardware
devices and prevent unauthorized access by user-level applications. By
implementing I/O protection, the operating system can ensure that each process has
access to the resources it needs without interfering with other processes or the
system itself.

6. What are the five major activities of an operating system in regard


to file management, Process Management?
Ans.
The five major activities of an operating system in regard to file management and
process management are:

File Management:
a. File Creation and Deletion: The operating system creates and deletes files as
requested by users or programs.
b. File Access Control: The operating system ensures that only authorized users and
programs have access to files and that access is controlled according to predefined
permissions.
c. File Organization and Storage: The operating system organizes and stores files on
disk or other storage devices, such as tapes or network storage devices.
d. File Retrieval and Updating: The operating system retrieves files from storage
and updates them as requested by users or programs.
e. File Backup and Recovery: The operating system provides facilities for backing
up files and recovering them in the event of data loss or system failure.

Process Management:
a. Process Creation and Termination: The operating system creates and terminates
processes as requested by users or programs.
b. Process Scheduling: The operating system schedules processes for execution on
the CPU according to predefined priorities and scheduling algorithms.
c. Process Synchronization: The operating system ensures that processes can
communicate and synchronize with each other without interfering with each other's
execution.
d. Process Communication: The operating system provides facilities for processes
to communicate and exchange data with each other, such as shared memory or
message passing.
e. Process Resource Management: The operating system manages resources such as
CPU time, memory, and input/output devices to ensure that processes have the
resources they need to execute efficiently and without interference from other
processes.

Overall, these activities are critical for the proper functioning of an operating
system, as they enable the system to manage files and processes effectively and
efficiently, ensuring that resources are allocated appropriately and that data is stored
and accessed reliably and securely.
7. Which of the following instructions should be privileged?

Ans.
The following instructions should be privileged:

a. Switch from User Mode to Kernel Mode: This is a privileged instruction because
it allows a program or process to access the kernel space, which contains sensitive
resources and information that should be protected from user-level access.

b. Updating Base and Limit Register: This is a privileged instruction because it


determines the range of memory addresses that a process can access, which is a
critical aspect of memory protection and security.

e. Interrupts are disabled: This is a privileged instruction because it involves


accessing and manipulating hardware resources, such as the interrupt controller,
which can affect the behavior of the entire system.

h. Send a file to printer to print: This is a privileged instruction because it involves


accessing and controlling hardware resources, such as the printer, which are
managed by the operating system and require special privileges to access.

The following instructions are not privileged:

c. Clear Memory Location: This is a non-privileged instruction because it does not


involve accessing sensitive resources or manipulating system behavior.

d. Read a clock: This is a non-privileged instruction because it does not involve


accessing or manipulating sensitive resources.

f. Executing a loop to enter user data: This is a non-privileged instruction because it


involves accessing and manipulating user-level data, which does not require special
privileges.

g. Load a value in processor register: This is a non-privileged instruction because it


involves accessing and manipulating data within the user space, which does not
require special privileges.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY
Subject Name: Operating Systems Subject Code: CSH206B-T

Topic: Process Management

Tutorial :4

Aim: To gain familiarity with concept of OS Process Management


Course Outcome: CO3
Blooms Taxonym: BT1, BT2

Section – A
True/false
1. A classic process normally has a shared address space. True
2. A modern process creation system call must always define a thread. False
3. Whenever a process calls fork(), a new child process is created with its own
copies of the parent’s program text, data, and stack segments, and access to all
open file descriptors. True
4. After the child has been created, both the parent and child processes are ready
to use the processor, as they each have their own abstract machine. True
5. An object’s behavior is defined completely by its class definition. False

Short Answer
1. A modern process creation system call usually creates a _thread_ to
execute within the process.
2. The operating system maintains a data structure called a ___ process control
block (PCB) ___ to keep all the details required to manage a process.
3. With the UNIX fork() call, a child’s behavior is completely defined by
__ copying the parent process __.
4. __________ was a model of an autonomous entity to represent the operation of
such a unit within a simulated system.
5. A class is similar to an __ object in object-oriented programming (OOP) __
that maintains its own state in its private variables and can be executed as an
autonomous unit of computation.
Multiple Choice
1. Which statement about resources is false?
a) A process/thread must request a resource before using it
b) The operating system can provide resources
c) Resources may be requested from another process (Ans)
d) A thread suspends its operation until a requested resource is allocated.
2. Files are distinguished from other resources except that
a) The interface is exceptionally complex as compared with most other
resources.
b) They are the prevalent form of storing information
c) Operating systems often use the file as a primitive for modeling
other resource abstractions (Ans)
d) UNIX pipes can be modeled as files

3. Operating system-supplied resources include the following except


a) Processor
b) Time
c) Keyboards (Ans)
d) Displays

4. Thread status may include the following except


a) Which resource is being waited on, if blocked
b) Address of the next instruction to execute (Ans)
c) Whether or not the thread is blocked waiting for a resource
d) Address of the first instruction in the program
5. Early process abstraction primitives included the following except
a) FORK()
b) RESTART() (Ans)
c) QUIT()
d) JOIN()
6. A UNIX process contains each of the following except
a) Text segment
b) Data segment
c) Thread segment (Ans)
d) Stack segment
Section – B
Answer the following Questions

1. Put the following in the chronological order in the context of the


birth of a process executes: Ready, suspended, execute, terminate,
create.
Ans.
1. Create: A process is created and allocated resources such as memory and
CPU time.
2. Ready: The process is waiting to be assigned to a processor for execution.
3. Execute: The process is assigned to a processor and its instructions are
executed.
4. Suspended: The process is temporarily halted and its execution state is
saved to be resumed later.
5. Terminate: The process has finished its execution and its resources are
released.

2. When a process requests for I/O, how many process switches take
place?
Ans.
When a process requests I/O, typically one process switch takes place. The
operating system switches the CPU from the executing process to another process
that is ready to run, allowing the first process to wait for the I/O operation to
complete. Once the I/O operation is complete, the operating system may switch the
CPU back to the original process.

3. A Shortest Job First algorithm may lead to starvation where a


process with large execution time is made to wait for indefinitely
long times. Suggest a modification to the SJF that overcomes this
problem.
Ans.

One modification to SJF that can overcome the problem of starvation is called
"Aging." Aging involves increasing the priority of a process as it waits for
execution. This ensures that even if a process has a long execution time, it will
eventually get executed because its priority will keep increasing with time.

In this modified algorithm, each process has an initial priority based on its expected
execution time. As the process waits, its priority increases based on a predefined
function that takes into account how long the process has been waiting. This
function can be linear or nonlinear, depending on the desired behavior of the
system.
Thus, even if a process has a large execution time, its priority will increase with
time, and it will eventually get executed. This modification to SJF ensures fairness
in the scheduling of processes and prevents starvation of long-running processes.

4. If the waiting time for a process is p and there are n processes in the memory
then the CPU utilization is given by,
a. p/n
b. p^n (p raised to n)
c. 1-p^n
d. n-(p^n )
at an average of six processes per minute vice time. Estimate the fraction of time
the CPU is busy in a system with a single processor.
Ans.
p/n.
The CPU utilization is defined as the fraction of time that the CPU is busy. In this case,
we are given that there are six processes per minute, which means that the average time
required for each process is 1/6 minutes or 0.1667 minutes.

5. In context of food serving in a restaurant suggest the states involved in


the service via role play.
Ans.
1. Arrival of customer: The customer arrives at the restaurant and is greeted by the
host/hostess.

2. Seating the customer: The host/hostess seats the customer at a table.

3. Providing the menu: A waiter/waitress provides the customer with the menu.

4. Taking the order: The waiter/waitress takes the customer's order and
communicates it to the kitchen.

5. Preparing the order: The kitchen staff prepares the food order as per the
customer's request.

6. Serving the food: The waiter/waitress serves the food to the customer at their
table.

7. Checking on the customer: The waiter/waitress checks on the customer to ensure


that they are satisfied with their meal.

8. Clearing the table: The waiter/waitress clears the table after the customer has
finished their meal.

9. Presenting the bill: The waiter/waitress presents the bill to the customer.

10. Payment and departure: The customer pays the bill and leaves the restaurant.
Department of Computer Science and Technology

Subject Name: Operating System Subject Code: CSH206B-


T

Topic: Scheduling Algorithm

Tutorial: 5

Aim: To gain familiarity with concept of CPU Scheduling Algorithm


Course Outcome : CO3
Blooms Taxonomy: BT1, BT2

Section – A
Multiple Choice Question:

1. FCFS is ______________ scheduling algorithm.


a. Pre-emptive b. Non Pre-emptive c. both d. none
2. SJF ______________ scheduling algorithm.
a. Pre-emptive b. Non Pre-emptive c. both d. none
3. The real difficulty with SJF in short term scheduling is :
a. it is too good an algorithm b. Knowing the length of the next CPU
request
c. it is too complex to understand d. None of these
4. Preemptive Shortest Job First scheduling is sometimes called:
a. Fast SJF scheduling b. EDF scheduling – Earliest Deadline
First
c. HRRN scheduling – Highest Response Ratio Next
d. SRTN scheduling – Shortest Remaining Time Next
5. Which of the following is FALSE about SJF (Shortest Job First Scheduling)?
S1: It causes minimum average waiting time
S2: It can cause starvation
a. Only S1 b. Only S2 c. Both S1 and S2 d. Neither S1 nor
S2

Section – B
Q1. Define the following scheduling criteria:

a) CPU utilization: It refers to the percentage of time the CPU is busy processing a task.
The higher the CPU utilization, the more efficiently the system is utilizing the CPU
resources.

b) Throughput: It is the number of processes that are completed in a unit of time. A


scheduling algorithm that maximizes throughput is desirable as it ensures a high volume
of work is completed in a given time period.

c) Turnaround time: It is the time interval between the submission of a process for
execution and the completion of the process. It includes the time taken for the process to
be executed as well as the time spent waiting in the queue for the process to be assigned
to the CPU.

d) Waiting time: It is the amount of time a process spends waiting in the ready queue
before it is assigned to the CPU for execution. The waiting time of a process depends on
the scheduling algorithm used, as well as the characteristics of the process itself.

e) Response time: It is the time interval between the submission of a request and the first
response produced by the system. In the context of operating system scheduling, it is the
time interval between the submission of a process for execution and the first response
produced by the system. It includes the time spent waiting in the queue as well as the
time spent executing on the CPU.

Q2. What is convoy effect?

Ans,

The convoy effect is a phenomenon that occurs in a non-preemptive scheduling


algorithm, where a long process blocks the execution of other shorter processes that are
waiting in the ready queue. When a long process is occupying the CPU for an extended
period, other shorter processes that are waiting in the ready queue cannot execute until
the long process has completed its execution. This results in a convoy of smaller
processes forming behind the long process, waiting for it to finish.

The convoy effect can lead to poor system performance, as the shorter processes have to
wait for an extended period, leading to an increase in their waiting time and turnaround
time. This effect can be minimized by using a preemptive scheduling algorithm that
allows the shorter processes to execute even if a longer process is already running. In a
preemptive algorithm, the shorter processes can be scheduled to execute while the longer
process is temporarily suspended, improving the overall system performance.

Q3. Consider the following scenario of processes in a system:


Process Arrival Time Execution Time

P1 0 5

P2 2 4

P3 3 7

P4 5 6

a) Draw the Gantt chart for the execution of the processes, showing their start time
and end time, using FCFS scheduling algorithm. Calculate Turn Around time,
Average Turn around Time, Waiting Time, and Average Waiting Time.
b) Draw the Gantt chart for the execution of the processes, showing their start time
and end time, using SJF scheduling algorithm. Calculate Turn Around time,
Average Turn around Time, Waiting Time, and Average Waiting Time.
Q4. Consider the following scenario of processes in a system:

Process Arrival Time Execution Time

P1 0 9

P2 1 5

P3 2 3

P4 3 4

Draw the Gantt chart for the execution of the processes, showing their start time and end
time, using FCFS, SJF, and SRTF scheduling algorithm. Calculate Turn Around time,
Average Turn Around Time, Waiting Time, and Average Waiting Time.

You might also like