Вы находитесь на странице: 1из 48

Computer Hardware and System

Software Concepts
Introduction to concepts of Operating System (Process & File Management)
Operating System
Process Management
Process Management

Functions:
– To keep track of the status of each process

– To suspend and choose some processes based on some criteria

– To coordinate inter process communication

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


3
Technologies Ltd Version No: 2.0
Some concepts

Processor
– Hardware component that is capable of executing instructions

Process
– An instance of a program in execution

– Is an active entity whereas a program is a passive entity

– Needs certain resources for execution in which a processor is one of them

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


4
Technologies Ltd Version No: 2.0
Structure of a process

Code Region : Contains the executable instructions of the process

Data Region : Holds the data areas used by the process

Stack Region : Holds the dynamic data such as local data in a


procedure,arguments to a procedure/function etc.

Program Counter (PC): The PC gives the address of the next instruction to be
executed by the process.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


5
Technologies Ltd Version No: 2.0
States of a process

New : Created

Ready : Assign a process to a processor

Run : Instruction execution

Blocked : For an event to occur (Ex: I/O)

Terminated : Finished execution

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


6
Technologies Ltd Version No: 2.0
Process State Diagram.

Admitted
New
Interrupt
Ready
I/O or Event
Completion Running Exit
IO or Event
Waiting wait(Blocked) Terminated

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


7
Technologies Ltd Version No: 2.0
Context switching

The task of switching the CPU to another process by saving the state of the old
process and loading the saved state of the new process is known as context
switching

Context switching
– Keeps the CPU busy all the time

– Occurs when any of the following situations is encountered


• An I/O operation is initiated

• An interrupt occurs

• An I/O is completed

• A process terminates

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


8
Technologies Ltd Version No: 2.0
Concurrent processes

Concurrent processes execute in operating systems and can be of two types


viz.,
– Independent

– Co-operating

Independent process - are those processes which cannot affect or be affected


by other processes executing in the system.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


9
Technologies Ltd Version No: 2.0
Co-operating processes

Benefits
– Sharing of information

– Computation speed-up

– Modularity

– Convenience

Communication
– Message passing

– Shared memory

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


10
Technologies Ltd Version No: 2.0
Some concepts

Uniprogramming

Multiprogramming

Multiprocessing

Multitasking

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


11
Technologies Ltd Version No: 2.0
Scheduling

Policy to decide which ready process is to be picked up next.

Criteria which lets a particular policy to be chosen are the following:


– CPU Utilisation

– Throughput

– Turnaround time

– Waiting time

– Response time

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


12
Technologies Ltd Version No: 2.0
Scheduling policy

Scheduling policies are of two categories


– Non-Preemptive scheduling

– Preemptive scheduling

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


13
Technologies Ltd Version No: 2.0
Non-preemptive scheduling

CPU is allocated to a process till the job is over or incurs an I/O wait

Example
– FCFS ( First Come First Serve )

Disadvantage

Monopoly of the process

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


14
Technologies Ltd Version No: 2.0
Example

Find the average waiting time for FCFS for the following processes whose CPU
time is given below:
P1 – 6 ms

P2 – 8 ms

P3 – 7 ms

P4 – 3 ms

Gantt Chart’s are used to analyze and evaluate the CPU scheduling.

A Gantt chart is graphical representation of duration of task against


progression of time.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


15
Technologies Ltd Version No: 2.0
Example contd..

P2 P3 P4
P1
0 6 21 24
14
time

Average waiting time= 10.25


Average Turn around time=16.25
Average Response Time=

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


16
Technologies Ltd Version No: 2.0
Preemptive scheduling

Fixed time slice is specified during which a process gets attention

If the process gets terminated before the time slice then CPU makes a context
switch

Example
– Round Robin

– Shortest Job First(SJF)

– Priority Scheduling

SJF and Priority Scheduling may be either preemptive or non-preemptive.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


17
Technologies Ltd Version No: 2.0
Round Robin Scheduling

Let the time quantum be 4 msec.


P1 – 6 ms,P2 – 8 ms,P3 – 7 ms,P4 – 3 ms

4 8 12 24
Average Waiting time=13.25

P1 P2 P3 P4 P1 P2 P3

15 17 21

Average Turn Around time=?


Average Response Time=?

Round Robin is a Preemptive Scheduling algorithm by nature

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


18
Technologies Ltd Version No: 2.0
Priority Scheduling (Non Preemptive method)

Process Execution Time Priority Arrival time in msec

P1 10 2 0

P2 4 1 2
P3 6 3 0

P1 P2 P3

0 10 14 20

What is the Average waiting time and Average


Turnaround time?

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


19
Technologies Ltd Version No: 2.0
Priority Scheduling (Preemptive method)

Process Execution Time Priority Arrival time in msec

P1 10 2 0

P2 4 1 2
P3 6 3 0

Preempt P1

P1 P2 P1 P3

0 2 6 14 20

What is the Average waiting time and Average


Turnaround time?

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


20
Technologies Ltd Version No: 2.0
Priority scheduling contd…

Disadvantage

Due to priority some low priority jobs have to wait for longer time when the
frequency of high priority jobs are more

Solution

Aging :It is a concept in which the priority of a process is increased after some
time

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


21
Technologies Ltd Version No: 2.0
Threads

Thread is light weight where as a process is heavy weight.

A thread is a part of the program. But a process is a program itself

In the case of multi threading two parts of the same program can execute
simultaneously

Threads shares the same address space, data section and resources

Different Stack (to hold local data) and PC.

Context switching is easy in the case of threads

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


22
Technologies Ltd Version No: 2.0
Operating System
File Management
File Management

Part of the Operating System that deals with effective information


management

Features:
– Minimal I/O operations on files

– Flexibility between logical and physical block size

– Automatic allocation of file space

– Flexible file naming facility such as links, aliases etc

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


24
Technologies Ltd Version No: 2.0
File System.

File System is a method of storing and managing the files, which contain data.

This makes it easy to locate and access the data.

Different Operating Systems incorporate different File Systems.

Example.

– FAT (File Allocation Table)

– NTFS (New Technology File System)

– Unix File System

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


25
Technologies Ltd Version No: 2.0
FAT.

File Allocation Table (FAT) is a file system that was developed for MS-DOS.

It is used in consumer versions of Microsoft Windows up to and including Windows Me.

The purpose of the “File Allocation Table” is to keep track of which areas of the disk are
available and which areas are in use.

FAT 12 was the first version in FAT.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


26
Technologies Ltd Version No: 2.0
Versions of FAT.

FAT12

FAT16

FAT32

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


27
Technologies Ltd Version No: 2.0
FAT12.

Uses a 12-bit binary number to hold the cluster number.

can hold a maximum of 4,086 clusters.

most suitable for very small volumes, and is used on floppy disks and hard disk partitions
smaller than about 16 MB

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


28
Technologies Ltd Version No: 2.0
FAT16.

Uses a 16-bit binary number to hold the cluster number.

can hold a maximum of 65,526 clusters.

used for hard disk volumes ranging in size from 16 MB to 2,048 MB.

VFAT (called Virtual FAT) is a variant of FAT16.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


29
Technologies Ltd Version No: 2.0
FAT32.

Uses a 28-bit binary number to hold the cluster number, as 4 of the 32 bits are "reserved.

Can theoretically handle volumes with over 268 million clusters.

Can support (theoretically) medium up to 2 TB in size.

maximum file size is 4GB

Used in by newer versions of Windows, like Windows 98, Windows ME and Windows
2000.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


30
Technologies Ltd Version No: 2.0
File systems

MSDOS - file system

UNIX - file system

NTFS

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


31
Technologies Ltd Version No: 2.0
MS DOS-File system

MS-DOS has a tree structure i.e. files are organized on each logical drive
within a hierarchical directory structure.

Root directory is the top directory which holds numerous files and sub-
directories.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


32
Technologies Ltd Version No: 2.0
MS DOS-File system

Naming convention in DOS consists of


– Logical drive

– Path

– Filename

Example:

C:\ER\CHSSC\CHAPTER.DOC

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


33
Technologies Ltd Version No: 2.0
MS DOS – Data access

Basic allocation units of each drive- CLUSTERS

chkdsk is used to find the cluster size in a system

Each drive has a file-allocation table (FAT)

FAT is a roadmap that DOS follows to locate the clusters belonging to a


particular file.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


34
Technologies Ltd Version No: 2.0
Structure of a Hard disk

SECTOR
TRACK

CYLINDER

PLATTER

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


35
Technologies Ltd Version No: 2.0
MS DOS – Data access

The entry in the FAT corresponding to each cluster contains a value that
indicates:
which cluster is unused
which cluster is reserved
which cluster considered as a bad cluster
the number of next cluster in the file
the last cluster of the file

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


36
Technologies Ltd Version No: 2.0
How to access the contents of a file?
FAT
0 FFFD

1 FFFF

First Cluster of File A 2 0003

End of File B is cluster 6


3 0004

4 0007

First Cluster of File B 5 0006


End of File A is cluster 7
6 FFFF

7 FFFF
Cluster 8 is free
8 0000

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


37
Technologies Ltd Version No: 2.0
Volume structure in MS-DOS

Boot-sector : Contains a bootstrap loader and disk characteristics

FAT : Main file allocation table

Additional FAT : used for recovery during the failure of main FAT

Root directory : It is in a fixed position of fixed size

File space : Rest of disk space which is available for files and sub-directories.

Additional
Boot Sector FAT Root Directory File Space
FATs

Volume Structure of a Disk

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


38
Technologies Ltd Version No: 2.0
File permissions in MS-DOS

read-only : a file cannot be written or deleted

hidden : such files ignored by many commands

system : such files are system files ( OS related files)

archive : used for back-up

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


39
Technologies Ltd Version No: 2.0
UNIX File system

UNIX has multiple file systems

A file system

– is a formatted partition of the disk

– Is a group of files having relevant information

There is always one compulsory file system known as the root.

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


40
Technologies Ltd Version No: 2.0
Volume structure in UNIX

Boot block : occupies the beginning of the root file system

Super block : Has the state of the file-its size,where to find the free space on
the file system,how many files it can store etc.

Inode list : It follows the super block-Give the internal representation of the file

Data Block : Contains data.( Size of the blocks can vary from 512 bytes to 4K)

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


41
Technologies Ltd Version No: 2.0
Volume structure of UNIX

Boot Block Super Block Inode Block Data Block File System 1

Boot Block Super Block Inode Block Data Block File System 2

Boot Block Super Block Inode Block Data Block File System 3

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


42
Technologies Ltd Version No: 2.0
Inode pointer structure Data Block

Direct 0

Direct 1 Data Block

.
.
. Data Block

Direct 9

Data Block
Single Index Block
Indirect

Double
Indirect
Data Block
Triple Index Block Index Block
Indirect
Array of 13
pointers
Data Block

Index Block Index Block Index Block

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


43
Technologies Ltd Version No: 2.0
Types of users in UNIX
OWNER : the owner of the file

GROUP : all members in the group

OTHERS : all other users in the environment


Owner(u) Group(g) Others(o)
Categories of file permissions
r w x r w x r w x
– Read only
a) Owner, group and others all have read, write and execute permissions
– Write only
Owner(u) Group(g) Others(o)
– Execute only
r w x r - - r - -
b) Owner has read, write and execute permissions, while Group and
others have only read permission

Owner(u) Group(g) Others(o)

r w x r w - - - -
c) Owner has read, write and execute permissions, while Group has read
and write and others don't have any permission

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


44
Technologies Ltd Version No: 2.0
NTFS.
NTFS stands for New Technology File System.

It was introduced with Windows NT

Can support up to 2 TB in size.

no limitation on file sizes.

Allows encryption of files, which FAT does not allow.

NTFS is more reliable.

Security and access control

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


45
Technologies Ltd Version No: 2.0
NTFS

MFT USER FILE SPACE USER FILE SPACE

Copy of first 16
MFT records

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


46
Technologies Ltd Version No: 2.0
Comparison of Different File Systems

Features FAT NTFS UNIX file System

Operating Systems DOS and all Windows NT, UNIX and Unix
versions of Windows based OS like
Windows 2000, Linux, etc.
Windows XP

Volume size Limited Virtually unlimited Virtually unlimited

Max file size Limited Limited by the Limited by the


volume of the volume of the
disk disk

Number of files Limited Large Large

Built-in security No Yes Yes

Encryption NO Supported in the Inherent


recent
versions like
NTFS5.

Fault tolerance Low High High

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


47
Technologies Ltd Version No: 2.0
Thank You!

Copyright © 2004, Infosys ER/CORP/CRS/OS09/003


48
Technologies Ltd Version No: 2.0

Вам также может понравиться