1. What is an Operating System?
A program that acts as an intermediary between a
user of a computer and the computer hardware.
Operating system goals:
Execute user programs and make solving user
problems easier.
Make the computer system convenient to use.
Use the computer hardware in an efficient manner.
2. Computer System Components
1. Hardware – provides basic computing resources
(CPU, memory, I/O devices).
2.Operating system – controls and coordinates
the use of the hardware among the various
application programs for the various users.
3.Applications programs – define the ways in
which the system resources are used to solve
the computing problems of the users (compilers,
database systems, video games, business
programs).
4.Users (people, machines, other computers).
3. 3
OPERATING SYSTEM
OVERVIEW
The Layers Of A
System
Program Interface
Humans
User Programs
O.S. Interface
O.S.
Hardware Interface/
Privileged Instructions
Disk/Memory/Screen
4.
5. Loading Operating System
• Press the power button in C.P.U
• The BIOS chip tells it to look in a fixed place, usually on the lowest-numbered
hard disk (the boot disk) for a special program called a boot loader (under
Linux the boot loader is called Grub or LILO). The boot loader is pulled into
memory and started. The boot loader's job is to start the real operating system.
• The loader does this by looking for a kernel, loading it into memory, and
starting it.
• Once the kernel starts, it has to look around, find the rest of the hardware, and
get ready to run programs.
• After this first stage, the kernel hands control to a special process called ‘init’
which spawns several housekeeping processes.
• Init's next step is to start several daemons. A daemon is a program like a print
spooler, a mail listener or a WWW server that lurks in the background, waiting
for things to do. These special programs often have to coordinate several
requests that could conflict.
• The next step is to prepare for users.
6.
7.
8. Process Management
A process is the unit of work in a system. Some of which are operating
system processes and remaining are user processes.
A program does nothing unless its instructions are executed by a CPU. A
process is defined as a program in execution. A process needs certain
resources, including CPU time, memory, files and I/O devices to
accomplish its task.
Operating system activities in connection with Process Management
Creation and deletion of both user and system processes.
Suspension and resumption of processes.
Provision of mechanisms for process synchronization.
Provision of mechanisms for process communication.
Provision of mechanisms for deadlock handling.
9. Threads and Processes
Process:one or more threads, along with their execution state. e or
more threads, along wi
Thread: a sequential execution stream that executes a series
of instructions in ordereir execution state.
Dispatching :Almost all computers today can execute multiple
threads simultaneously. Each processor chip typically
contains multiple cores Each core contains a complete CPU
capable of executing threads
Context switch: changing the thread currently running on a
core by first saving the state of the old process, then loading
the state of the new thread.
10.
11. •Several processes are submitted parallely to the system. The
processor serves very quickly each process on round robin basis or
more complex scheduling techniques and gives a flavour to the user
that the user is doing several works at the same time. This is
MULTITASKING
•MULTIPROGRAMMING is a similar concept but here a
process continues to run till there is an I/O call from the
program itself. Till then other processes remain suspended.
The objective of multiprogramming / multitasking is to have
some processes running at all time to maximize utilization of
CPU.
The objective of time sharing is to switch the processor
amongst processes so frequently that users can interact with
each program while it is running
12. Main-memory Management
Main-memory is a large array of words or bytes, ranging in size from
hundreds of thousands to hundreds of millions. The central processor
reads instructions from main-memory during the instruction-fetch
cycle, and both reads and writes data from main memory during the
data-fetch cycle. To process data from disk, first transferred to main
memory. To improve both the utilization of CPU and the speed of the
computer's response, keep several programs in memory. Selection of
a memory-management scheme depends on many factors.
Operating system activities in memory-management
-Keep track of which parts of memory are using by whom.
-Which processes are loaded into memory and when memory space
becomes available.
-Allocate and deallocate memory space as needed.
13. File Management
Computers can store information on several different types of physical media,
such as magnetic tape, magnetic disk, optical disk, etc. These media
properties include speed, capacity, data transfer rate and access method
(sequential or random).
A file is a collection of related information defined by its creator. Commonly
files represent programs (source and object) and data. Data files may be
numeric, alphabetic or alphanumeric. Files are organized into directories to
ease their use.
Operating System activities in File Management
Creation and deletion of files.
Creation and deletion of directories.
Manipulating files and directories.
Mapping of files onto secondary storage.
Backup of files on stable (non-volatile) storage media.
14. Input/Output System Management
Operating system is to hide the peculiarities of specific hardware
devices from the user, only the device driver knows the peculiarities
of the specific device to which it is assigned.
Operating system activities with respect to I/O sub-system
Memory management component including buffering, caching and
spooling.
A general device-driver interface.
Drivers for specific hardware devices.
15. Secondary-Storage Management
The main purpose of a computer system is to execute
programs. These programs, with the data they access must be
in main memory during execution. Most programs including
compilers, assemblers, sort routines, editors and formatters
are stored on a disk until loaded into main memory.
Operating System activities in disk management
Free-space management.
Storage allocation.
Disk scheduling.
16. Networking
A distributed system is a collection of processors that do not share
memory, peripheral devices or clock. Processors communicate with one
another through various communication lines.
Operating system activities in networking
Routing and connection strategies.
Control the problems of connection and security.
Access to a shared resources allows computation speedup, increased
data availability and enhanced reliability.
Protection System
If a computer system has multiple users and allows the concurrent
execution of multiple processes, then the various processes must be
protected from one another's activities.
17.
18. Error Detection - The operating system
constantly needs to be aware of possible
errors . Errors may occur in the CPU , memory
hardware , in I/O device , and in user programs
. It is duty of operating system that display
appropriate message whenever an error
occurs and takes the suitable action for
ensuring correct and consistent computing .
Communication - If more than one programs
are running on same computer , then there are
many instances , when one process needs to
exchange information with another process .
Thus operating system performs the process of
communication through message passing .
19. Protection - Protection involves ensuring that
all access to system resource is controlled .
When several disjoint programs execute
concurrently it should not possible for one
process to interfere with the others , or with
operating system . Security of the system
from the outsiders is also important . Such
security starts with the user having to
authenticate himself to the system , usually by
means of a password to be allowed access to
the resources .
20. FIFO Page replacement Algorithm
• Simplest page replacement algorithm
• When a page must be replaced, the oldest page is chosen.
• There is a FIFO queue.
• When a page is brought into the memory, we insert it at
the tail of the queue.
• We replace a page at the head of the queue.
21. Example – FIFO Algo
Lets consider that pages need be brought in memory in
given sequence
7 0 1 2 0 3 0 4 2 3 1 2
7 7
0
7
0
1
2
0
1
2
3
1
2
3
0
4
3
0
4
2
0
4
2
3
1
2
3
22.
23.
24. Multi-Level Feedback Scheduling in
Windows NT,XP,2000
The multilevel feedback-queue scheduling
algorithm,allows a process to move between
queues. The idea is to separate processes
according to the characteristics of their CPU
bursts. If a process uses too much CPU time, it
will be moved to a lower-priority queue.
This scheme leaves I/O-bound and interactive
processes in the higher-priority queues.
In addition, a process that waits too long in a
lower-priority queue may be moved to a higher-
priority queue.
29. Types of Memory
Registers(0.25ns)
Compilers
On -Chip Cache
Off -Chip Cache(Hardware)
Main Memory (80-250 ns)(OS)
Hard Disk (5*10^6 ns) (OS)
S
P
E
E
D
S
I
Z
E
The Operating System tries to read / write data from the fa
Smallest storage unit and goes down the above pyramid o
doesnot get data in the memory at the top of the pyramid.
(0.5 – 25 ns)
32. MEMORY ALLOCATION (MULTIPLE FIXED SIZE PARTITIONING)
P2
FREE
P1
FREE
FIXED
PARTIONS
a) A Process is selected from input queue and is loaded in free
partition.
b)When the process terminates the partition becomes free for other
processes.
34. Caching
Information is normally kept in main memory. As it
is used it is copied to a faster storage system
the cache on a temporary basis. When a
particular piece of information is needed, the
cache is first referred, if it is in the cache it is
used. This event is called CACHE HIT.
If it is not in the cache the event is called CACHE
MISS.
35. (MULTIPLE VARIABLE SIZE PARTITIONING – Dynamic Storage Allocation)
P2
FREE(Hole)
P1
FREE(Hole)
VARIABLE
PARTIONS
a. Operating system keeps a table indicating which part of
memory
Is free.
b. Memory is allocated to the processes until the remaining
free block of memory is unable to hold any process
Internal
Fragmentation
External
Fragmentation
36. • When a process arrives and need memory, the system searches for
a set of hole that is large enough for the process. It the hole is large
enough, it is split into two, one part sufficient to hold the process
and the free portion is returned to the set of holes.
• When the process releases the block of memory it is returned back
to the set of holes. If the new hole is adjacent to the set of holes the
adjacent holes are merged to form one larger hole.
37. Filling Strategies
• First Fit – Allocate the first hole that is big enough. Search can start
either at the begining of the set of holes or at a location where the
previous first fit search ended.
• Best Fit- Allocate the smallest hole that is big enough. We must
search the entire list unless the list is ordered by size. This strategy
produces the smallest leftover hole.
• Worst Fit- Allocate the largest hole. We must search the entire list,
unless it is sorted by size.
First fit and the best fit suffers from external fragmentation
38. External Fragmentation & Internal Fragmentation
• External Fragmentation – As processes are loaded and
removed from memory, the free memory space is
broken into little pieces. External fragmentation exists
when there is enough total memory space to satisfy a
request but the available spaces are not contiguous.
• Internal Fragmentation – When a free hole is
allocated to a process the hole may be a little larger
than the requested memory. For example let the
process size be 18462 bytes but hole allocated is
18466 bytes so internal fragmentation is 4 bytes.
39. PAGING CONCEPT
• Paging is a memory management scheme that permits
the physical address space in the main memory to be
non-contiguous. It avoids external fragmentation and
compaction.
40. BASIC METHOD OF PAGING
• Physical memory is broken into fixed sized blocks called frames.
• Logical memory space it the virtual memory space of a process is
broken down into blocks of fixed size called pages. Size of a page
is typically a power of 2 between 512 bytes and 16 MB.
• Every logical address generated by CPU is divided into two parts –
a) page no. (p)
b) page offset (d).
• The page no is used as index into a page table(exists physically).
• The page table contains the base address of each page in
physical memory.
41. PAGE 0
PAGE 1
PAGE 2
PAGE 3
Logical Memory
1
4
3
7
Page Table
page 0
page 2
page 1
page 3
0
1
2
3
Physical Memory
FrameNumber
0
1
2
3
4
5
6
7
p d
CPU
f d
Logical
Address
Physical
Address