Os Unit Ii Notes
Os Unit Ii Notes
Introduction:
A process control block (PCB) contains information about the process, i.e.
registers, quantum, priority, etc.
The process table is an array of PCBs, that means logically contains a PCB for
all the current processes in the system.
The process control block (PCB) is used to track the process’s execution
status.
Each block of memory contains information about the process state, program
counter, stack pointer, status of opened files.
Resource management: The process table and PCB allow the operating
system to manage system resources, such as memory and CPU time,
efficiently. By keeping track of each process’s resource usage, the operating
system can ensure that all processes have access to the resources they
need.
Process scheduling: The process table and PCB can be used to schedule
processes for execution. By keeping track of each process’s state and
resource usage, the operating system can determine which processes should
be executed next.
However, apart from advantages there are certain disadvantages
such as:
Overhead: The process table and PCB can introduce overhead and reduce
system performance. The operating system must maintain the process table
and PCB for each process, which can consume system resources.
Complexity: The process table and PCB can increase system complexity
and make it more challenging to develop and maintain operating systems.
The need to manage and synchronize multiple processes can make it more
difficult to design and implement system features and ensure system
stability.
Scalability: The process table and PCB may not scale well for large-scale
systems with many processes. As the number of processes increases, the
process table and PCB can become larger and more difficult to manage
efficiently.
Security: The process table and PCB can introduce security risks if they are
not implemented correctly. Malicious programs can potentially access or
modify the process table and PCB to gain unauthorized access to system
resources or cause system instability.
Q2. State the difference between program and process.
Introduction:
Schedulers in an operating system are specialized components responsible
for managing the order in which processes are executed by the CPU. They
play a crucial role in optimizing the performance and efficiency of the system
by determining the sequence of process execution. There are three main
types of schedulers, each with distinct functions and operational frequencies:
long-term, short-term, and medium-term schedulers.
Long-term Scheduler:
The long-term scheduler, also known as the job scheduler, controls the
admission of processes into the system. It decides which processes from the
job queue should be moved to the ready queue, thereby determining the
degree of multiprogramming (the number of processes in memory at one
time). This scheduler runs infrequently because it makes decisions that have
long-lasting effects on the system's load and performance. Its primary goal is
to maintain a balanced mix of I/O-bound and CPU-bound processes, ensuring
efficient utilization of system resources.
Short-term Scheduler:
The short-term scheduler, or CPU scheduler, is responsible for selecting
which process from the ready queue should be executed next by the CPU.
This scheduler runs very frequently, as it needs to make quick decisions to
manage context switching—the process of saving and loading the state of
processes. The short-term scheduler's efficiency directly affects the
responsiveness and throughput of the system, as it determines the order in
which processes access the CPU.
Medium-term Scheduler:
The medium-term scheduler manages the swapping of processes between
the main memory and secondary storage. Its primary function is to control
the level of multiprogramming by temporarily suspending (swapping out)
and resuming (swapping in) processes. This helps in managing the memory
more efficiently and ensuring that active processes have enough resources
to execute. By reducing the number of processes in memory, it prevents
overloading and allows the system to maintain better performance.
Introduction:
Definition of Threads:
2. Resource Sharing: Threads within the same process share the same
address space and resources, which allows them to communicate and share
data more efficiently than separate processes.
3. Synchronization: Threads can synchronize their activities through
mechanisms such as locks, semaphores, and monitors, enabling coordinated
execution and data sharing while avoiding conflicts.
Components of Threads:
1.Stack Space: Each thread has its own stack space where local variables
and function call information are stored. This allows threads to have
independent function call hierarchies.
2. Register Set: Threads have their own set of CPU registers, including the
program counter (PC) and other general-purpose registers. These registers
hold the current execution state of the thread.
3. Program Counter (PC): The program counter keeps track of the address
of the next instruction to be executed by the thread.
4. Thread Control Block (TCB): Like processes, each thread has its own
thread control block that contains information about the thread's state,
priority, register contents, stack pointer, and other relevant information.
During a context switch, the contents of the CPU registers are saved into the
thread's TCB, allowing the thread to be resumed later.
Introduction:
Q6. Explain: a) FCFS b) SJN (small note there are total 14 points only
write 5 to 6 u can delete which ever u don’t understand and learn the easy
ones) love yaaaa
Introduction:
3.When a process enters the ready queue, it is assigned the CPU, and it
continues to execute until it completes its CPU burst.
5. Since it doesn't consider the burst time of processes, it may lead to poor
performance in terms of average waiting time, especially if long processes
arrive first, causing shorter processes to wait excessively.
6.The average waiting time can be calculated by subtracting the arrival time
from the service time of each process and then averaging these values
across all processes.
7. An example was provided in the data where the average wait time was
calculated for a set of processes using FCFS.
Introduction:
SJN Scheduling: Selects the process with the shortest burst time for
execution to minimize average waiting time. Optimal for batch systems but
may not work well for unpredictable execution times in interactive systems.
b) Shortest Job Next (SJN) Scheduling:
2.In SJN, the scheduler selects the process with the shortest burst time from
the ready queue for execution.
4.SJN is suitable for batch systems where the required CPU time of each
process is known in advance.
5.However, it's not suitable for interactive systems where the required CPU
time is not predictable because it requires prior knowledge of process
execution times.
7.An example was provided in the data where the average wait time was
calculated for a set of processes using SJN.
Q7. Explain types of threads with its advantages and disadvantages. (you
can do it pookie)
Introduction:
User Level Thread is a type of thread that is not created using system calls.
The kernel has no work in the management of user-level threads. User-level
threads can be easily implemented by the user. In case when user-level
threads are single-handed processes, kernel-level thread manages them.
Let’s look at the advantages and disadvantages of User-Level Thread.
A kernel Level Thread is a type of thread that can recognize the Operating
system easily. Kernel Level Threads has its own thread table where it keeps
track of the system. The operating System Kernel helps in managing threads.
Kernel Threads have somehow longer context switching time. Kernel helps in
the management of threads.
(miaaww <3)
Introduction
1. Pre-emption – Process is forcefully removed from CPU. Pre-emption is also
called time sharing or multitasking.
PREEMPTIVE NON-PREEMPTIVE
Parameter SCHEDULING SCHEDULING
Process cannot be
Process can be interrupted until it
3.Interrupt
interrupted in between. terminates itself or its
time is up.
In pre-emptive
It is low in non
8.CPU Utilization scheduling, CPU
pre-emptive scheduling.
utilization is high.
Pre-emptive Non-pre-emptive
9.Waiting Time scheduling waiting scheduling waiting time
time is less. is high.
Pre-emptive Non-pre-emptive
10.Response Time scheduling response scheduling response
time is less. time is high.
I loveeeeeeeee yaaaaaaaaaaaaaaa