Operating System 2
Operating System 2
software resources,
it manages the computer's memory, processes, devices, files, and security aspects
of the system.D
also allows us to communicate with the computer without knowing how to speak the
computer's language.
Batch OS
Distributed OS
Multitasking OS
Network OS
Real-Time OS
Mobile OS
Socket:
A socket is defined as an endpoint for communication D
The server waits for incoming client requests by listening to a specified port. D
Once a request is received, the server accepts a connection from the client socket
to complete the connection.
D
Kernel Establishes communication between user level application and hardware.
D
Manages memory and CPU time.
D
Decides state of incoming processes. Controls Disk, Memory, Task Management.
Monolithic Kernel (provides good performance but lots of lines of code)
D
It is one of the types of kernel - - where all operating system services operate in
kernel space.
D
It has huge lines of code which is complex.
Example : Unix, Linux, Open VMS, XTS-400 etc.D
Process:
D
Process is an instance of an executing program.
D
prgoram under execution is known as process
D
For example, we write our computer programs in a text file and when we execute this
program,
it becomes a process which performs all the tasks mentioned in the program.
Program:
Thread:
D
Thread is a path of execution within a process. A thread is also known as a
lightweight process.
D
The idea is to achieve parallelism by dividing a process into multiple threads.
D
For example,Word processor uses multiple threads: one thread to format the text,
another thread to process inputs.
D
The idea is to achieve parallelism by dividing a process into multiple threads.
For example,Word processor uses multiple threads: one thread to format the text,
another thread to process inputs.
Virtual Memory:
A computer can address more memory than the amount physically installed on the
system.
This extra memory is actually called virtual memory and it is a section of a hard
disk that's set up to emulate the computer's RAM.
The main visible advantage of this scheme is that programs can be larger than
physical memory.
Thrashing:
In an operating system (OS), a thread is the smallest unit of a program that can be
executed.
When you run a program, it can have one or more threads running at the same time to
do different things,
allowing the program to multitask.
When you run a program, it can have one or more threads running at the same time to
do different things,
allowing the program to multitask.
A Deadlock is a situation where each of the computer processes waits for a resource
which is being assigned
to some other process.
In this situation, none of the processes gets executed since the resource it needs
is held by some other process which is also waiting for some other resource to be
released.
Deadlock happens when Mutual exclusion, hold and wait, No preemption and circular
wait occurs simultaneously.
Necessary Conditions for deadlock:
Mutual Exclusion
Hold and Wait
No preemption
Circular Wait
Fragmentation:
An unwanted problem in the operating system in which the processes are loaded and
unloaded from memory,
and free memory space is fragmented
fragemnetion free space create kar dega as process are loaded and unloaded from
memory
Processes can't be assigned to memory blocks due to their small size, and the
memory blocks stay unused. - karo
Types of fragmentation:
1. Internal
2. External
Internal Fragmentation: This occurs when fixed-sized memory blocks are allocated to
processes - karo
External Fragmentation: This happens when free memory is split into small,
scattered chunks over time, - karo
In spooling, there is no interaction between the I/O devices and the CPU. DD
work: The OS divides the CPU's time into small slices and assigns each task a
slice. The rapid switching between tasks is called context switching.
Cooperative Multitasking:
"each program running on the computer decides on its own - when to stop and let
another program use the CPU" -karo
This means that if a program doesn’t “cooperate” by pausing or finishing its task,
it can keep the CPU busy,
Preemptive Multitasking:
the CPU. It gives each program a short time to run, then automatically pauses it
and switches to another program.
Examples of Multitasking:
Running a web browser, text editor, and media player at the same time. - karo
Multiprocessing:
Types of Multiprocessing:
Symmetric Multiprocessing (SMP)
Asymmetric Multiprocessing (AMP)
Each processor or core can work on a different task at the same time, improving
performance.
while multiprocessing uses multiple CPUs or cores to run tasks in parallel for
better performance.
Explain Cache memory
dd
Cache memory is an extremely fast memory type that acts as a buffer between RAM and
the CPU.
D
It holds frequently requested data and instructions so that they are immediately
available to the CPU when needed.
pages should only be brought into memory if the executing process demands them.
So demand paging works opposite to the principle of loading all pages immediately.
Paging is a memory management scheme that eliminates the need for contiguous
allocation of physical memory D
paging is memory management technique where the computer's memory is divided into
small,
lack of frames(if a process is allocated too few frames, then there will be too
many and too frequent page faults.) causes Thrashing.
It ensures that tasks are completed within a specific time frame, often in
milliseconds or microseconds,D - karo
Example:
Types of RTOS:
Hard RTOS
Firm RTOS
Soft RTOS
Static binding happens when the code is compiled, while dynamic bind happens when
the code is executed at run time.
Static Binding:
When a compiler acknowledges all the information required to call a function or all
the values of the variables during compile time,
it is called “static binding”. As all the required information is known before
runtime,
it increases the program efficiency and it also enhances the speed of execution of
a program. D
Static Binding makes a program very efficient, but it declines the program
flexibility, D
Dynamic binding can be associated with run time ‘polymorphism’ and ‘inheritance’ in
OOP
program execute at run time , memory will be alloated for variable at run time
scheduling alg
In this method, processes are executed in the order they arrive in the queue. D
The first process to arrive gets executed first, and others wait until it’s
finished.D
fcfs ek scheduling alg, jisme jo process pahle aage woh pahle execute hoga , order
main execute hoga , jo pahle aaya woh pahle execucte hoga
jo task pahle aata hai woh sabse pahhle execute hogaa fcfs ka andarr
Arrival: When a task (or process) comes in, it's added to a queue.
Execution: The CPU picks the task at the front of the queue and starts working on
it.
Completion: Once the task is finished, the CPU moves on to the next task in line.
Round Robin (RR) Scheduling is a way for a computer to manage multiple tasks by
giving each one a small,
If a task doesn't finish during its time, it gets paused and the next task gets a
turn.
The paused task will come back later for another turn.
rrbin main task multiple task manage karte hai , har task ko equal time dete hai
run hone ka liyee , - karo
agar koi task properly work nahi kar rhaa , toh ham usko pause kar dete hai - karo
aur agle task ko run karte hai , pause waala task baad main run hote hai . - karo
agar koi task properly work nahi kar rhaa , toh ham usse pause kardenge , aur baad
main execute karengee D
How It Works:
The computer gives each task, like opening a file or running a game, a short time
to run (called a time slice).
After a task uses up its time slice, the computer moves on to the next task.
If a task isn’t finished, it goes to the back of the line and will get another
chance later.
example: Done
If you have 3 tasks (Task 1, Task 2, Task 3) and each gets 3 seconds:
Producer-Consumer problem:
The job of the Producer is to generate the data, put it into the buffer, and again
start generating data.
While the job of the Consumer is to consume the data from the buffer.
producer data produce karega or consumer ussi data ko consume kargeaa , producer
data produce karke usse buffer main rakhegaa or consumber buffer se data consume
karega
probm - prodycer data produce kare when buffeer is not full , agar buffer full hai
toh producer data produce na karee
AGAR buffer empty hai toh consumer data consume nahi karega ,
prodcuer or consumer dono same time pa buffer access nahi kar sakta hai
The producer should produce data only when the buffer is not full.
If the buffer is full, then the producer shouldn't be allowed to put any data into
the buffer
The consumer should consume data only when the buffer is not empty. If the buffer
is empty, then the consumer shouldn't be allowed to take any data from the buffer.
The producer and consumer should not access the buffer at the same time.
Starvation is the problem that occurs when low priority processes get jammed for an
unspecified time as
Solution to Starvation :
starvation main low priorty process jamm ho jate hai oor high priority process
keep executing ,
Operating system (OS) is system software that manages computer hardware, software
resources. It
manages the computer's memory, processes, devices, files, and security aspects of
the system.
allows us to communicate with the computer without knowing how to speak the
computer's language.DD
the server waits for incoming client requests by listening to a specified port.
( Server wait for client
requests on specific port, once request received the server established connection
with client
socket.
Kernel is the central core component of an operating system that manages operations
of computer
and hardware.
one of the types of kernel where all operating system services operate in kernel
space.
It has huge lines of code which is complex. Example : Unix, Linux, Open
VMS, XTS-400 DD
Process: Program under execution.
we write our computer programs in a text file and when we execute this program,
it becomes a process which performs all the tasks mentioned in the program.
formatting of text and saving the text are done concurrently by multiple
threads.
A computer can address more memory than the amount physically installed on the
system. This
extra memory is actually called virtual memory and it is a section of a hard disk
that's set up to
emulate the computer's RAM.
Virtual memory serves two purposes. First, it allows us to extend the use of
physical memory by
using a disk.
Thrashing:
High degree of multiprogramming lack of frames (if a process is allocated too few
frames, then there will be too
many and too frequent page faults) causes Thrashing.
Deadlock
dl is situation in which two or more processs waiting for the resource but the
resoruce is already assign to some other process .
Two or more processes are waiting on some resource’s availability, which will never
be available
as it is also busy with some other process.
Deadlock is a situation where each of the computer processes waits for a resource
which is being assigned to some other process , none of the processes gets
executed since the resource it needs is held by some other process , other process
which is also waiting for some other resource to be released.
Mutual Exclusion
Hold and Wait
No preemption
Circular Wait
Fragmentation:
An unwanted problem in the operating system in which the processes are loaded
and unloaded from memory,
programs are loaded and deleted from memory, they generate free space or a hole in
the memory.D
process is loaded and unloaded from memory, these areas are fragmented into small
pieces
of memory
Types of fragmentation:
1. Internal
2. External
In spooling, there is no interaction between the I/O devices and the CPU. D
That means there is no need for the CPU to wait for the I/O operations to take
place
Cache memory is an extremely fast memory type that acts as a buffer between RAM
and the CPU.
The 'S-State' examines all possible tests or activities before deciding whether the
allocation should be allowed to each process.
typically
without buffer delays.
Types of RTOS:
Hard RTOS
Firm RTOS
Soft RTOS
Secondary memory is non-volatile, which means it retains data even when the power
is off. - karo
Primary memory devices are more expensive than secondary storage devices. - karo
Secondary memory devices are less expensive when compared to primary memory
devices.
Primary memory is volatile, which means it is wiped out when the computer is turned
off.
Static binding happens when the code is compiled, while dynamic bind happens
when the code is executed at run time.
sab kych mermory , varibale ko value , error checking sab complile time pa check
hota hai
Direct mapping :
While transferring the data from main m emory to cache memory, it uses the formula
KmodN to replace any line. D - karo
Where K indicates main memory block no. and N indicates no. of cache lines. - karo
In direct mapping we divide the main memory addressing space into three parts : -
karo
Word
Index
Tag
Word: No. of bits required to identify a particular word within the block.
Index: No. of bits required to identify the block number in cache memory where the
main memory block will be placed.
Associative mapping :
While transferring the data from main memory to cache lines, it checks the
availability of the line . D
If the line is not available, with the help of a replacement algorithm any
one of the lines is replaced by the new data .
The main idea was to avoid high conflict miss, any block of main memory can be
placed anywhere in cache memory. D
Tag Word
Direct mapping suffers from high conflict miss. We had to replace a cache memory
block even when other blocks in the cache memory we present as empty. D
To avoid high conflict miss the solution is associative mapping. In this, any block
of
main memory can be placed anywhere in cache memory.D
D
The details about each segment are stored in a table called a segment table. - karo
So demand paging works opposite to the principle of loading all pages immediately.
IT IMPROV
Paging is a memory management scheme that eliminates the need for contiguous
allocation of physical memory.DD
Starvation is the problem that occurs when low priority processes get jammed for an
unspecified time as the high priority processes keep executing.DD
Dynamic binding makes the execution of a program flexible - as it can decide what
value should be assigned to the variable and which function should be called, at
the
time of program execution.
Static Binding makes a program very efficient, but it declines the program
flexibility
Multi-tasking Multiprocessing
The number of CPU is one. The number of CPUs is more than one. D
MULTITASKING MULTIPROCESSING
The simultaneous execution of more
than one task is known as
multitasking.D
Only one job is executed at a time More than one job is executed at a time.D
DD
Multitasking’s efficiency is
moderate Multiprocessing’s efficiency is maximum D