0% found this document useful (0 votes)
19 views

Operating System 2

sv22

Uploaded by

dk1078451
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Operating System 2

sv22

Uploaded by

dk1078451
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 22

An 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.D
also allows us to communicate with the computer without knowing how to speak the
computer's language.

Without an operating system, a computer is not useful.D

An operating system (OS) is like the manager of a computer or a smartphone.

Types of operating system:

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.

Kernel is the central core component of an operating system that manages


operations of computer and hardware.
D

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.

It has dependencies between system components.

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

reside in computer memory

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.

process is an instance of program

Program:

Program is a set of instructions to perform a certain task. Eg: chrome.exe,


notepad.exe

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.

Virtual memory serves two purposes.

First, it allows us to extend the use of physical memory by using a disk. D

Second, it allows us to have memory protection,D

because each virtual address is translated to a physical address.

Thrashing:

Thrashing is a condition or a situation when the system is spending a major portion


of its

time in servicing the page

faults, but the actual processing done is very negligible.

High degree of multiprogramming,


lack of frames causes Thrashing.
thread

In an operating system (OS), a thread is the smallest unit of a program that can be
executed.

Think of a thread as a mini-task inside a larger task (the program)

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 thread is the smallest unit of a program that can be executed.

Think of a thread as a mini-task inside a larger task (the program).

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.

RAID, or “Redundant Arrays of Independent Disks” is a technique which makes use of


a combination of multiple disks
instead of using a single disk - for increased performance, data redundancy or
both.

Data redundancy, although taking up extra space, adds to disk reliability.

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.

How deadlock is achieved:

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

but the process doesn’t use the entire allocated space.

External Fragmentation: This happens when free memory is split into small,
scattered chunks over time, - karo

making it hard to allocate large contiguous blocks to new processes

Spooling is a process in which data is temporarily held to be used and executed by


a device, program, or system. - karo

data temporray hold ya store hota hai spooling main

In spooling, there is no interaction between the I/O devices and the CPU. DD

The biggest example of Spooling is printing. DD


multitasking:

Multitasking is the ability of an operating system to run multiple tasks (processes


or programs) seemingly at the same time.

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.

only one cpu is required in multitasking

multitasking allows multiple applications or processes to run at the same time, -


karo

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,

program decide by itself when to stop and start

Preemptive Multitasking:

Preemptive Multitasking: In preemptive multitasking, the operating system controls


when each program gets to use

the CPU. It gives each program a short time to run, then automatically pauses it
and switches to another program.

OS control program when they will use cpu

Examples of Multitasking:

Running a web browser, text editor, and media player at the same time. - karo
Multiprocessing:

use of two or more cpu to execute multiple proecess simuntaneously - karo

Types of Multiprocessing:
Symmetric Multiprocessing (SMP)
Asymmetric Multiprocessing (AMP)

Multiprocessing refers to the use of multiple CPU cores or processors to execute


multiple tasks
or processes simultaneously.

Each processor or core can work on a different task at the same time, improving
performance.

How it works: Each processor or core handles a different process or thread


independently,
so tasks can truly run in parallel without needing to switch rapidly between them.

How it works: Each processor or core handles a different process or thread


independently,
so tasks can truly run in parallel without needing to switch rapidly between them.

eature Multitasking Multiprocessing


Execution One task at a time (but switches rapidly between tasks)
Multiple tasks at the same time on different processors/cores
Resources Single CPU/core is shared among tasks Multiple
CPUs/cores are used to execute tasks
Speed Slower due to context switching Faster
due to true parallelism

Example Using a word processor and browser on a single-core CPU Video


editing and gaming on a multi-core CPU

In summary, multitasking involves quickly switching between tasks on a single


CPU/core,

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.

Demand paging is a method of virtual memory management which is based on the


principle that \

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.

it will improve performnce of application - karo

load data into memory only when it is needed,

Segmentation is a memory management technique in which the memory is divided into


the variable size parts. DD

Each part is known as a segment which can be allocated to a process. DD

Segment table contains mainly two information about segment:

Base: It is the base address of the segment

Limit: It is the length of the segment.


DD

Paging is a memory management scheme that eliminates the need for contiguous
allocation of physical memory D

Paging is used for faster access to data. D

When a program needs a page,

it is available in the main memory(RAM) as the OS copies a certain number of pages


from your storage device to main memory.

Paging allows the physical address space of a process to be noncontiguous.

paging is memory management technique where the computer's memory is divided into
small,

fixed-sized blocks called pages.

Why does trashing occur?

High degree of multiprogramming(if number of processes keeps on increasing in the


memory) ,

lack of frames(if a process is allocated too few frames, then there will be too
many and too frequent page faults.) causes Thrashing.

Real Time Operating System, types of RTOS.

A real-time operating system (RTOS) is a special-purpose operating system used in


computers that has strict time constraints

task specific time main execute ho jana achahiye aapkaaa

It ensures that tasks are completed within a specific time frame, often in
milliseconds or microseconds,D - karo

Example:

Think of an RTOS like a traffic light system.


The lights change based on timers and sensors to ensure traffic flows smoothly and
without delay,

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.

program is execute is at complile time , it is more efficient and faster way to


execute

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

as all decision will make before executions

Dynamic Binding Calling a function or assigning a value to a variable, at run-time


is called “Dynamic Binding”.

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

FCFS (First-Come, First-Served) scheduling is one of the simplest types of CPU


scheduling.

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

FCFS (First-Come, First-Served) is one of the simplest scheduling algorithms used


in operating systems.

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.

Simple to implement: It's easy to understand and manage.


Fair: The first process to arrive gets served first.

Round Robin (RR) Scheduling is a way for a computer to manage multiple tasks by
giving each one a small,

equal amount of time to run.

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

manage how tasks (or processes) are executed. D

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:

Task 1 runs for 3 seconds, then it pauses.


Task 2 runs for 3 seconds, then pauses.
Task 3 runs for 3 seconds, and then it goes back to Task 1 again if it's not done
yet.

Producer-Consumer problem:

The Producer-Consumer problem is a classic problem that is used for multi-process


synchronisation
i.e. synchronisation between more than one processes.

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

we can solve this problem using semaphore

What's the problem here?


The following are the problems that might occur in the Producer-Consumer:

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.

We can solve this problem by using semaphores.

Starvation is the problem that occurs when low priority processes get jammed for an
unspecified time as

the high priority processes keep executing.


So starvation happens if a method is indefinitely delayed.

Solution to Starvation :

Ageing is a technique of gradually increasing the priority of processes that wait


in the system for a long time. - karo

starvation main low priorty process jamm ho jate hai oor high priority process
keep executing ,

happen when method is indefintelt delayed.

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

Without an operating system, a computer is not useful. Without an operating system,


DD
a computer is not useful.

Types of operating system:


Batch OS
Distributed OS
Multitasking OS
Network OS
Real-Time OS
Mobile OS
An operating system function

Hides the underlying complexity of the hardware. (Aka, Abstraction)

interface between the user and the computer hardware D

2. A socket is defined as an endpoint for communication . D

A socket is identified by an IP address concatenated with a port number.D

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.

Kernel Establishes communication between user level application and hardware

Manages memory and CPU time.

Decides state of incoming processes.

Kernel Establishes communication between user level application and hardware. DD

Decides state of incoming processes. Controls Disk, Memory, Task Management

Monolithic Kernel (provides good performance but lots of lines of code)

one of the types of kernel where all operating system services operate in kernel
space.

it 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.

Resides in Computer’s primary memory (RAM).

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 is a set of instructions to perform a certain task. Eg: chrome.exe,


notepad.exe

A thread is also known as a lightweight process. achieve parallelism by dividing a


process into multiple threads.

Thread is a path of execution within a process

E.g., Multiple tabs in a browser, text editor

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.

Second, it allows us to have memory protection, allows us to have memory


protection,
because each virtual address is translated to a physical address.

Thrashing:

Thrashing is a condition or a situation - - when the system is spending a major


portion of its time in
servicing the page faults, but the actual processing done is very negligible.

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.

RAID, or “Redundant Arrays of Independent Disks” - technique which makes use of a


combination of
multiple disks instead of using a single disk for increased performance, data
redundancy or both.

Data redundancy, although taking up extra space, adds to disk reliability.

Deadlock

4. DL is a bug present in the process/thread synchronization method .

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.

he Processes are said to be in Deadlock

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.

How deadlock is achieved:

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,

programs are loaded and deleted from memory, they generate free space or a hole in
the memory.D

The conditions of fragmentation depend on the memory allocation system. D

process is loaded and unloaded from memory, these areas are fragmented into small
pieces
of memory

Types of fragmentation:
1. Internal
2. External

Spooling is a process in which data is temporarily held to be used and executed by


adevice, program, or system D

data temporay store akrte hai

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.

it holds frequently requested data and instructions so that they are


immediately available to the CPU when needed.

It is a banker algorithm used to avoid deadlock and allocate resources safely to


each
process in the computer system.

The 'S-State' examines all possible tests or activities before deciding whether the
allocation should be allowed to each process.

banker's algorithm is named because it checks whether a person should be


sanctioned a loan amount or not help the bank system safely simulate allocation
resources.
'
person ko loan sanctoion karna cahiya ya nahi kanrna chahiye toh ham banker alg ko
use karengee

real-time operating system (RTOS) is a special-purpose operating system used in


computers that has strict time constraints - for any job to be performed and is
intended to serve real time applications that possess data as it comes in

typically
without buffer delays.

ek speicfic time main tsak execute hona chaiyee

Types of RTOS:
Hard RTOS
Firm RTOS
Soft RTOS

Primary memory is temporary. Secondary memory is permanent.

Primary memory is faster than secondary memory because it is directly accessible to


the CPU. - karooo

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 directly accessible by Processor/CPU. D

Secondary memory is not directly accessible by the CPU. D

Primary memory is volatile, which means it is wiped out when the computer is turned
off.

Since it is non-volatile, data can be retained in case of a power failure.

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

Tag Index Word

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 free, immediately data is transferred without any


formulae . 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

Associative mapping addressing scheme

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

Segmentation is a memory management technique in which the memory is divided


into the variable size parts. Each part is known as a segment which can be
allocated
to a process. D - karo

D
The details about each segment are stored in a table called a segment table. - karo

Segment table contains mainly two information about segment: - karo

Base: It is the base address of the segment


Limit: It is the length of the segment.

Demand paging is a method of virtual memory management which is based on the


principle that 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.

IT IMPROV

Why does trashing occur?

High degree of multiprogramming(if number of processes keeps on increasing in the


memory) , lack of frames(if a process is allocated too few frames, then there will
be
too many and too frequent page faults.) causes Thrashing.

What is paging and why do we need it?

Paging is a memory management scheme that eliminates the need for contiguous
allocation of physical memory.DD

Paging is used for faster access to data.DD

Paging allows the physical address space of a process to be non- contiguous.DD

When a program needs a page, it is available in the main memory(RAM) as the OS


copies a certain number of pages from your storage device to main memory.

Starving and Aging in OS

Starving/Starvation(also called Lived lock) –

Starvation is the problem that occurs when low priority processes get jammed for an
unspecified time as the high priority processes keep executing.DD

So starvation happens if a method is indefinitely delayed.DD

Solution to Starvation : Ageing is a technique of gradually increasing the priority


of
processes that wait in the system for a long time. DD

Dynamic Binding Calling a function or assigning a value to a variable, at run-time


is
called “Dynamic Binding”. Dynamic binding can be associated with run time
‘polymorphism’ and ‘inheritance’ in OOP.

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

Static binding is implemented in a program at the time of coding. call a


function or all the values of the variables during compile time, it is called
“static binding”.

Multi-tasking Multiprocessing
The number of CPU is one. The number of CPUs is more than one. D

In this, one by one job is being executed at a time.


DD In this, more than one process can be executed at a
time.
In multiprocessing, there is more than one processor present in the system that can
execute more than one process at the same time. D

In multitasking each process is


assigned some specific quantum of time for which a process is meant to execute.

MULTITASKING MULTIPROCESSING
The simultaneous execution of more
than one task is known as
multitasking.D

In multiprocessing, we use more than one


processor which executes several sets of
instructions parallel.D

Only one CPU is required More than one CPU is required.D

Only one job is executed at a time More than one job is executed at a time.D
DD

It takes a moderate amount of time It takes less time


It is economical It is also economical
It has more than one number of users It has either one or more users

It has moderate throughput It has a maximum throughput

Multitasking’s efficiency is
moderate Multiprocessing’s efficiency is maximum D

It is classified into two: Single user


multitasking and multiple user
multitasking DD

It is classified into two: Symmetric


multiprocessing and asymmetric
multiprocessing. DD

You might also like