Sunteți pe pagina 1din 89

OPERATING SYSTEMS

UNIT -1
Syllabus
 OS Introduction.

 Process & Process Management.

 Interprocess Communication and


Synchronization, Deadlocks.

 Memory Management.

 I/O and File Management.


Subject Structure
 Continuous Assessment= 40 marks
 ESE =60 marks Total 100
marks Theory
 Credits =4
125
Marks

 OS Lab=25 marks Total 25


 Credits =1 marks Practical
CA and TW Components

OS CA Components
Class Test 1 Class Test 2 Experiential Learning Assignment
10 10 15 5
Saturday, February 1, 2020 Saturday, April 4, 2020 Jan-April 2020 Saturday, March 7, 2020

OS Lab CA Components

Journal and Contineous performance Lab Quiz Implementation


5 12 8
Reference Books
 Operating Systems Concepts by Silberschatz, P Galvin, G Gagne

 Modern Operating System by Andrew S. Tanenbaum

 Operating Systems: Internals and Design Principles by William Stallings

 Operating Systems Concepts” by Sibsankar Haldar and Alex Alagaramy

 Operating System by D.M Dhamdhere

 Unix and shell programming by B.M Harwani

 Y Kanetkar,” Unix Shell Programming”, 1st Edition, 2008 by BPB Publications, ISBN:
978-81-7029-753-2.
Phases of Computing
Some key points…..

 A computer is a device that runs programs.


 A program is a set of instructions that is prepared to do a
specific job . Different programs are written to do different
things for us.
 This makes computer able to do different things for us.
 A program is normally stored on a disk. This may be a Compact
Disc, diskette etc.. But they have to be in Main Memory in order
to run. This main memory is usually known as RAM.

Program Running
Process
What is OS cont..
 Operating System is a software, which makes a
computer to actually work.

 An OS is a program which acts as an interface


between computer system users and the computer
hardware.

 It is the software the enables all the programs we


use.

 The OS organizes and controls the hardware.

 Examples: Windows, Linux, Unix and Mac OS, etc.


View of OS
What OS does?

An operating system performs basic tasks such


as,

 controlling and allocating memory.


 prioritizing system requests.
 controlling input and output devices.
 facilitating networking.
 managing file systems.
Different
Multi
types of OS Single
user,
multi
user,
task
multi
task
Booting, a process to start
OS
 Booting is the initial set of operations that a
computer system performs after electrical power to
the CPU is switched on or when the computer is
reset.

 It is a process or set of operations that loads and


hence starts the operating system, starting from the
point when user switches on the power button.
Booting process steps
1. The power button activates the power supply in the PC, sending power to the
motherboard and other components. Then PC performs a power-on self-test
(POST) which indicates if their is a h/w failure.

2. The PC displays information on the attached monitor showing details about the
boot process.

3. The BIOS attempts to access the first sector of the hard drive known as the boot
disk. The boot disk is typically the same hard disk that contains your operating
system.

4. The BIOS confirms there's a bootstrap loader, or boot loader, in that first sector
of the boot disk, and it loads that boot loader into memory (RAM). The boot
loader is a small program designed to find and launch the PC's operating system.

5. Once the boot loader is in memory, the BIOS hands over its work to the boot
loader, which in turn begins loading the operating system into memory. When
the boot loader finishes its task, it turns control of the PC over to the operating
Bootstrap Process
OS Services
 An Operating System provides services to both
the users and to the programs.
 It provides programs, an environment to execute.
 It provides users, services to execute the
programs in a convenient manner.

 Following are few common services provided by


operating systems.
 Program execution
 I/O operations
 File System manipulation
 Communication
 Error Detection
 Resource Allocation
 Protection
Batch Processing
 In Batch processing same type of jobs batch
together and execute at a time.

 The OS was simple, its major task was to transfer


control from one job to the next.

 OS keeps a number a jobs in memory and


executes them without any manual information.
Jobs are processed in the order of submission i.e.
first come first served fashion.

 When job completes its execution, its memory is


released and the output for the job gets copied into
an output spool for later printing or processing.
Advantages
1.Batch processing takes much of the work of the
operator to the computer.
2.Increased performance as a new job get started
as soon as the previous job finished without any
manual intervention.
Disadvantages
1.Difficult to debug program.
2.A job could enter an infinite loop. Due to lack of
protection scheme, one batch job can affect
Multitasking/TimeSharing
 Multitasking refers to term where multiple jobs are executed
by the CPU simultaneously by switching between them.
Switches occur so frequently that the users may interact with
each program while it is running.

 The user gives instructions to the operating system or to a


program directly, and receives an immediate response.

 These Operating Systems were developed to provide


interactive use of a computer system at a reasonable cost.

 A time-shared operating system uses concept of CPU


scheduling and multiprogramming to provide each user with a
small portion of a time-shared CPU.

 Each user has at least one separate program in memory.


 Example: Multics, Unix
 A program that is loaded into memory and is executing is commonly
referred to as a process.

 When a process executes, it typically executes for only a very short


time before it either finishes or needs to perform I/O.

 Since interactive I/O typically runs at people speeds, it may take a


long time to completed. During this time a CPU can be utilized by
another process.

 Operating system allows the users to share the computer


simultaneously. Since each action or command in a time-shared
system tends to be short, only a little CPU time is needed for each
user.
Multiprogramming/Multip
rocessing
 Multiprogramming is a technique to execute number
of programs simultaneously by a single processor.
 In Multiprogramming, number of processes reside in
main memory at a time.

 The OS picks and begins to executes one of the jobs in


the main memory.

 If any I/O wait happened in a process, then CPU


switches from that job to another job.

 Hence CPU in not idle at any time.


Advantages
1.High and efficient CPU utilization.
2.User feels that many programs are allotted CPU almost
simultaneously.
Disadvantages
1.CPU scheduling is required.
2.To accommodate many jobs in memory, memory
management is required.
Real Time Operating
System
Real time systems represents are usually
dedicated, embedded systems.

In such systems, Operating Systems typically


read from and react to sensor data.

The Operating system must guarantee


response to events within fixed periods of time
to ensure correct performance.
Distributed OS
 Distributed environment refers to multiple
independent CPUs or processors in a computer
system. Operating system does the following activities
related to distributed environment.

 OS Distributes computation logics among several


physical processors.

 The processors do not share memory or a clock.

 Instead, each processor has its own local memory.

 OS manages the communications between the


processors. They communicate with each other
through various communication lines.
Components/Logical
View of OS
Unix Operating System

 Unix development started from mid 1960’s to finally in 1969 by a


group of AT&T employees at Bell Labs.

 The UNIX operating system is capable of handling activities from


multiple users at the same time. The UNIX operating system is a
set of programs that act as a link between the computer and the
user.

 There are various Unix variants available in the market. Solaris


Unix, AIX, HP Unix and BSD are few examples. Linux is also a
flavour of Unix which is freely available.

 Several people can use a UNIX computer at the same time; hence
UNIX is called a multiuser system.

 A user can also run multiple programs at the same time; hence
UNIX is called multitasking.
Unix Structure
Four Basics of UNIX
 Kernel: The kernel is the heart of the operating system. It interacts
with hardware and most of the tasks like memory management,
task scheduling and file management.

 Shell: The shell is the utility that processes your requests. When
you type in a command at your terminal, the shell interprets the
command and calls the program that you want. The shell uses
standard syntax for all commands. C Shell, Bourne Shell and Korn
Shell are most famous shells which are available with most of the
Unix variants.

 Commands and Utilities: There are various command and utilities


which you would use in your day to day activities. cp, mv, cat and
grep etc. are few examples of commands and utilities. There are
over 250 standard commands plus numerous others provided
through 3rd party software. All the commands come along with
various optional options.

 Files and Directories: All data in UNIX is organized into files. All
files are organized into directories. These directories are organized
into a tree-like structure called the file system.
Unix Architecture
The File Subsystem
 The characteristics of unix file system are:
 A hierarchal structure.
 Consistent treatment of data.
 Ability to create and delete files.
 Dynamic growth of files.
 Peripheral devices are also treated as files.

 The file system is organized as a tree. The root


node is called “root” and is denoted by “/”. Every
non leaf node in this structure is a directory and
every leaf node is a ordinary file/special device file.

 The name of the file is given by the path name.


 The internal representation of the file is in the form of iNode. This
inode contains the information about the file such as its layout on
the disk, its owner, its access permissions and last accessed time.

 This inode is short form for index node. Every file has one inode. 
The inodes of all the files on the system are stored in inode table.
When we create a new file a new entry in the inode table is created.

 The kernel contain two data structures: file table and user file
descriptor table. The file table is global table at the kernel level
but the user file descriptor table is for every process. When a
process creates a file or opens a file the entry for that is made in
both the tables.

 The information about the current state of the file is maintained in


the file table. For example if the file is being written the information
about the current cursor position is kept in the file table. This file
table also checks whether the accessing process has access to that
file or not.

 The user file descriptor table keeps a track of all the files opened by
File System Layout
Process Subsystem
 KERNEL process is created as part of the booting .

 KERNEL first loads the init process •

 All other processes are created by init •

 Each process is given an unique process id (PID) –PID of init is 1


–PID
 of kernel is 0 (zero) .

 Each process is associated with its creator (parent) –identified


by the Parent Process ID (PPID) •init process is mother of all
processes
 When parent process of any process dies, it will be
linked to init process as its parent •

 Each process runs with a specific priority (PRI).

 New processes are created using either fork or exec


command •

 fork creates an independent process –Except kernel


everything else is created using fork •

 Exec creates a new process as a sub-process (thread)


of the calling program –It shares the memory and other
resources of the parent process
Process States
Buffer Cache
 When a process wants to access data from
a file, the kernel brings the data into main
memory, alters it and then request to save
in the file system

 Example: copy cp one.c two.c

 To increase the response time and


throughput, the kernel minimizes the
frequency of disk access by keeping a pool
of internal data buffer called buffer cache.
Buffer Cache
 Buffer cache contains the data in
recently used disk blocks
 When reading data from disk, the kernel
attempts to read from buffer cache.
 If data is already in the buffer cache, the
kernel does not need to read from disk
 If data is not in the buffer cache, the
kernel reads the data from disk and
cache it
Buffer Cache
 During system initialization, the kernel
allocates space for a number of buffers,
configurable according to memory size and
system performance constraints.
 A buffer consists of 2 parts:
1. A memory array that contains data from the
disk.
2. A buffer header that identifies the buffer.
 There is a one to one mapping of buffer
headers to data array.
Buffer Headers
51

 A buffer consists of two parts


 a memory array
 buffer header
 disk block : buffer = 1 : 1
device num
block ptr to data area
num
status
ptr to previous buf on hash queue
ptr to next buf on hash queue

ptr to previous buf on free list


ptr to next buf on free list

Figure 3.1 Buffer Header


Buffer Headers
52

 device num
 logical file system number
 block num
 block number of the data on disk
 status
 The buffer is currently locked.
 The buffer contains valid data.
 delayed-write
 The kernel is currently reading or writing the contents of the
disk.
 A process is currently waiting for the buffer to become free.
 kernel identifies the buffer content by examing
device num and block num.
An operating system is a software that :
acts as an interface between the user and the
computer hardware and controls the execution of all
kinds of programs.
performs all the basic tasks like file management,
memory management, process management,
handling input and output, and controlling
peripheral devices such as disk drives and printers.
Some popular Operating Systems are Linux,
Windows, OS X, VMS, OS/400, AIX, z/OS, etc.
1) Monolithic Operating System
2) Layered Operating System
3) Microkernel Operating system
4) Networked and Distributed Operating System
A monolithic os is an operating system
architecture where the entire operating system is
working in kernel space and is alone in supervisor
mode.
Every component of the operating system is
contained in the kernel and can directly
communicate with any other (i.e., simply by using
function calls). The kernel typically executes with
unrestricted access to the computer system.
Ex:- OS/360,VMS and LINUX.
As operating systems became larger and more
complex, purely monolithic designs became unwieldy.
The layered approach to operating systems attempts
to address this issue by grouping components that
perform similar functions into layers.
Each layer communicates exclusively with those
immediately above and below it.
Lowerlevel layers provide services to higher-level ones
using an interface that hides their implementation.
EX :- The THE operating system is an early example of
a layered operating system .Windows XP and Linux,
implement some level of layering.
In microkernel designs, most operating system
components—such as process management,
networking, file system interaction and device
management—execute outside the kernel with a lower
privilege level.
Microkernels exhibit a high degree of modularity,
making them extensible, portable and scalable.
Further, because the microkernel does not rely on
each component to execute, one or more components
can fail, without causing the operating system to fail.

EX :- Linux and Windows XP contain modular


components.
A network operating system enables its processes to
access resources (e.g., files) that reside on other
independent computers on a network.
The structure of many networked and distributed operating
systems is often based on the client/server model.
The client computers in such a network request
resources—such as files and processor time—via the
appropriate network protocol. The servers respond with
the appropriate resources.
A distributed operating system is a single operating

system that
EX :-MIT's manages
Chord resources
operating on and
system more than
the one computer
Amoeba
system.
operating system from the Vrije Universiteit (VU) in
Amsterdam.
Two Types of Lists that
are used in Buffer Cache
An operating system is a software that :
acts as an interface between the user and the
computer hardware and controls the execution of all
kinds of programs.
performs all the basic tasks like file management,
memory management, process management,
handling input and output, and controlling
peripheral devices such as disk drives and printers.
Some popular Operating Systems are Linux,
Windows, OS X, VMS, OS/400, AIX, z/OS, etc.
1) Monolithic Operating System
2) Layered Operating System
3) Microkernel Operating system
4) Networked and Distributed Operating System
A monolithic os is an operating system
architecture where the entire operating system is
working in kernel space and is alone in supervisor
mode.
Every component of the operating system is
contained in the kernel and can directly
communicate with any other (i.e., simply by using
function calls). The kernel typically executes with
unrestricted access to the computer system.
Ex:- OS/360,VMS and LINUX.
As operating systems became larger and more
complex, purely monolithic designs became unwieldy.
The layered approach to operating systems attempts
to address this issue by grouping components that
perform similar functions into layers.
Each layer communicates exclusively with those
immediately above and below it.
Lowerlevel layers provide services to higher-level ones
using an interface that hides their implementation.
EX :- The THE operating system is an early example of
a layered operating system .Windows XP and Linux,
implement some level of layering.
In microkernel designs, most operating system
components—such as process management,
networking, file system interaction and device
management—execute outside the kernel with a lower
privilege level.
Microkernels exhibit a high degree of modularity,
making them extensible, portable and scalable.
Further, because the microkernel does not rely on
each component to execute, one or more components
can fail, without causing the operating system to fail.

EX :- Linux and Windows XP contain modular


components.
A network operating system enables its processes to
access resources (e.g., files) that reside on other
independent computers on a network.
The structure of many networked and distributed operating
systems is often based on the client/server model.
The client computers in such a network request
resources—such as files and processor time—via the
appropriate network protocol. The servers respond with
the appropriate resources.
A distributed operating system is a single operating

system that
EX :-MIT's manages
Chord resources
operating on and
system more than
the one computer
Amoeba
system.
operating system from the Vrije Universiteit (VU) in
Amsterdam.
Two Types of Lists that
are used in Buffer Cache
Structure of Hash Queue
 When the kernel accesses a disk block, separate
queue (doublely linked circular list) is formed
and it is hashed as a function of the device and
block num Every disk block exists on one and
only on hash queue and only once on the queue.
Structure of the Free List
78
 Buffer pool according to LRU
 The kernel maintains a free list of buffer
 doubly linked list
 take a buffer from the head of the free list.
 When returning a buffer, attaches the buffer to the tail.
Structure of the buffer pool
Initially all the disk blocks would be in free list

Then process wanted to access the


data stored in block no. 30. So now 30 is
removed from the free list.
Now p1 wants to access data stored in
secondary disk which is not present
in the buffer

So now block no.25 will get


copied to the first buffer of free
list and
then given to P1
Advantages of Buffer Cache
1. The use of buffers allows uniform disk access, Uniform disk access =>
system design simpler.

2. Copying data from user buffers to system buffers => eliminates the
need for special alignment of user buffers.

3. The buffer algo. help insure file system integrity, because they
maintain a common, single image of disk blocks contained in the
cache. Single image of of disk blocks contained in the cache => helps
insure file system integrity.

4. Use of the buffer cache can reduce the amount of disk traffic, thereby
increasing overall system throughput and decreasing response time.
System Calls
 The way that programs talk to the operating system
is via ``system calls.''  It is a request to the
operating system to perform some activity. System
calls allow user-level processes to request some
services from the operating system which process
itself is not allowed to do.
System Call
When a program in user mode requires access to RAM or a
hardware resource, it must ask the kernel to provide access
to that resource. This is done via something called
a system call.
When a program makes a system call, the mode is switched
from user mode to kernel mode. This is called a context
switch.
Types of System Calls
Thank you!!!!

Happy Studying!!!

S-ar putea să vă placă și