Cs30101:: Operating Systems
Cs30101:: Operating Systems
Cs30101:: Operating Systems
Credits: 03
Teaching Scheme: - Theory 3 Hrs/Week
Prerequisites: Data Structures and Algorithms, Computer
Organization.
Objectives:
• Identify the role of operating systems and explain the
different structures operating systems.
• Describe OS support for processes/threads, and virtual
memory, I/O and file systems.
• Evaluate processes and/or threads synchronization
mechanisms and explain deadlock conditions and ways to
resolve them.
• Identify the different design and implementation
concepts for Unix/Linux
• Use Inter-Process Communication techniques under
Unix/Linux.
• Mapping with PEOs: II, III, (d).
1
Syllabus
Unit I
Introduction to OS (8+1 Hrs)
2
Unit II
Process Management (8+1 Hrs)
3
Unit III
Scheduling and Deadlock (8+1 Hrs)
4
Unit IV
Memory Management (8+1 Hrs)
5
Unit V
I/O and File Management
(8+1 Hrs)
A. I/O management: I/O Devices, OS design issues for I/O
management, I/O Buffering.
Disk Scheduling: FCFS, SCAN, C-SCAN, SSTF.
File Management: Concepts, File Organization, File
Directories, File Sharing. Record Blocking, Secondary Storage
Management, Free Space management, Security.
Case study: Process Management, Concurrency, Scheduling,
Memory Management, I/O Management, File Management in
LINUX
B: Organization of I/O functions,Disk caches
6
Books
Text Books
1. “Operating Systems”, Stalling William, Pearson
Education, ISBN: 0-13-031999- 6, 4th Edition.
2. “Operating System Concepts”, Silberschatz A., Galvin P.,
Gagne G., John Wiley and Sons, ISBN: 9971-51-388-9, 6th
Edition.
Reference Books
1. “Modern Operating Systems”, Tanenbaum Andrew S.,
Prentice Hall India, ISBN: 81-7808-447-3, 2nd Edition.
2. “Unix Concepts and Applications”, Das Sumitabha, Tata
McGraw Hill, ISBN: 0-07-053475-6, 3rd Edition.
7
Marking Scheme
Parameter Marks % of Marks
ESE 100 60
MSE 20 100
8
Scheme of Marking for continuous assessment
of Tutorial courses
Sr Parameter % of
No Marks
08/06/11 9
Scheme of Marking for continuous assessment of Lab
courses
Sr Parameter % of Marks
No
3 Practical Assignments 40
-Originality of assignment (Innovativeness)
(2 Marks)
-Understanding the theme and use of assignment
performed (2 Marks)
10
Unit I
11
Block Diagram of a Computer (Logical)
Vishal
12
Kaushal
Operating System (OS)
• What do you do with just computer hardware?
– If someone gives you a computer with no software
whatsoever, how do you get it to do anything?
– You write a program that runs on the hardware
13
Without an OS
• Each program runs directly on the hardware
• Each program must do everything
• Each program needs to know the details of the hardware and
how to use it
• If the hardware changes, the program must change as well
• The hardware supports only one program at a time - each
user must wait until the previous program is done to “share”
the hardware with other users.
• Writing programs is incredibly complex and expensive
• OS is like an extended machine to provide a better interface
for convenience.
14
Four Components of a Computer System:
15
Computer System Structure
Operating system
Controls and coordinates use of hardware among various
applications and users
Users
People, machines, other computers
16
Operating System (OS)
• Integrated set of programs that controls the resources of a
computer system
• Provides its users with an interface which is more convenient
to use than bare machine
• Directly sits on top of the hardware and controls it
• Manages computer hardware
• Provides a basis for application programs
• Acts as an intermediary between computer user and
computer hardware
17
Introduction
• “An operating system is similar to a government. Like a
government, it performs no useful function by itself. It simply
provides an environment within which other programs can do
useful work”
18
Views of an Operating System
• Resource Allocator
– Operating system manages or allocates resources
– What resources?
• CPU time, RAM Memory, disk & other I/O devices, interrupt
numbers (IRQ’s), files, network ports & sockets, and other
software resources
– Who uses the resources?
• Resource users: One or more user processes & threads
• Control Program
– Operation and control of hardware devices
– Implements security and protection
– Execution of user program to prevent errors and prevent improper
use of the computer
19
Goals of an OS
Execute user programs and make solving user
problems easier
Make the computer system convenient to use
Use the computer resources in an efficient
manner
Ability to evolve
Can you think of reasons which make evolution
necessary?
H/W changes, new services, fixes
Different design goals for different OS
Mainframes, PC, Handheld
Vishal
20
Kaushal
The Role of an OS
• A computer is a set of resources for the movement, storage, and
processing of data.
• The OS is responsible for managing these resources.
21
Operating System as Software
22
OS as Resource Manager
23
•This figure suggests the main resources that are managed by the OS.
• The OS decides when an I/O device can be used by a program in execution and
controls access to and use of files.
•The processor itself is a resource, and the OS must determine how much
processor time is to be devoted to the execution of a particular user program.
• In the case of a multiple-processor system, this decision must span all of the
processors.
24
How are Hardware resources shared?
• Memory and disk space
– programs use different regions Program A
– space multiplexed Program B
• Printers (and other peripherals)
– programs line up and wait
• CPU
– programs time share
– time is split into slices, with each Program B Program A
program getting several slices
– time multiplexed B A
A
B
C
25
Evolution of Operating Systems
Operating systems will evolve over time
26
Common Tasks by OS
Vishal
27
Kaushal
Basic function of OS:
• Process Management
• File Management
28
1. Process Management
A process is a program in execution. It is a unit of work within the
system. Program is a passive entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying
location of next instruction to execute
Process executes instructions sequentially, one at a time, until
completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating
system running concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes /
threads
29
Process Management Activities
The operating system is responsible for the following activities in connection
with process management:
30
2. Main Memory Management
Main memory -array of words/bytes
Keeping track of which parts of memory are currently being used and by
whom
Deciding which processes (or parts thereof) and data to move into and
out of memory
31
3. Secondary Storage Management
Main memory is small and volatile
Secondary storage is large and nonvolatile
32
4. I/O Subsystem management
spooling (the overlapping of output of one job with input of other jobs)
33
5. File Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer rate,
access method (sequential or random)
File-System management
Files usually organized into directories
34
FS Management Activities
Creating and deleting files
Creating and deleting directories
Supporting primitives for manipulating files and directories
Mapping files onto secondary storage
Backing up files on stable (non-volatile) storage media
Vishal
35
Kaushal
OS Services
37
Operating System Services (Cont)
File-system manipulation - The file system is of particular interest.
Obviously, programs need to read and write files and directories,
create and delete them, search them, list file Information,
permission management.
38
Operating System Services (Cont)
Error detection – OS needs to be constantly aware of possible
errors
May occur in the CPU and memory hardware(memory
error,power failure)
In I/O devices(connection failure in n/w)
In user program(access to illegal memory, arithmetic overflow)
For each type of error, OS should take the appropriate action
to ensure correct and consistent computing.
Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
39
Operating System Services (Cont)
Another set of OS functions exists for ensuring the efficient
operation of the system itself via resource sharing
Resource allocation - When multiple users or multiple
jobs running concurrently, resources must be allocated to
each of them
Many types of resources - Some (such as CPU cycles,
main memory, and file storage) may have special
allocation code, others (such as I/O devices) may have
general request and release code
Accounting - To keep track of which users use how much
and what kinds of computer resources
40
Operating System Services (Cont)
Protection and security - The owners of information
stored in a multiuser or networked computer system may
want to control use of that information, concurrent
processes should not interfere with each other
Protection involves ensuring that all access to system
resources is controlled
Security of the system from outsiders requires user
authentication(password) , defending external I/O
devices modem,NIC from invalid access attempts
41
User – OS Interface
• GUI
– Graphical User Interface
– Desktop, icons, mouse
• CLI
– Command Line Interface
– Allows direct command entry
– Sometimes implemented in kernel, sometimes by systems
program
– Command interpreter
– Windows: Command shell
– UNIX/LINUX: Terminal – bash, ksh, csh: shells
– Built-in commands vs external commands
Vishal
42
Kaushal
User Operating System Interface - GUI
User-friendly desktop metaphor interface
43
The Mac OS X GUI
44
User Operating System Interface - CLI
Command Line Interface (CLI) or command interpreter allows direct command
entry
45
Bourne Shell Command Interpreter
46
Protection and Control
• Ensuring proper operation of the operating system, and
programs
• Examples
(a) only certain users can access certain files;
(b) restricted access to operating system parts of RAM;
(c) restrictions about which instructions can be executed by
applications;
(d) restricted access to RAM of other processes
47
Protection
48
Protection modes
• User mode
– limited access to RAM memory; just the memory of a
single program running
– limited access to machine instructions; illegal to
execute I/O instructions, interrupt management
instructions and some others
• kernel mode
– access to all RAM memory
– access to all machine instructions
• User vs. kernel mode implemented as a bit in CPU
49
So , if we have these protection modes, how does a
process gain access to the OS?
50
System Calls
User programs are not allowed to access system resources
directly. They must ask the OS to do that for them.
51
Dual Mode Operation
Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux, and
Mac OS X), and Java API for the Java virtual machine (JVM)
53
Example of System Calls
System call sequence to copy the contents of one file to another file
Vishal
55
Kaushal
Advantages of using APIs
1. Portability: User programs that follow the API’s
definition are portable.
2. An API can provide a common interface for
different implementations of a service.
For example, the UNIX file system API is the same for all
kinds of devices.
3. Using an API allows upgrading system software
without changing user programs
4. APIs are faster than system call as there is no need
of mode switch.
56
System Call Implementation
Typically, a number associated with each system call
The system call interface invokes intended system call in OS kernel and
returns status of the system call and any return values
The caller need know nothing about how the system call is implemented
Just needs to obey API and understand what OS will do as a result call
57
API – System Call – OS Relationship
58
Steps in Making a System Call
60
System Call Parameter Passing
Often, more information is required than simply identity of desired system
call
Exact type and amount of information vary according to OS and call
Three general methods used to pass parameters to the OS
Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and address of block
passed as a parameter in a register
This approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system
Block and stack methods do not limit the number or length of parameters
being passed
61
Parameter Passing via Table
62
Types of System Calls
1. Process control
2. File management
3. Device management
4. Information maintenance
5. Communications
6. Protection
63
Examples of Windows and Unix System Calls
64
65
Differences between library functions and system
calls
66
Types of Operating System:
08/06/11 67
1.Batch OS
• First OS
• Developed around mid 1950s by GM
• IBSYS had become quite famous by early 1960s
• Special piece of software called monitor
• User submits the job on cards or tape to a computer
operator who batches the job together sequentially and
places the entire batch on an input device for use by the
monitor
• Monitor loads one job, executes it, then loads the next
and so on
Vishal
68
Kaushal
Batch Systems:
69
Batch OS
• Monitor controls sequence of events
– Must always be in memory and available for
execution
– Called resident monitor
– Rest of the monitor is utilities loaded as subroutines
when required
– Executes in kernel mode (contrast with user mode)
• Job is placed in user program area and control is passed
to it
• Upon completion, the job returns the control to the
monitor which proceeds with reading the next job
• Results of each job are sent to an output device
• JCL: Job Control Language – meta instructionsVishal
70
Kaushal
Batch Systems:
71
Batch Systems:
Computer runs it
Increases CPU utilization
Job pool-jobs waiting on disk for User gets results minutes
allocation into memory
(hours, days) later
Job scheduling-selection of job from
pool
73
CPU scheduling
Uniprogramming
74
Multiprogramming
• When one job needs to wait for I/O, the processor can switch to the
other job
75
Multiprogramming
78
4. Parallel System/Multiprocessor/Tightly coupled:
As like multiprocessor system have more than one processors in
close communication ,sharing the computer, bus clock & sometimes
memory & peripheral devices.
Referred to as tightly coupled system.
Advantage
1. Throughput: get more work done in less time, Increases throughput
2. Economical :It saves money because process can share peripherals,
mass storage and power supply.
3. Increases the reliability: Ability to continue providing service
proportional to the level of surviving hardware -graceful
degradation -> fault tolerant
79
4. Parallel System:
Symmetric multiprocessing (SMP)
Peer processors
Each processor runs an identical copy of the operating system.
Many processes can run at once without performance drop.
Most modern operating systems support SMP.
Ex: Solaries 5,Win2000
Asymmetric multiprocessing
Each processor is assigned a specific task; master processor
schedules and allocated work to slave processors.
More common in extremely large systems
Ex: Solaries 4,
80
SMP vs ASMP
Vishal
81
Kaushal
5. Distributed System
82
5. Distributed System
A collection of heterogeneous nodes connected by one or more
interconnection networks which provides access to system-wide shared
resources and services.
More than one physical computer, each consisting of CPUs, local memory,
and possibly stable storage, and I/O paths to connect it with the
environment.
83
CPU CPU CPU
5. Distributed System
Advantages of distributed systems. Memory Memory Memory
Resources Sharing
Computation speed up – load sharing
Reliability
Communications
Requires networking infrastructure.
Ex: Local area networks (LAN) or Wide area networks (WAN)
May be either client-server or peer-to-peer systems
85
6. Real-time OS.:
Real-Time systems may be either hard or soft real-time
Hard real-time:
Secondary storage limited or absent, data stored in short term
memory, or read-only memory (ROM)
Conflicts with time-sharing systems, not supported by general-
purpose operating systems.
Time constraints can be not be relaxed.
Soft real-time
Limited utility in industrial control of robotics
Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features.
Time constraints can be relaxed.
86
Classes of OS - Summary
Vishal
87
Kaushal
What have we seen so far?
• What is OS?
– Resource manager and control program
• Basic functions of OS
• OS Services
• OS-User Interface
• System calls
• Types of OS
Vishal
88
Kaushal
OS Structures
Monolithic
Layered
Ringed
Virtual Machines
Exo kernels
Client Server Systems and Microkernels
OS Structure
The OS (a simplified view)
Command Interpreter
Information Services
Protection System
I/O System
Hardware
92
OS Structure
• An OS consists of all of these components, plus lots of
others, plus system service routines, plus system programs
(privileged and non-privileged), plus ....
• The big issue:
• how do we organize all of this?
• what are the entities and where do they exist?
• how does these entities cooperate?
• Basically, how do we build a complex system that’s:
• performance
• reliable
• extensible
93
Monolithic system
• “The Big mess”
– Every component contained in kernel
• direct communication among all elements
• highly efficient
• Traditionally, systems such as Unix were built as a monolithic
kernel:
user programs
hardware
94
Monolithic system
• Monolithic Systems
– Entire OS runs as a single program in kernel mode
– Examples: UNIX, LINUX, DOS, Windows 9x
System
call/procedure
95
Monolithic system
• Problems with monolithic kernels:
• hard to understand
• hard to modify
• unreliable: a bug anywhere causes a system crash
• hard to maintain
• Since the beginnings of OS design, people have
wanted ways to organize the OS to simplify its
design and construction.
96
Layered system
• Layered Systems
– Generalization of previous approach
– OS constructed as hierarchy of layers
– The first description of this approach was Dijkstra’s THE system.
– Layers in THE system
97
Layered system
• Problems with Layering
• Systems must be hierarchical, but real systems are
more complex than that, e.g.,
• file system would like to be a process layered on VM
• VM would like to use files for its backing store I/O
• Approach is not flexible.
• Often has poor performance due to layer crossings.
• Systems are often modelled as layered structures
but not built that way (for better or worse).
99
Ringed Approach
Further generalization of layering concept
First example: MULTICS
Series of concentric rings with inner ones more privileged
than outer ones
Layering scheme of THE was only a design aid
Everything was ultimately linked into one single object at
runtime
Ring structure of MULTICS however was very much present
at run time and enforced by hardware
Virtual Machines
OS/360 -> batch system->time sharing
First example: VM/370
Virtual machine monitor runs on bare hardware and does
multi programming providing several virtual machines to next
layer up
These virtual machines are exact copies of bare hardware
Can run any OS .
Virtual Machines
CMS: Conversational Monitor System
Uses
Different Oss can now serve different specific purposes
Running old MS-DOS programs (16 bit) on 32 bit or 64 bit
Windows
Running Java Programs in JVM
103
Virtual Machines (Cont.)
104
Exo kernels
Machine is partitioned
machines
Exokernel runs in the bottom most layer allocating
resources to VMs
105
Exo Kernels
Client Server Model
Move OS code up into higher layers removing as much as
possible from kernel mode microkernel
User processes are now called client processes
They send requests to server processes (OS running in
user space) which in turn use the services of micro kernel
in kernel mode
OS broken up into several server processes like fileserver,
memory server etc. and a micro kernel
Pure microkernel design is commercially impractical
because it's too inefficient
Too much message passing
Client Server Model
Handles comm.
b/n client & server
Client Server Model
Each part of OS becomes small and manageable
Bug in file server will not bring the whole machine down
Advantage: Adaptability to use in distributed systems
user mode
communication
microkernel low-level processor kernel mode
VM protection
control
hardware
112
Microkernel
Windows 2000
115
History of Windows
• Windows
– From 85 to 95, just a graphical environment over MS-DOS
– 4000 lines of AL code, 8KB memory, 8086 microprocessor
– Windows 95, used MS-DOS only for booting and running legacy
MS-DOS programs
– Windows 98
• Windows 95 and 98 still contained large amount of 16-bit AL
• In parallel, MS developed Windows NT
– Full 32 bit system
– Didn’t succeed much
– Became accepted only with v 4.0
• Shell changed from Program Manager to Windows Explorer
Vishal
116
Kaushal
History of Windows
• v 5 of Win NT was renamed Win 2000 in early 1999
– Intended to be a successor of both Win NT 4.0 and Win 98
– Didn’t work as planned, came out with another version of Win 98
and named it Windows Me
• Better version of Win 2000 was released as Win XP
– Had a much longer run: 6 years from 2001
– Replaced all previous versions of Windows
– 64 bit versions started with Win XP onwards
Vishal
117
Kaushal
History of Windows
• Jan 2007: Windows Vista
– Intended as successor to Windows XP
– New graphical interface called Aero
– NT 6.0
• Windows 7: latter half of 2009
– NT 6.1
• Windows 8
– Touch screen friendly
– NT 6.2
Vishal
118
Kaushal
History of Windows
08/06/11 119
Windows 2000 or Win2K
Vishal
120
Kaushal
Design Goals
• Extensibility
– The code must be written to comfortably grow and change as
market requirements change.
• Portability
– The system must be able to run on multiple hardware architectures
and must be able to move with relative ease to new ones as market
demands dictate.
• Reliability and robustness
– The system should protect itself from both internal malfunction and
external tampering
– Applications should not be able to harm the operating system or
other applications.
Vishal
122
Kaushal
Design Goals
• Compatibility
– Although Windows NT should extend existing technology, its
user interface and APIs should be compatible with older
versions of Windows and with MS-DOS
– It should also interoperate well with other systems such as
UNIX, OS/2, and NetWare.
• Performance
– Within the constraints of the other design goals, the system
should be as fast and responsive as possible on each hardware
platform
Vishal
123
Kaushal
Windows 2000 Architecture
124
Windows 2000 Simplified
Architecture
Environment
System & Service Subsystems
Processes User Apps
OS/2 POSIX
Subsystem DLL
Win32
User
Kernel
Executive
Win32
Device
Kernel User/GDI
Drivers
Hardware Abstraction Layer (HAL)
125
Windows 2000 Architecture
126
User mode
Special system support processes:
- Include services not provided as part of the Windows
OS, such as logon process, session manager, service
manager, authentication subsystem
• Service processes
– These host Windows services, such as the Task Scheduler
and Spooler services
– Services generally have the requirement that they run
independently of user logons
– Many Windows server applications, such as Microsoft SQL
Server and Microsoft Exchange Server, also include
components that run as services
127
User Mode Processes
• User Applications
– Can be one of six types: Windows 32-bit, Windows 64-bit,
Windows 3.1 16-bit, MS-DOS 16-bit, POSIX 32-bit, or
OS/2 32-bit
• Environment subsystem
– Implement part of the support for the operating system
environment
• personality presented to the user and programmer
– Win NT originally shipped with Windows, POSIX, and
OS/2
– OS/2 was dropped from Win2K
– Windows XP: only the Windows subsystem is shipped in
the base product
Vishal
• an enhanced POSIX subsystem is available as part of
128
Kaushal
the free Services for Unix product
Environment Sub Systems
• Win32 subsystem runs 32-bit Windows applications and
also supports Virtual DOS Machines (VDMs) , which
allows MS-DOS and 16-bit Windows 3.1x (Win16)
applications to run on Windows.
• OS/2 environment subsystem supports 16-bit character-
based OS/2 applications and emulates OS/2 1.3 and
1.x, but not 32-bit or graphical OS/2 applications as used
on OS/2 2.x or later.
• POSIX environment subsystem supports applications
that are strictly written to either the POSIX.1 standard or
the related ISO IEC standards
Vishal
129
Kaushal
User Mode Processes
• Subsystem DLLs
– User applications don't call the native Windows
operating system services directly; rather, they go
through these
– Translate a documented function into the appropriate
internal (and generally undocumented) Windows
system service calls
Vishal
130
Kaushal
Windows 2000 Architecture
Kernel mode
• Kernel mode in Windows 2000 has full access to the
hardware and system resources of the computer.
•The kernel mode stops user mode services and
applications from accessing critical areas of the operating
system that they should not have access to.
•The executive interfaces with all the user mode
subsystems. It deals with I/O, object management, security
and process management
131
Executive Modules
• Process and thread manager
– handles process and thread creation and termination
• Virtual memory manager
– manages virtual memory, allowing Windows 2000 to use the hard disk as a
primary storage device (although strictly speaking it is secondary storage).
• I/O system
– allows devices to communicate with user-mode subsystems by translating
user-mode read and write commands and passing them to device drivers.
• Cache manager
– Improves the performance of files based I/O by causing recently
referenced disk data to reside in main memory for quick access.
• Object manager
– create, manage, destroy windows executable Objects
– A special executive subsystem that all other executive subsystems must
pass through to gain access to Windows 2000 resources.
– This is essentially a resource management infrastructure Vishalservice that
132
Kaushal
allows Windows 2000 to be an object oriented operating system.
Executive Modules
• LPC (Local Procedure call) facility
– flexible, optimized version of RPC,
– Enforces a client-server relationship between applications and
executives subsystems.
• PnP Manager
– handles Plug and Play and supports device detection and
installation at boot time
• Power Manager
– It coordinates power management among various devices and
reduce power consumption.
• Configuration manager
– Responsible for implementing and managing the system registry.
• Security reference monitor
– protection/auditing
Vishal
133
Kaushal
Kernel
Multiprocessor synchronization
134
Device Drivers
Loadable kernel modules
Types:
135
Kernel Mode Processes
• Windowing and graphics system
– implements the graphical user interface (GUI) functions
– Eg. dealing with windows, user interface controls, and
drawing
Vishal
136
Kaushal
Hardware Abstraction Layer
137
Hardware Abstraction Layer
The HAL provides the following services:
Integration with the newlib ANSI C standard library-
- Provides the familiar C standard library functions
System initialization —Performs initialization tasks for the processor and the
runtime environment before main()
138
LINUX
139
Layers of a UNIX System
140
General UNIX Architecture
System call
interface
Kernel
142
What is Linux
A fully-networked 32/64-Bit Unix-like Operating System
Unix Tools Like sed, awk, and grep (explained later)
Compilers Like C, C++, Fortran, Smalltalk, Ada
Network Tools Like telnet, ftp, ping, traceroute
Multi-user, Multitasking, Multiprocessor
Has the X Windows GUI
Coexists with other Operating Systems
Runs on multiple platforms
Includes the Source Code
143
Where did it come from?(History)
144
History
Linux is on a path of continuous improvement
Linux is being continuously:
Downloaded
Modified
Fine-tuned
The
future
The
past
145
How do you get it?
Download it from the Internet
From a “Distribution” (e.g. RedHat)
Linux kernel
X Windows system and GUI
Web, e-mail, FTP servers
Installation & configuration support
3rd party apps
Hardware support
146
Features of Linux
Free
Compatibility on most hardware
Well documented
Customisable
Open source
Multi-tasking capability
TCP/IP Networking
High level of security
Programming support for many languages
GUI support
147
Linux Architecture
The Kernel is the heart of the operating system. Its main
functions are:
SHELL
148
Linux Architecture ( Contd ...)
SHELL
KERNEL TO
KERNEL
HARDWARE
HARDWARE SHELL COMMUNICATION
SHELL
KERNEL TO SHELL
COMMUNICATION
SHELL
Tools and
Application
149
Directory Hierarchy
ROOT DIRECTORY
BIN TMP
SBIN
BOOT
ROOT
DEV
ETC HOME PROC USR
MOUNT
KEVIN
SUSAN
DHAR
DYLAN
ASSET
APTECH MICKEY
LIN1
150
Vishal
151
Kaushal
Vishal
152
Kaushal
Modular structure
Although monolithic, the kernel is structures as a collection of
modules
Linux is structured as a collection of modules, a number of which can
be automatically loaded and unloaded on demand.
These relatively independent blocks are referred to as loadable
modules.
Module is an object file whose code can be linked to and unlinked
from the kernel at runtime.
It implements specific function such as file system, device drivers
It is not a separate process/thread.
It is executed in kernel mode on behalf of the current process.
153
Modular Structure
154
Modular Structure
• User can explicitly load module using insmod command.
• unloaded using rmmod command.
• Kernel monitors the need for particular function and can load &
unload modules as needed.
• In stackable modules dependencies b/n modules can be defined.
• Common code b/n set of modules can be moved into a single
module reducing replication.
• Kernel make sure that needed modules are present & avoid
unloading of models.
08/06/11 155
Linux Kernel Modules
156
Linux Kernel Modules
• It shows that the VFAT module was loaded after the FAT
module and that the VFAT module is dependent on the FAT
module.
• Modules are organized as linked list.
• Each module is defined by two tables,
1. Module table
2. Symbol table.
157
Module Table
• next: Pointer to the following module. All modules are organized into
a linked list.
• name: Pointer to module name
• size: Module size in memory pages
• usecount: Module usage counter. The counter is incremented when
an operation involving the module’s functions is started and
decremented when the operation terminates
• flags: Module flags
• nsyms: Number of exported symbols
• ndeps: Number of referenced modules
• syms: Pointer to this module’s symbol table.
• deps: Pointer to list of modules that are referenced by this module.
• refs: Pointer to list of modules that use this module
Vishal
158
Kaushal
Linux kernel components
This figure shows the main components of the Linux
kernel as implemented on an IA-64 architecture (e.g.
Intel Itanium).
It shows several processes running on top of the
kernel.
Each box indicates a separate process, while each
squiggly line with an arrowhead represents a thread
of execution.
159
Linux kernel components
160
Kernel Components
• Signals: The kernel uses signals to call into a process.
– For example, signals are used to notify a process of
certain faults, such as division by zero.
• System calls: The system call is the means by which a
process requests a specific kernel service. There are
several hundred system calls, which can be roughly
grouped into six categories: file system, process,
scheduling, IPC, socket, and miscellaneous
• Processes and scheduler: Creates, manages, and
schedules processes.
• Virtual memory: Allocates and manages virtual memory
for processes
Vishal
161
Kaushal
Kernel Components
• File systems: Provides a global, hierarchical namespace
for files, directories, and other file related objects and
provides file system functions.
• Network protocols: Supports the Sockets interface to
users for the TCP/IP protocol suite
• Character device drivers: Manages devices that require
the kernel to send or receive data one byte at a time,
such as terminals, modems, and printers.
• Block device drivers: Manages devices that read and
write data in blocks, such as various forms of secondary
memory (magnetic disks, CD-ROMs, etc.)
Vishal
162
Kaushal
Kernel Components
Vishal
163
Kaushal
Do you agree?
• Each processor is doing exactly one of three things at
any given moment:
– In user-space, executing user code in a process
– In kernel-space, in process context, executing on
behalf of a specific process
– In kernel-space, in interrupt context, not associated
with a process, handling an interrupt
Vishal
164
Kaushal
Self Study
•Overview of Linux
•Windows 2000 architecture
Vishal
165
Kaushal