Professional Documents
Culture Documents
MAHIMA KUMARI
2K21CSUN01128
Tutorial :3
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. 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.
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.
Timer Interrupts
Keyboard Interrupts
Network 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.
b. Memory Protection:
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.
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.
Tutorial :4
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
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.
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.
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.
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
Tutorial: 5
Section – A
Multiple Choice Question:
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.
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.
Ans,
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.
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:
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.