0% found this document useful (0 votes)
3 views44 pages

Unit - 1 Os With Linux - Unix

The document provides an overview of operating systems (OS), defining them as interfaces between hardware and software while detailing their functions such as process management, memory management, file management, security, and command interpretation. It also categorizes different types of OS, including batch, multiprogramming, multiprocessing, time-sharing, and real-time systems, along with their advantages and disadvantages. Additionally, it discusses process states, scheduling criteria, and algorithms, as well as memory management techniques like contiguous memory allocation.

Uploaded by

disecek477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views44 pages

Unit - 1 Os With Linux - Unix

The document provides an overview of operating systems (OS), defining them as interfaces between hardware and software while detailing their functions such as process management, memory management, file management, security, and command interpretation. It also categorizes different types of OS, including batch, multiprogramming, multiprocessing, time-sharing, and real-time systems, along with their advantages and disadvantages. Additionally, it discusses process states, scheduling criteria, and algorithms, as well as memory management techniques like contiguous memory allocation.

Uploaded by

disecek477
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

OS with LINUX / UNIX

UNIT – 1
Introduction, Process management
& Memory Management

Prep
ared
by :
Brij
esh
K hod
a
Introduction of Operating System

Prep
ared
by :
Brij
esh
K hod
a
Introduction
Definition : “OS is a set of system programs which
act as an interface between hardware & Software”
It is an integrated set of programs which controls
the resources Of computer system & provides an
interface to user.
OS hides the details of hardware from user and
Provides Convenient interface environment.

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
Process Management
Main Memory Management
File Management
Protection System
Command-Interpreter System

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
1. Process management
A process is a program in execution. A process needs
certain resources, including CPU time, memory, files, and
I/O devices, to accomplish its task.
The operating system is responsible for the following
activities in connection with process management.
◦ Process creation and deletion.
◦ process suspension and resumption.
◦ Provision of mechanisms for:
● process synchronization
● process communication

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
2. Memory management
Memory is a large array of words or bytes, each with its own
address. It is a repository of quickly accessible data shared by
the CPU and I/O devices.
Main memory is a volatile storage device. It loses its contents in
the case of system failure.
The operating system is responsible for the following activities in
connections with memory management:
◦ Keep track of which parts of memory are currently being used and by
whom.
◦ Decide which processes to load when memory space becomes available.
◦ Allocate and deallocate memory space as needed

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
3. File management
A file is a collection of related information defined by its
creator. Commonly, files represent programs (both source
and object forms) and data.
The operating system is responsible for the following
activities in connections with file management:
◦ File creation and deletion.
◦ Directory creation and deletion.
◦ Support of primitives for manipulating files and directories.
◦ Mapping files onto secondary storage.
◦ File backup on stable (nonvolatile) storage media.

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
4. Security (Protection) system
Protection refers to a mechanism for controlling access
by programs, processes, or users to both system and
user resources.
The protection mechanism must:
◦ distinguish between authorized and unauthorized usage.
◦ specify the controls to be imposed.
◦ provide a means of enforcement.

Prep
ared
by :
Brij
esh
K hod
a
Functions of OS
5. Command interpretation
It means interaction of user with OS by commands. OS provides
a set of commands which user can use to give instructions to
computer system.

Many commands are given to the operating system by control


statements which deal with:
◦ process creation and management
◦ I/O handling
◦ secondary-storage management
◦ main-memory management
◦ file-system access
◦ protection
◦ networking

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
1. Batch OS
2. Multi programming
3. Multi processing
4. Time sharing
5. Real time OS

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
1.Batch OS
It is known as sequential job processing OS.
It works based on first-come-first-serve (FCFS)
Manner.
It means, only one process can be executed at a time. Only after
completion of first process, second process can be entered into CPU
for Execution.

❖ Advantages
After input process is over, user can do another job.
Os is less complicated.
❖ Disadvantages
Difficult to give priority scheduling.
Next process needs to wait until the completions of previous process.
Prep
ared
by :
Brij
esh
K hod
a
Types of OS
2. Multi programming
In multi programming os, there is only one processor,
which can execute more than one processes
simultaneously.
More than one processes stored in main memory and
cpu switches from one process to another process
immediately.

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
❖ Advantages
Many processes can run simultaneously.
Maximum utilization of cpu.
Job perform fast because not wait for batch.
❖ Disadvantages
OS is more complicated because many processes needs to be
handle.
Large main memory is required.
Maximum utilization of resources.
Must provide some memory protection system.

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
3. Multi processing
In multi processing OS, there are more than one
processors can handle more than one processes at a
time.
Because of more than one processes are being executed
at the same time, we can say it as parallel processing.

Prep
ared
by :
Brij
esh
K hod
a
Multi processing OS
❖ Advantages
It improves the performance of system because more
processes are executed.
In case of failure of one CPU, other can take over the
complete work load.
❖ Disadvantages
More completed because more processes needs to handle.
Large main memory is required.
Expansive.

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
4. Time sharing OS
In time sharing OS, CPU time is divided into equal part,
called “time-slice”.
Then, equal time slice is given to all users in network. So,
user can access the cpu for limited time.
Because of limited main memory, it is not possible to keep
programs of all users in main memory.
If a user can execute all its processes in that time slice, it
terminates. But if user can not complete its work, then that
user need to wait for next time slice.

Prep
ared
by :
Brij
esh
K hod
a
Time sharing OS
❖ Advantages
Cost is very less.
All users get equal time slice.
Reduce CPU idle time.
❖ Disadvantages
Most complicated to handle multiple users.
Protection & security against multiple users is required.

Prep
ared
by :
Brij
esh
K hod
a
Types of OS
5. Real time OS
A system in which transaction accesses and updates file
quickly to support original decision making is called
real time OS.
This system is used where immediate response from
computer is required.
Data are update in seconds, which affects your decision.
Such system is used in weather forecasting, air traffic
control, stock market and controlling of satellite
system.

Prep
ared
by :
Brij
esh
K hod
a
❖ Advantages
Data processing is very fast.
Fast response time.
❖ Disadvantages
Most complicated OS.
Most expansive OS

Prep
ared
by :
Brij
esh
K hod
a
Process
a program in execution.
When a process created, it requires several resources such
as CPU time, memory, files, stack, register etc. to run a
program.

Process states: Life time of a process can be divided into


several stages called “states”.

◦ new: The process is being created


◦ running: Instructions are being executed
◦ waiting: The process is waiting for some event to occur
◦ ready: The process is waiting to be assigned to a processor
◦ terminated: The process has finished execution

Prep
ared
by :
Brij
esh
K hod
a
Process state diagram

Prep
ared
by :
Brij
esh
K hod
a
Process scheduling criteria
CPU utilization – keep the CPU as busy as possible
Throughput – # of processes that complete their execution per
time unit
Execution time – the amount of time a Process remains in CPU
for execution.
Waiting time – amount of time a process waiting outside for
CPU.
Turnaround time – the amount of time from process creation to
its termination (life time of process) is called turnaround time.
(Execution time + Waiting time = Turnaround time)
Response time – amount of time it takes from when a request
was submitted until the first response is produced, not output (for
time-sharing environment)

Prep
ared
by :
Brij
esh
K hod
a
Process scheduling algorithms
Process scheduling :
Selects a process from many processes in memory that
are ready to execute, and allocates to the CPU for
execution.
This scheduling is done by different scheduling
techniques, which are called “process scheduling
algorithms”.
(1) First come first serve (FCFS)
(2) Shortest Job First (SJF)
(3) Round Robbin
(4) Multilevel Queue
Prep
ared
by :
Brij
esh
K hod
a
First Come First Serve (FCFS)
Process Burst Time
P1 24
P2 3
P3 3
Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:

P1 P2 P3

Waiting0 time for P1 = 0; P2 = 24;24P3 = 27


27 30

Average waiting time: (0 + 24 + 27)/3 = 17

Prep
ared
by :
Brij
esh
K hod
a
Shortest Job First(SJF)
Associate with each process the length of its next CPU
burst. Use these lengths to schedule the process with
the shortest time
SJF is optimal – gives minimum average waiting time
for a given set of processes
◦ The difficulty is knowing the length of the next CPU request

Prep
ared
by :
Brij
esh
K hod
a
Shortest Job First(SJF)
Process Arrival Time Burst Time
P1 6
P2 8
P3 7
P4 3
SJF scheduling chart
P4 P1 P3 P2

0 3 9 16 24

Average waiting time = (3 + 16 + 9 + 0) / 4 = 7


Prep
ared
by :
Brij
esh
K hod
a
Round Robbin
Each process gets a small unit of CPU time (time quantum),
usually 10-100 milliseconds. After this time has elapsed,
the process is preempted and added to the end of the ready
queue.
If quantum is q, then each process gthere are n processes in
the ready queue and the time ets 1/n of the CPU time in
chunks of at most q time units at once. No process waits
more than (n-1)q time units.
Performance
◦ q large ⇒ FIFO
◦ q small ⇒ q must be large with respect to context switch, otherwise
overhead is too high

Prep
ared
by :
Brij
esh
K hod
a
Round robbin
Process Burst Time
P1 24
P2 3
P3 3

The Gantt chart is:

P1 P2 P3 P1 P1 P1 P1 P1

0 4 7 10 14 18 22 26 30

Typically, higher average turnaround than SJF, but better


response

Prep
ared
by :
Brij
esh
K hod
a
Multilevel queue

Prep
ared
by :
Brij
esh
K hod
a
Physical memory v/s logical memory
Logical memory address :
It is generated by CPU. It is also known as virtual memory address.
Physical memory address:
It is actual address where data stored. It is generated by memory unit.

SR NO LOGICAL ADDRESS PHYSICAL ADDRESS

1 Address given by CPU. Address given by memory.

2 Generated at compile time. Generated by load time.


3 Set of logical addresses generated by a Set of physical address corresponding
program is called logical address space. to logical address is called physical
address.
4 Logical address is used in virtual Physical address is used in main
memory. memory.
5 Range of logical address is 0 to max Range of physical address is R+0 to
R+max.
Prep
ared (where R is base address.)
by :
Brij
esh
K hod
a
Memory Management Unit (MMU)
Hardware device that maps virtual to physical address.

In MMU scheme, the value in the relocation register is


added to every address generated by a user process at the
time it is sent to memory

The user program deals with logical addresses; it never sees


the real physical addresses

Prep
ared
by :
Brij
esh
K hod
a
MMU
Relocation register is a register, which stores the base address of user process
area in memory. This address will be added to every logical address to
generate physical address.

Prep
ared
by :
Brij
esh
K hod
a
Dynamic Memory Allocation
Techniques

Prep
ared
by :
Brij
esh
K hod
a
(A) Contiguous Memory Allocation
(1) Single Partition:
In single partition scheme, memory is divided into 2
parts where one part is reserved for OS and second part
is used to store user process & data.
Using Reallocation register, user processes protect from
each other. It contains smallest physical address.
limit register contains the range of logical address.

Prep
ared
by :
Brij
esh
K hod
a
(A) Contiguous Memory Allocation

Prep
ared
by :
Brij
esh
K hod
a
(A) Contiguous Memory Allocation
(2) Multiple partition:
(i) Fix size partition:
In fixed size partition, the user process area is divided
into equal sized memory blocks.
Each process will be stored in this fixed size block. If
the process is larger than block size, the next block is
allocated to that process. It means, one process with
size greater than block, may stored in more than one
block.
If the process is smaller than block size, internal
fragmentation is generated.
Prep
ared
by :
Brij
esh
K hod
a
(A) Contiguous Memory Allocation
(ii) variable size partition:
In variable sized partition, memory block according to
size of process is allocated. Hence, the size of memory
blocks are of different size.
The block of available memory (free block) is called
“HOLE”.
Holes of various size is given to newly coming process.
When process arrives, it is allocated memory from
hole, which is large enough to allocate it.

Prep
ared
by :
Brij
esh
K hod
a
(A) Contiguous Memory Allocation
Operating system maintains information about:
a) allocated partitions
b) free partitions (hole)
In this scheme, external fragmentation is generated.

Prep
ared
by :
Brij
esh
K hod
a
Dynamic Storage Allocation problem
(in variable size partition)
There are 3 techniques to satisfy a request of n size
block from a list of free holes.
(1) first fit : allocate the first hole that is big enough.
The entire memory is not checked.
(2) best fit: allocate the smallest hole that is big enough
must search entire list. This produces smaller leftover
holes.
(3) worst fit: allocate the largest hole. Must also search
entire list. This produces largest leftover hole.

Prep
ared
by :
Brij
esh
K hod
a
(B) Non Contiguous Memory Allocation
(1) Pagging :

Page no Frame no
pages

Prep
ared
by :
Brij
esh
K hod
a
(B) Non Contiguous Memory Allocation
Logical address space of a process can be noncontiguous; process is
allocated physical memory whenever the latter is available
Divide physical memory into fixed-sized blocks called frames (size is
power of 2, between 512 bytes and 8192 bytes)
Divide logical memory into blocks of same size called pages.
Keep track of all free frames. Free frame list contains available free
frames.
To run a program of size n pages, need to find n free frames and load
program
Set up a page table to translate logical to physical addresses
During this, Internal fragmentation is generated.

Prep
ared
by :
Brij
esh
K hod
a
(B) Non Contiguous Memory Allocation
(2) Segmentation:

Prep
ared
by :
Brij
esh
K hod
a
(B) Non Contiguous Memory Allocation
It is a memory management scheme, that supports user
view of memory.
A program is a collection of segments. A segment is a
logical unit which logically divides your program in
different segments.
The above segment table maps 2-dimensional physical
address which contains:
Base: contains starting physical address where segment
resides in memory.
Limit: specifies length of segment.
Prep
ared
by :
Brij
esh
K hod
a
Assignment -1
Q.No Questions marks
1 What is OS? Explain Functions of OS. 5
2 Explain types of OS. 5
3 What is process? Explain Process state diagram. 3
4 Explain Following terms: 1
(1) Throughput
(2) Turnaround time
(3) Execution time
(4) Waiting time
5 What is process scheduling? Explain different 5
process scheduling algorithms.
6 Differentiate : Logical address v/s Physica 3
address.
7 Explain MMU in detail. 3
8 Explain Contiguous Memory Allocation. 5
9 Explain Non – Contiguous Memory Allocation. 5
Prep
ared
by :
Brij
esh
K hod
a

You might also like