0% found this document useful (0 votes)
2 views55 pages

Module 5-OS

The document provides an overview of operating systems, detailing their evolution from no OS to modern multi-tasking systems. It covers key functions such as process management, resource management, and file organization, as well as different types of operating systems like real-time and time-sharing systems. Additionally, it discusses file systems, storage management, and process scheduling, highlighting the importance of context switching and various scheduling types.

Uploaded by

xdias580
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)
2 views55 pages

Module 5-OS

The document provides an overview of operating systems, detailing their evolution from no OS to modern multi-tasking systems. It covers key functions such as process management, resource management, and file organization, as well as different types of operating systems like real-time and time-sharing systems. Additionally, it discusses file systems, storage management, and process scheduling, highlighting the importance of context switching and various scheduling types.

Uploaded by

xdias580
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

Module 5

Operating System
Uses operating systems to manage the
functionality of computers
• Introduction to Computer operating system
An operating system (OS) is a system software that provides a virtual
machine(hides hardware details, provides an interface to applications
and end users), manages computing resources (keeps track of resource
usage, grants/revokes permissions for resources), and executes
application software.

2
Evolution of Operating System
1) No OS (late 1940s – mid 1950s)
• ◦ Serial Processing – processed programs one after another
• ◦ Single user system.
• ◦ Programmer/User directly interacted with the hardware.
• ◦ No operating system.
• ◦ Programs loaded directly into computer
• ◦ Machines run from a console with display lights, toggle switches.

3
Features:
• Manual Program Scheduling
• uniprogramming
• processor sat idle when loading programs and doing I/O

4
2) Simple Batch System

◦ Introduced to maximize the processor utilization


◦ Programs recorded in a magnetic tape with an inexpensive machine
◦ OS loaded and executed programs in tape one at a time
◦ When the current program ended execution, its output was written to
another tape and OS loaded next program
◦ At the end of entire batch of programs, output tape was printed with
an inexpensive machine

5
Features
• No direct access to hardware
• Uniprogramming
• High response time
• Processor sat idle during I/O

6
3) Multi-Programmed batch Systems

◦ Central theme of modern OS


◦ Introduce in 3rd generation to minimize the processor idle time
during I/O
◦ Memory is partitioned to hold multiple programs
◦ When current program waiting for I/O, OS switches processor to
execute another program in memory
If memory is large enough to hold more programs, processor could
keep 100% busy
7
4) Time Sharing System

◦ Introduced to minimize the response time and maximize the user


interaction during program execution
◦ Uses context switching
◦ Enables to share the processor time among multiple programs
◦ Rapidly switching among programs, credits illusion of concurrent
execution of multiple programs

8
Following are some of important functions of an operating System.
Process Management
Resource Management ,(Memory, I/O device, Storage)
User Interfacing Security Protection

9
Different types of
operating system

Based on user Based on no of tasks

Single user- Facilities Multi user-Facilities Single Task-executes Multi task- executes
single user to use the multiple users to use only one program at a multiple programs at
system at a time . the system at a time. time. a time.

10
Different types of Operating Systems
• Single user-single task– A single task is performed by one user at a time.
• Single user-Multi task- Several programs are run at the same time by a single user.
• Multi user-Multi task – A multi-user operating system has been designed for more
than one user to access the computer at the same or different time.
• Multi-threading – A thread is also called a sub process. Threads provide a way to
improve application performance through the parallel execution of sub process.
• Real Time – OS is designed to run applications with very precise timing and with a
high degree of reliability.
• The main objective of real-time operating systems is their quick and predictable response to
events.
• These types of OS are needed in situations where downtime is costly or a program delay could
cause a safety hazard.
• Time Sharing Systems– o Processor’s time is shared among multiple users/applications

Features of Timesharing operating systems are as follows:


o Provides quick response
o Reduces CPU idle time
11
5.2 Explores how an operating system manages
directories/folders and files in computers.
• Files A file is a named collection of related information, usually a sequence
of bytes
• A file can be viewed in two different ways.
• Logical (programmer’s) view: how the users see the file.
◦ Liners collection of records.
◦ Image File – cells(pixels) of intensity values
◦ Linear sequence of bytes.
• Physical (operating system) view: how the file is stored on secondary
storage.
◦ Many possibilities, not necessarily contiguous

12
File Attributes
• Each file has an associated collection of information(attributes)
• file name
• type (e.g., source, data, executable)
• Owner • location(s) on the secondary storage.
• organization (e.g. sequential, indexed, random)
• access permissions – who is permitted to read/write/delete
data in the file.
• time and date of creation, modification, last access
• file size

13
File Types
• One of the possible implementation techniques of file type is to
include the type as an extension to the file name.
• File can be classified into various types based on the content. •
Executable(.exe)
• Text(.txt, .docx, …etc)
• Image(.bmp, .png, .jpeg, …etc)
• Video (.vob, .flv, .swf,…etc)
• Audio (.wav, .mp3,…etc)
• Compressed( .rar, .zip,…etc)

14
Directory and file organization
• Directories
They are continues used to organize files logically.
• File Structure
• A File Structure is a format that the operating system can understand.
• A file has a certain defined structure according to its type.
• A text file is a sequence of characters organized into lines.
• An object file is a sequence of bytes organized into blocks that are
understandable by the machine.

15
File Systems
• A file system is used to control how data is stored and retrieved.
• FAT (File Allocation Table)
• FAT is the file systems introduced with Microsoft Disk Operating System (MS
DOS).
• FAT uses a File Allocation Table (FAT) to keep track of files in the storage
devices
• FAT and the root directory reside at a fixed location of the volume so that the
system's boot files can be correctly located. To protect a volume, two copies
of the FAT are kept

16
NTFS (New Technology File System)
• It is a proprietary file system developed by Microsoft. This is
improvement of FAT. This improvement includes
• The capability to recover from some disk-related errors automatically, which
FAT cannot.
• Support with Unicode encoding system
• Improved support for larger hard disks.
• Better security as permissions and encryptions are used to restrict access to
specific files to approved users

17
• File Security
• Passwords
• Access privileges
• Authentication
• It refers to identifying each user of the system and associating the executing
programs with those users. It is the responsibility of the Operating System to
create a protection system which ensures that a user who is running a particular
program is authentic. Operating Systems generally identifies/ authenticates
users using following three ways:
• Username / Password - User need to enter a registered username and password
with Operating system to login into the system.
• User attribute - fingerprint/ eye retina pattern/ signature - User need to pass
his/her attribute via designated input device used by operating system to login into
the system.

18
• Disk Fragmentation
• Fragmentation is the unintentional division of Disk into many small free areas
that cannot be used effectively due to scattered storage of file fragments.
• Defragmentation
• Defragmentation is a process that locates and eliminates file fragments by
rearranging them.

19
File Storage Management
• Space Allocation
• Files are allocated disk spaces by operating system. Operating systems deploy
following three main ways to allocate disk space to files.
• Contiguous Allocation
• Linked Allocation
• Indexed Allocation

20
Contiguous Allocation
• Allocate disk space as a collection of adjacent/contiguous blocks. This
technique needs to keep track of unused disk space.
• Features:
o Simple.
o Easy Access.
o File size is not known at the time of creation.
o Extending file size is difficult
o External fragmentation (free unusable space between allocation)

21
Linked Allocation
• Inside each block a link is maintained to point to where the next block
of the file is.
• Features:
• No external fragmentation.
• Files can grow easily.
• Many seek are required to access file data
• Example: MSDOS FAT file system

22
Indexed Allocation
• Creates a table of pointers(index) at the time of the file creation. This
table is modified as new blocks are allocated for the file or removed
from the file. The index table is also saved in a block/s.
• Example : UNIX file system
• Features
• File ends at nil pointer
• No external fragmentation
• Each block contains pointer to next block
• No compaction, external fragmentation

23
Maintenance of Secondary storage
• Secondary storage is the non-volatile repository for both user and
system data and programs. Secondary storage is typically used to
store
• Source program
• Executable programs
• Data for the program
• Temporary data

24
Disk formatting
• Formatting is the process of preparing a data storage device for initial
use which may also create one or more new file systems.
• The first part of the formatting process that performs basic medium
preparation is often referred to as "low-level formatting”. Partitioning
is the common term for the second part of the process, making the
data storage device visible to an operating system.
• The third part of the process, usually termed "high-level formatting"
most often refers to the process of generating a new file system.

25
1. Recovery of data from a formatted disk
• As file deletion is done by the operating system, data on a disk are not
fully erased during every high-level format. Instead, links to the files
are deleted and the area on the disk containing the data is retains
until it is overwritten.

26
5.3: Explores how an operating system
manages processes in computers.
• What is Process?
• Process is a fundamental concept in modern operating systems.
• A process is basically a program in execution.
• Process is not a program. A program may have many processes.

• Type of processes
• I/O bound processes
• Processor bound processes

27
• Process requirements
• The process must have (at least):
• ID
• Executable code
• Data needed for execution
• Execution context (PC, priorities, waiting for I/O or not)
• Process creation
• Reasons for process creation:
• New batch job
• User starts a program
• OS creates process to provide a service
• Running program starts another process
28
Process Termination
• On process termination, OS reclaims all resources assigned to the
process.
• Reasons for process termination:
• Normal termination,
• Execution time-limit exceeded,
• A resource requested is unavailable,
• An execution error
• A memory access violation,
• An operating system or parent process request
• Parent process has terminated.

29
• These and many other events may either terminate the process, or
simply return an error indication to the running process. In all cases,
the operating system will provide a default action which may or may
not be process termination.

30
• Interrupts
• Interrupt is an event that alters the sequence of execution of process.
• Interrupt can occur due to a time expiry an OS service request I/O completion.
• For example when a disk driver has finished transferring the requested data, it
generates an interrupt to the OS to inform the OS that the task is over.
• Interrupts occur asynchronously to the ongoing activity of the processor. Thus the
times at which interrupts occur are unpredictable.

• Interrupt Handling
• Generally I/O models are slower than CPU. After each I/O call, CPU has to sit idle until I/O
device complete the operation, and so processor saves the status of current process and
executes some other process. When I/O operation is over, I/O devices issue an interrupt to
CPU then stores the original process and reserves execution.

31
Process Management
• In multiprogramming environment, the OS decides which process
gets the processor when and for how much time. This function is
called process scheduling. An Operating System does the following
activities for processor managements:
• Keeps tracks of processor and status of process. The program
responsible for this task is known as traffic controller.
• Allocates the processor (CPU) to a process.
• De-allocates processor when a process is no longer required

32
Process State
Seven State Process Transition diagrams

33
Process Transitions
• The operating system’s role is to manage the execution of existing and
newly created processes by moving them between the two states
until they finish. For simplicity (of both understanding and
implementation) modern operating systems support the idle process
which is always ready to run, and never terminates. Newly created
processes are created and marked as ready, and are queued to run.
As the single running process terminates or is interrupted, it is
marked as Ready by the operating system, and the next Ready
process is commenced (or continued).
• Here the operating system has the role of a dispatcher: dispatching
work for the processor according to some defined policy addressing
fairness, priority, apparent “interactivity‘”
34
• Process Control Block (PCB) A Process Control Block is a data structure
maintained by the Operating System for every process. The PCB is
identified by an integer process ID (PID). A PCB keeps all the
information needed to keep track of a process as listed below in the
table:

35
• The architecture of a PCB is completely dependent on Operating
System and may contain different information in different operating
systems. Here is a simplified diagram of a PCB:
• The PCB is maintained for a process throughout its lifetime, and is
deleted once the process terminates.
• Generally I/O models are slower than CPU. After each I/O call, CPU
has to sit idle until I/O device complete the operation, and
so processor saves the status of current process and
executes some other process. When I/O operation is over,
I/O devices issue an interrupt to CPU then stores the
original process and reserves execution.

36
Context Switching
• 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.
• Using this technique a context switcher enables multiple processes to share
a single CPU. Context switching is an essential part of a multitasking
operating system features.
• When the scheduler switches the CPU from executing one process to
execute another, the context switcher saves the content of all processor
registers for the process being removed from the CPU, in its process control
block.
• Context switch time is pure overhead.
• Context switching can significantly affect performance as modern
computers have a lot of general and status registers to be saved.

37
38
Types of Scheduling
• Long-term scheduling (Job scheduling): It determines which
programs are admitted to the system for processing. Job scheduler
selects processes from the queue and loads them into memory for
execution. Process loads into the memory for CPU scheduling.
• Medium-term scheduling: Medium term scheduling is in charge of
swapping processes between the main memory and the secondary
storage.
• Short-term scheduling (low-level scheduling): Determines which
ready process will be assigned the CPU when it next becomes
available.

39
Long-term scheduling (Job scheduling)
• Determines which processes are admitted to the system for processing
• Controls the degree of multiprogramming
• If more processes are admitted
better CPU usage
less likely that all processes will be blocked
The long term scheduler may attempt to keep a mix of processor-bound and I/O
bound processes.

Medium-Term Scheduling
• Swapping decisions based on the need to manage multiprogramming
• Done by memory management software

Short-Term Scheduling
• Determines which process is going to execute next (also called CPU scheduling)
• The short term scheduler is known as the dispatcher
Dispatching the CPU to the process 40
Scheduler Comparison

41
Process Schedulers
Assigning the processor to the processes.
• Turnaround time : Time required for a particular process to complete,
from submission time to completion.
• Response time : The time taken in an interactive program from the
issuance of a command to the commence of a response to that
command.
• Throughput : Number of processes completed per unit time. May
range from 10 / second to 1 / hour depending on the specific
processes.
• Waiting time : How much time a process spends in the ready queue
waiting its turn to get on the CPU. 42
Scheduling Policies
Non-preemptive
Once a process is in the running state, it will continue until it
terminates or blocks itself for I/O.

Preemptive
• Currently running process may be interrupted and moved to the Ready
state by the OS.
• Allows for better service since any one process cannot monopolize the
processor for very long

43
5.4: Explores how an operating system
manages the resources
Memory Management Memory management is the functionality of an
operating system which handles or manages primary memory and
moves processes back and forth between main memory and disk
during execution.
Memory management keeps track of each and every memory location,
regardless of 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.

44
An Operating System does the following activities for memory
management:
• Keeps tracks of primary memory, i.e., what part of it are in use by
whom, what part are not in use.
• In multiprogramming, the OS decides which process will get memory
when and how much.
• Allocates the memory when a process requests it to do so.
• De-allocates the memory when a process no longer needs it or has
been terminated.

45
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.
MMU uses the following mechanism to convert virtual address to physical
address.
• The value in the base register is added to every address generated by a user
process, which is treated as offset at the time it is sent to memory. For
example, if the base register value is 10000, then an attempt by the user to
use address location 100 will be dynamically reallocated to location 10100.
• The user program deals with virtual addresses; it never sees the real physical
addresses. 46
Paging
• Logical address space of a process can be non-contiguous; 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
• 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“
• Internal fragmentation"
47
48
Mapping
The operating system takes care of mapping the logical addresses to
physical addresses at the time of memory allocation to the program.
The runtime mapping from virtual to physical address is done by the
memory management unit (MMU) which is a hardware device.

49
Virtual memory
• It Is it necessary to load an entire program to the memory for
execution?
• If the size of the program is larger than the available memory how can
it be execute?

50
Virtual memory is partitioned in to equal size pages.
Main memory is also partitions into equal size page frames.
Size of a page = size of a page frame
Programs are also partitioned into pages at the time of loading.

• Process runs on a virtual machine as defined by the underlying hardware.


• Focus is on Hardware support for a virtual address space
virtual addresses independent of physical memory
• Key hardware component is the Memory Management Unit (MMU)
address translation: virtual to physical memory
ensures virtual address space protection

Virtual memory serves two purposes.


First, it allows us to extend the use of physical memory by using disk.
Second, it allows us to have memory protection, because each virtual address is
translated to a physical address.
51
Virtual memory – Goals
• Allow applications larger than physical memory to execute.
• Run partially loaded programs – Entire program need not to be in
memory all the time.
• Degree of Multiprogramming: Many programs simultaneously reside
in memory.
• Application Portability:
• Applications should not have to manage memory resources
• Program should not depend on memory architecture.
• Permit sharing of memory segments or regions. •
• For example, read-only code segments should be shared between program
instances

52
Input and output Device Management
Device driver
• Device driver is software.
• The computer communicates with peripheral devices through device
drivers.
• A driver provides a software interface to hardware devices, enabling
operating systems and other computer programs to access hardware
functions without knowing the precise hardware details.
• Device drivers depends on both the hardware and the operating
system loaded in to the computer

53
Spooling
Spooling is an acronym for simultaneous peripheral operations on line.
Spooling refers to putting data of various I/O jobs in a buffer. This buffer is a
special area in memory or hard disk which is accessible to I/O devices.
An operating system does the following activities related to distributed
environment:
• Handles I/O device data spooling as devices have different data access rates.
• Maintains the spooling buffer which provides a waiting station where data
can rest while the slower device catches up
• Maintains parallel computation because of spooling process as a computer
can perform I/O in parallel fashion. It becomes possible to have the computer
read data from a tape, write data to disk and to write out to a tape printer
while it is doing its computing task. 54
Advantages
• The spooling operation uses a disk as a very large buffer.
• Spooling is capable of overlapping I/O operation for one job with processor
operations for another job.
55

You might also like