Operating system
2019 onwards
New syllabus
Advanced Level
Sri Lankan
1 | Page
OPERATING SYSTEM
Operating system
Operating system is a collection of software that manages
computer hardware resources and provide common services for
other software.
Operating system acts as an interface between computer
hardware and users.
Operating system co-ordinates computer hardware and software
2 | Page
Operating system Developers
I. Dennis Ritchie and Ken Thompson
UNIX
II. Linus Torvalds
Linux
Examples for Operating system
1. UNIX
2. GNU/Linux
3. MS Word
4. Sun Solaris
5. VST
6. IBM OS/2
7. DOS (Disk Operating system)
8. Novell Netware
9. Android
GUN/Linux Distribution
Red Hat
Fedora
Mint
Ubuntu, etc.
GUN/ Linux is an open source operating system
3 | Page
Functions of Operating system
1. Process Management
2. Memory Management
3. File Management
4. Input / Output Devices or Hardware Management
5. Network /Security Management
6. Interfacing between hardware and user
PROCESS MANAGEMENT
A process is a program in execution
A program can have multiple processes
Note: -
A program does nothing unless its instructions are
executed by a CPU.
A process will need certain resources CPUtime, memory, files,
and input/output devices to accomplish its task
Resources are allocated to the process either when it is created or
while it is executing
4 | Page
Function of Process Management
1. Creating and Deleting processes.
2. Scheduling processes on the CPU.
3. Suspending and resuming process.
4. Providing mechanisms for process communication
Process state transition diagram
As a process executes , it change states
1. New/Created – The process is being created.
2. Ready -The process is waiting to be assigned to a processor.
3. Running – Instructions are being executed.
4. Waiting -The process is waiting for some event to occur (such
as an I/O completion)
5. Terminated /Exit- The process has finished execution
5 | Page
Seven states process transition diagrams
6 | Page
Context Switch
In an operating System, suspending the current process
temporarily and resuming it again or starting another process is
called context switch.
It requires performing a state save of the current process (at PCB)
and a state restore of a different process
7 | Page
Process control Block (PCB)
Each process is represented in the operating system by a PCB.
In an operating system,PCB is data structure containing the
information needed to manage a particular process.
PCB contains the following information regarding process
1. Process no
2. Process state
3. Program counter
4. CPU register
5. Process scheduling state
6. CPU scheduling information
7. Memory management information
8. I/O status information
PCB Diagram
8 | Page
Schedulers
Operating system selects process from the queues. The selecting
process is carried out by the appropriate scheduler.
1. Long -Term schedulers
A long-term scheduler decides which process are to be admitted
to the ready queue.
2. Medium term schedulers
Medium term schedulers temporarily remove processes from
main memory and places them in secondary storage (swapping).
9 | Page
3. Short Term Schedulers
Short term schedulers decide to be executed (allocated a CPU).
NOTE: - It is called CPU scheduler
Short term scheduler makes scheduling decision much more
frequently than the long or mid-term scheduler.
Inter process communication
Shared memory – A region of memory that is shared by process is
established
Message passing -Messages exchanged between the process
Maximizing CPU Utilization
1. MultiProgramming
2. Time sharing
10 | P a g e
MEMORY MANAGEMENT
Memory management is the function of an operating system
responsible for managing the memory.
Memory should be shared among multiple process.
Memory is a resource for process.
Memory consist of the following: -
Bytes words
Address
Activities of Memory Management
1. Allocating memory for process
2. Resolving memory
3. Keeping track of memory currently being used
11 | P a g e
A process must be in memory to be executed.
A process can be suspended temporarily out of memory to a
backing store in order to free memory place another process in
the main memory and then brought back into memory for
continued execution.
12 | P a g e
Virtual memory
Virtual memory is a technique that allows the execution of
process that are not completely in memory.
Advantages
It can be larger than physical memory.
When an application requires more memory space than the
maximum memory space available in the main memory of a
computer is ready for execution , operating system uses virtual
memory system.
13 | P a g e
Page Tables
Page tables are used to map/translate the virtual / process page
used by the application into physical address frames used by the
hardware to process instructions.
14 | P a g e
Question:-
1. Calculate the total number of pages of defined by the above
addressing scheme
26 =64bits
[Link] the following Virtual memory address
0101110000111100
What is the page and displacement of this address.
010111 0000111100
Page Displacement
FILE MANAGEMENT
It is the manipulation of documents and data in files an a
computer.
File attributes
1. Name
2. Type
3. Location
4. Size
5. Protection
6. Time & date
File operations
1. Creating a file
2. Writing a file
3. Reading a file
4. Deleting a file
5. Moving a file
15 | P a g e
File system
A file system is used to control how data stored and retrived.
File system and operating system
EG: - Windows OS, NTFS, FAT, Linux –EXT
MS Windows: -
FAT- File Allocation Table
NTFS – New Technology file system
REFS – Resilient file system
Linux
Ext2/Ext3/Ext4
Reise FS
Mac OS
HFS
HFS +
16 | P a g e
NTFS VS FAT
FAT NTFS
Maximum File Size Limited Unlimited
Maximum File Name Limited Unlimited
Length
Security No Yes
Support Of Unicode No Yes
Disk De-Fragmentation
Consolidating Fragmented Files of hard disk to improve
system Performance.
17 | P a g e
Fragmented Files
Consolidating fragmented files on hard disk to improve system
performance.
After defragmentation the ascending speed of a file increases.
Disk Partitions
Disk partitioning is the act of dividing a hard disk drive into multiple
logical storage.
Advantages
Efficient retrieval of files
Seperation of the operating system and program files from
user files.
Use of multi-boot setups.
18 | P a g e
Disadvantages
Reduces the total space.
Reduce overall disk performance.
Increases disk fragmentation.
User Interfaces
1. Command Line Interface
Command Base Interface
EG:- Dos
2. Graphical User Interface (GUI)
WIMP-Window,Icon,Menus,Pointer
GUI-User friendly, More memory needed.
CLI-Less user friendly, Less memory length.
Device Driver
A device driver is a system program that operates or controls
particular device that is attached to a computer.
19 | P a g e
Types of operating system
Single user – Multi Tasking OS.
Multi user OS.
Real Time OS.
Single Tasking OS.
Multi Tasking OS.
Embedded OS.
Distributed OS.
Multi Threading OS.
Single user – Multi Tasking OS
This is type of operating system have only one user but may
allow multiple programs to run at the same time.
EG:-MS-windows,GNU/linux,Mac OS
Multi User OS
A multiuser operating system allows multiple users to access a
computer at the same time.
EG:-GNU/Linux,UNIX
20 | P a g e
Single Tasking OS
A single tasking operating system allows only one running
program.
EG:-DOS (Disk Operating System)
Multi Tasking OS
A multi tasking operating system allows more than one
program to be running at the same time .
EG:-Soloris,GNU/Linux
Real-Time OS
A real time operating system is a multi tasking operating
system that aims at executing real time applications.
EG:-Lynx OS,RTLinux
Embedded OS
This type of operating system is designed to be used in
embedded computer system. It’s designed to operate on
small machines like [Link] is able to operate with a limited
number of resources.
EG:- MS Windows CE , Minix 3,IOS,Android
21 | P a g e
Distributed OS
This type of OS manage a group of independed computers and
makes them appear to be single computer.
Distributed computations are carried out on more than one
machine.
EG:-GNU/Linux, UNIX
Multi Threading OS
Multi Threading OS concurrently runs program by dividing
sub-components.
It’s offers better utilization of process and resources.
EG:-GNU/Linux
Garbage Collection
Garbage collection is an automatic memory management.
It is an attempt to reclaim memory occupied by processes that
are no longer in use by the program.
22 | P a g e
Disk Checking
Disk checkings a process to find files or areas that are
corrupted in a hard disk.
Demand paging
Demand Paging is a loading of pages only as they are needed.
It’s commonly used in virtual memory system.
Memory Utilization Technique
Dynamic Loading - To Obtain better memory space
utilization, we can use dynamic loading.
With dynamic loading a routine is not loaded until it is called.
Space Allocation
Files are allocated disk spaces by operating system
Operating systems deploy following them main ways to
allocated disk space to files.
[Link] Allocation
23 | P a g e
[Link] Allocation
[Link] Allocation
Allocating disk space as a collection of a adjacent
/contiguous blocks
This technique needs to keep track of unused disk space.
Characteristics
Simple
Easy access
File size is not need to know at the time of creation.
Extending file size is difficult.
External fragmentation ( free unusable space between
allocation ).
24 | P a g e
Contiguous Allocation
25 | P a g e
Linked Allocation
Characteristics
No external Fragmentation
Files can grow easily
Mainly seeking techniques are required to access file
data
26 | P a g e
Indexed Allocation
Characteristics
File ends at nill Pointer
No external fragmentation
Each blocks contains pointer to next block.
No compaction, external fragmentation
27 | P a g e
Scheduling Policies
Preemptive scheduling :- The CPU is allocated to the process
for the limited time.
Non-Preemptive scheduling:-The CPU is allocated to the
process till it terminates or switches to waiting state.