Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
org
www.bankersguru.org
www.bankersguru.org
Operating System
A program that acts as an intermediary between a user of a computer
and the computer hardware.
Operating system has following parts
kernel is a computer program that manages input/output requests
from software, and translates them into data processing
instructions for the CPU
Shell is a command line interpreter (CLI). It interprets the
commands the user types in and arranges for them to be carried
out.
www.bankersguru.org
www.bankersguru.org
PROCESS MANAGEMENT
A process is a program in execution. It is a unit of work within the system.
Program is a passive entity, process is an active entity.
Process Stages
Process can have one of the following five states at a time.
www.bankersguru.org
www.bankersguru.org
Process Scheduling
The problem of determining when processors should be assigned and to
which processes is called processor scheduling or CPU scheduling.
Scheduling Queues
www.bankersguru.org
www.bankersguru.org
Schedulers
Schedulers are special system softwares which handles process
scheduling in various ways. Their main task is to select the jobs to be
submitted into the system and to decide which process to run. Schedulers
are of two types
Context Switch
A context switch is the mechanism to store and restore the state or
context of a CPU in Process Control block so that a process execution can
be resumed from the same point at a later time.
www.bankersguru.org
www.bankersguru.org
Scheduling Criteria
CPU utilization – keep the CPU as busy as possible
Throughput – number of processes that complete their execution
per time unit
Turnaround time – amount of time to execute a particular process
Waiting time – amount of time a process has been waiting in the
ready queue
Response time – amount of time it takes from when a request was
submitted until the first response is produced.
www.bankersguru.org
www.bankersguru.org
www.bankersguru.org
www.bankersguru.org
THREADS
Thread is a light weight process that uses same address space for the
execution. As each thread has its own independent resource for process
execution, multiple processes can be executed in parallel by increasing
number of threads.
Advantages of Thread
Thread minimize context switching time.
Use of threads provides concurrency within a process.
Efficient communication.
Types of Thread
Threads are implemented in following two ways
www.bankersguru.org
www.bankersguru.org
PROCESS SYNCHRONIZATION
Process Synchronization means sharing system resources by processes in
a such a way that, Concurrent access to shared data is handled thereby
minimizing the chance of inconsistent data.
Mutex Locks
It provides support for critical section code. It is a strict software
approach, here in the entry section of code, a LOCK is acquired over the
critical resources modified and used inside critical section, and in the exit
section that LOCK is released.
www.bankersguru.org
www.bankersguru.org
Semaphores
It is a technique for managing concurrent processes by using the value of
a simple integer variable. This integer variable is called semaphore.
Semaphores are mainly of two types:
Binary Semaphore: A binary semaphore is initialized to 1 and only
takes the value 0 and 1 during execution of a program.
Counting Semaphores: A synchronizing tool and is accessed only
through two low standard atomic operations, wait and signal
designated by P() and V() respectively
Limitations of Semaphores
1. Priority Inversion is a big limitation os semaphores.
2. With improper use, a process may block indefinitely. Such a situation is
called Deadlock.
www.bankersguru.org
www.bankersguru.org
HANDLING DEADLOCK
Deadlocks can be prevented by avoiding at least one of the four
conditions.
Mutual Exclusion
Hold and Wait
No Preemption
Circular Wait
Deadlock can be avoided by using banker’s algorithm.
www.bankersguru.org
www.bankersguru.org
Memory management
Memory management is the functionality of an operating system which
handles or manages primary memory. Memory management keeps track
of each and every memory location either it is allocated to some process
or it is free. It checks how much memory is to be allocated to processes. It
decides which process will get memory at what time. It tracks whenever
some memory gets freed or unallocated and correspondingly it updates
the status.
Dynamic Loading
Dynamic Linking
Swapping
www.bankersguru.org
www.bankersguru.org
CONTIGUOUS ALLOCATION
In contiguous memory allocation each process is contained in a single
contiguous block of memory. The free blocks of memory are known as
holes. The set of holes is searched to determine which hole is best to
allocate
O O O O
S S S S
process 5 process 5 process 5 process 5
process 9 process 9
process 8 process 10
Fragmentation
As processes are loaded and removed from memory, the free memory
space is broken into little pieces. It happens after sometimes that
processes can not be allocated to memory blocks considering their small
size and memory blocks remains unused. This problem is known as
Fragmentation.
www.bankersguru.org
www.bankersguru.org
Paging
External fragmentation is avoided by using paging technique. Paging is a
technique in which physical memory is broken into blocks of the same
size called pages. When a process is to be executed, it's corresponding
pages are loaded into any available memory frames.
www.bankersguru.org
www.bankersguru.org
Segmentation
Segmentation is a technique to break memory into logical pieces where
each piece represents a group of related information. For example ,data
segments or code segment for each process, data segment for operating
system and so on. Segmentation can be implemented using or without
using paging.
Unlike paging, segment are having varying sizes and thus eliminates
internal fragmentation. External fragmentation still exists but to lesser
extent.
www.bankersguru.org
www.bankersguru.org
Virtual memory
Virtual memory is a technique that allows the execution of processes
which are not completely available in memory.This separation allows an
extremely large virtual memory to be provided for programmers when
only a smaller physical memory is available.
www.bankersguru.org
www.bankersguru.org
i
i
page
PAGE FAULT
An interrupt that occurs when a program requests data that is not in
memory. The interrupt triggers the operating system to fetch the data
from a virtual memory and load it into RAM.
www.bankersguru.org
www.bankersguru.org
PAGE REPLACEMENT
Page replacement algorithms are the techniques using which Operating
System decides which memory pages to swap out, write to disk when a
page of memory needs to be allocated.
First In First Out (FIFO) algorithm
Oldest page in main memory is the one which will be selected for
replacement.
Easy to implement, keep a list, replace pages from the tail and add
new pages at the head.
www.bankersguru.org
www.bankersguru.org
Page which has not been used for the longest time in main memory
is the one which will be selected for replacement.
Easy to implement, keep a list, replace pages by looking back into
time.
THRASHING
Thrashing is a condition in which excessive paging operations are taking
place. A system that is thrashing can be perceived as either a very slow
system or one that has come to a halt.
This leads to low CPU utilization.
www.bankersguru.org
www.bankersguru.org
myshop.mahendras.org
www.bankersguru.org