Unit 1 Operating System 1
Unit 1 Operating System 1
Unit – 1
Introduction of
Operating System
1
Reference Books
2
Topics to be covered
▪ Computer system overview and architecture
▪ Definition Operating System (OS)
▪ Objectives / Goals of Operating System (OS)
▪ Operating Systems (OS) services
▪ Generations of Operating Systems (OS)
▪ System calls
▪ Views of Operating Systems
▪ Types of Operating Systems (OS)
▪ Multiprogramming v/s Multiprocessing v/s Multitasking
▪ Structures of OS
3
Basic elements of computer
4
Computer system architecture
5
What is Operating System (OS)?
An Operating System is a program that acts as an
intermediate/interface between a user of a computer and the
computer hardware.
6
Definition
7
Where does the OS fit in?
8
Modes of operation of computer
1. Kernel Mode
• has complete access to all the
hardware
• here OS have complete access to
all the hardware and can
execute any instruction on that a
machine is capable of executing.
• has high privileged (rights)
2. User Mode
• can execute only subset (few) of
the machine instructions
• has less privileged (rights)
9
Flow of Communication
10
Functions/Services/Tasks of OS
Functions
11
Functions/Services/Tasks of OS
• By process management OS
manages many kinds of
activities:
1. Process • All process from start to
shut down i.e. open, save,
Management copy, install, print.
• Creation and deletion of
user and system processes.
12
Functions/Services/Tasks of OS
13
Functions/Services/Tasks of OS
14
Functions/Services/Tasks of OS
• By security management
OS manages many tasks
such as:-
4. Security • Alert messages
• Virus protection
Management • Dialogue boxes
• Firewall
• Passwords
15
Functions/Services/Tasks of OS
• To manage Resources, OS
perform many tasks such as:
• Install drivers required for
5.Resource input and output,
Management memory, power.
• Coordination among
peripherals.
16
Functions/Services/Tasks of OS
17
Different views of OS
Views of OS
OS as a User/Computer OS as a Resource
Interface manager
18
Different views of OS
▪ OS as a User/Computer Interface:
End
User
Programmer
Application
Programs
Utilities Operating-
System
Designer
Operating-System
Computer Hardware
19
Different views of OS
20
Different views of OS
21
Different views of OS
22
Different views of OS
23
Different views of OS
24
OS as a Resource Manager
OS as a Resource manager
(OS from system view)
25
Goals/objective of OS
Control/execute user/application programs.
26
Generations of Operating systems
First Generation
Second Generation
Third Generation
Fourth Generation
27
History of OS (First generation)
▪ First generation (1945-1955)
• Vacuum tubes and plug-boards are used in these systems.
Vacuum tubes
Plug board
28
First generation
29
First Generation Computers
30
coding by cable connections (plug board)
31
Punch Card
32
First Generation
Working
Problem
33
First Generation
Features of First Generation Computers
• They used vacuum tubes as main electronic component.
• They were large in size, slow in processing and had small
storage capacity.
• They consumed lots of electricity and produced excessive
heat.
• They were less reliable than later
generation computers
• They used machine level language for programming
34
History of OS (Second generation)
▪ Second generation (1955-1965)
• Transistors are used in these systems
• The machine that are produced are called mainframes.
• Batch systems was used for processing.
Programmers 1b4ri0n1grceaarddss
btoat1Oc4hp0eo1rfajtoobrscoanrrtioest7a0inp9pe4udtOotaeppseercaottomor7p0cua9tr4
inriges outp1u4t0t1apperintots1o4u0t1put 35
Second Generation
• Technology: Transistors
• Operating system : Present
• Language : Assembly and High level
language
36
Second Generation
37
Second Generation
Batch system
38
Batch system:
Working
• Collect a tray full of jobs and read them onto magnetic tape
using small computer such as IBM 1401.
• Then magnetic tapes are mounted on a tape drive., operator
load special program which read the first job from tape and
run it.
• Output was written onto second tape, after each job
finished, the OS automatically read next job from the tape.
• Output tape inserted into IBM 1401 for printing.
39
Second Generation
Features of Second Generation Computers
40
History of OS (Third generation)
▪ Third generation (1965-1980)
• Integrated circuits (IC's) are used in place of transistors in these computers.
• It provides multiprogramming (the ability to have several programs
in memory at once, each in its own memory partition).
41
Third Generation
Third Generation(1965-80)
44
42
Third Generation
43
Third Generation
Job 3
Job 2
Multiprogramming
Memory
Job 1 • Partition the memory into several pieces with
partitions
different job in each partition.
Operating • While one job was waiting for I/O to
system complete, another job could use CPU.
• whenever running job finished, the OS load
new job from the disk into the empty partition
of memory. This is know as SPOOLING
(Simultaneous Peripheral Operation On
Line).
44
History of OS (Fourth generation)
▪ Fourth generation (1980-present)
• Personal Computers
• LSI (Large Scale Integration) circuits, chips containing thousands of
transistors are used in these systems.
45
Fourth Generation
Fourth Generation(1980-90)
• Technology : LSI
• Operating systems : Present
• Language : High level language
48
46
Fourth Generation
Fourth generation:
Third generation:
• 1980 – present
• 1965 – 1980 • Large scale integration,
Second generation•:Multiprogramming
Integrated circuits, Personal computers
• 1955 – 1965
• Transistors, Batch
First generation:systems
• 1945 – 1955
• Vacuum tubes, Plug
boards
48
Types of Operating Systems
Batch OS
Multi-programming OS
Types
Multi-Tasking OS
Multi-processing OS
Distributed OS
Real Time OS
49
Multiprogramming v/s Multiprocessing v/s Multitasking
Multiprocessing Multitasking
Multiprogramming
50
Multiprogramming v/s Multiprocessing v/s Multitasking
51
Real Time OS
▪A system is said to be Real Time
if it is required to complete it’s work &
deliver it’s services on time.
▪ A real time OS defines the completion of job within the
rigid time constraints otherwise job looses its meaning.
▪ Example – Flight Control System, Air
line reservation system.
• All tasks in that system must execute on time.
▪ The Real Time OS is of two types:
1. Hard Real Time OS
2. Soft Real Time OS
52
Real Time OS
▪ Hard Real time
• It ensures the complication of critical tasks within the well defined
constraints.
• It can not afford missing even a single deadline, single miss can lead
to the critical failure.
• Example: Flight controller system.
53
Distributed Operating System
▪ “A Distributed system is collection of independent
computers which are connected through network.”
Systems processors
are differ in size and
functions
Communication
Network
54
Examples of Distributed OS
▪ Web Search Engines:
• Major growth industry in the last decade.
• 10 billion per month for global number of searches.
• e.g. Google distributed infrastructure
55
Distributed OS
Feature Description
56
User Mode vs. Kernel Mode
57
System Call
A system call is a request that a program makes to the OS.
58
System Call
Read system call
59
Read System Call
Return to caller Library
Trap to the kernel procedure
5 Put code for read in register read
6 10
User Call to library proc
4
space Increment SP 11
▪ Step-4 Then comes the actual call to the library procedure. This
instruction is the normal procedure call instruction.
61
Read System Call
▪ Step-6. Then it executes a TRAP instruction to switch from user
mode to kernel mode and start execution at a fixed address within
the kernel.
▪ Step-7.The kernel code that starts examines the
system call number and then dispatches to the correct system
call .
▪ Step-8. At that point the system call handler runs.
▪ Step-9.Once the system call handler has
completed its work, control may be returned to the user-
space library procedure .
▪ Step-10. This procedure then returns to the user program in the
usual way procedure calls return.
▪ Step-11. To finish the job, the user program has to clean up the
stack, as it does after any procedure call. 62
System Call
System Call
63
System Calls for Process Management
• pid = fork()
• pid = waitpid(pid, &statloc, options)
• s = execve(name, argv, environp)
• exit(status)
64
System Calls for Process Management
pid = fork()
• Fork is the only way to create new process in POSIX.
• Creates an exact duplicate of the original process.
• It will return PID which is id of child.
s = close(fd)
• Close an open file.
n = read(fd, buffer, nbytes)
• Read data from a file into a buffer.
66
System Calls for File Management
position = lseek(fd, offset, whence)
s = mkdir(name, mode)
• Create a new empty directory.
s = rmdir(name)
68
System Calls for Directory Management
s = unlink(name)
s = chmod(name, mode)
70
Miscellaneous System Calls
s = kill(pid, signal)
71
System Calls: Interrupts
An interrupt is a signal to the processor emitted by hardware
or software indicating an event that needs immediate
attention.
The processor responds by suspending its current
activities, saving its state, and executing a function
needed by interrupt.
72
Interrupts
74
Simple Structure
▪ MS-DOS is an operating system created for personal computers. It
was developed by Microsoft. It is a classic example of an operating
system with a layered structure.
▪ MS-DOS operating system is split into various layers and
each of the layers have different functionalities.
▪ Layering provides a distinct advantage in the MS-DOS operating
system because all the layers can be defined separately and
interact with each other as required.
▪ Also, it is easier to create, maintain and update the system if it is
done in the form of layers. Change in one layer specification does
not affect the rest of the layers.
▪ However, the layers in MS-DOS are not that sharply
defined and the layer specifications often bleed into each other.
75
SIMPLE STRUCTURE
76
Monolithic Structure
▪ Monolithic systems – basic structure:
🞆the entire operating system is working in kernel space.
🞆A set of primitives or system calls implement all operating system
services such as process management, concurrency, and memory
management.
🞆Device drivers can be added to the kernel as modules.
🞆user services and kernel services are implemented under same
address space. As both services are implemented under same
address space, this makes operating system execution faster.
🞆If any service fails the entire system crashes, and it is one of the
drawbacks of this kernel. The entire operating system needs
modification if user adds a new service.
🞆Acts as a virtual machine which controls all hardware parts
🞆Examples: Linux, Unix like kernels, BSD, OS/360
77
MONOLITHIC STRUCTURE
c
78
Layered Structure
🞆 A layered system consists of a series of layers, each of which depends
only on the correct operation of the layer immediately beneath it.
🞆 The lowest layer represents the hardware interface, and the highest
layer the application interface.
🞆 All the layers can be defined separately and interact with each other as
required. Also, it is easier to create, maintain and update the system if it
is done in the form of layers.
🞆 Change in one layer specification does not affect the rest of the layers.
🞆 A key problem in a layered system is deciding on the ordering of the
layers. (This is critical because of the requirement that each layer can
ultimately only use services provided by layers below it - so the ordering
cannot have any cycles.)
🞆 In a strictly-layered structure, efficiency can also become a problem
because when a higher-level layer requires a lower-level operation the
request must work its way down layer by layer.
🞆 Examples OS/2, window NT
79
LAYERED STRUCTURE
80
Microkernel Structure
🞆 Kernel is made as small as possible only the most important services are put
inside the kernel and rest of the OS service are present in the system application
program.
🞆 The user can easily interact with those not-so important services within the
system applications kernel is solely responsible for the three most important
services of operating system namely:
⚫ Inter-Process communication
⚫ Memory management
⚫ CPU scheduling
🞆 Microkernel and system applications can interact with each other by message
passing as and when required.
🞆 This is extremely advantageous architecture since burden of kernel is reduced
and less crucial services are accessible to the user and hence security is
improved too. It is being highly adopted in the present-daysystems.
81
MICROKERNEL STRUCTURE
82
MICROKERNEL STRUCTURE
83
Modular Structure
▪ A modular operating system is built with its various functions
broken up into distinct processes, each with its own interface.
▪ The primary benefit of the modular approach is that each process
operates independently, and if one of them fails or needs an
update, it won’t affect any of the other functions.
▪ The main elements of a modular operating system are a kernel
and a set of dynamically loadable applications with their own
discrete memory spaces. The kernel is protected from service and
application failures.
▪ The Linux kernel is modular, which means it can extend its
capabilities through dynamically-loaded kernel modules.
84
MODULAR STRUCTURE
85
Questions asked in Exams
1. What is Operating System? Discuss role/functions of OS as a resource
manager.
2. Write different operating system services and describe it with suitable
example.
3. Enlist various generations of operating system and explain them with
advantages and disadvantages in detail.
4. Describe RTOS its types and DOS with suitable examples.
5. Identify the differences between Multi-Programming, Multi-tasking, and
Multiprocessing System.
6. What are System Calls? Explain various types of system calls with
appropriate examples.
7. What is an interrupt and context switching? How it is handle by
operating system.
8. Explain Monolithic, Micro Kernel and Layered system of Operating
System Structure.
86
87