0% found this document useful (0 votes)
34 views

Os Unit 1

The document discusses the key functions and components of an operating system, including process management, memory management, storage management, I/O subsystem management, device management, protection and security, networking, and the command-interpreter system. It describes the services an operating system provides to users and processes, such as resource allocation and accounting. It also explains how system calls allow processes to interface with the operating system kernel.

Uploaded by

saumya patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Os Unit 1

The document discusses the key functions and components of an operating system, including process management, memory management, storage management, I/O subsystem management, device management, protection and security, networking, and the command-interpreter system. It describes the services an operating system provides to users and processes, such as resource allocation and accounting. It also explains how system calls allow processes to interface with the operating system kernel.

Uploaded by

saumya patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

SHARDA UNIVERSITY

“Principle of Operating System ”


Operating System

Services
Operating Systems Function (Component)

Process Management
Memory Management
Device Management
File Management
Protection & Security
Networking
Command-Interpreter System
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
Process Management Activities
The operating system is responsible for the following activities in connection
with process management:
 Creating and deleting both user and system processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
 Providing mechanisms for deadlock handling
Memory Management
 All data in memory before and after processing
 All instructions in memory in order to execute
 Memory management determines what is in memory when
 Optimizing CPU utilization and computer response to users
 Memory management activities
 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
 Allocating and deallocating memory space as needed
Storage 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
 Access control on most systems to determine who can access what
 OS activities include
 Creating and deleting files and directories
 Primitives to manipulate files and dirs
 Mapping files onto secondary storage
 Backup files onto stable (non-volatile) storage media
Mass-Storage Management
 Usually disks used to store data that does not fit in main memory or data that must be
kept for a “long” period of time.
 Proper management is of central importance
 Entire speed of computer operation hinges on disk subsystem and its algorithms
 OS activities
 Free-space management
 Storage allocation
 Disk scheduling
 Some storage need not be fast
 Tertiary storage includes optical storage, magnetic tape
 Still must be managed
 Varies between WORM (write-once, read-many-times) and RW (read-write)
I/O Subsystem
 One purpose of OS is to hide peculiarities of hardware devices from the user
 I/O subsystem responsible for
 Memory management of I/O including buffering (storing data temporarily
while it is being transferred), caching (storing parts of data in faster storage
for performance), spooling (the overlapping of output of one job with input
of other jobs)
 General device-driver interface
 Drivers for specific hardware devices
Device Management
Opening or attaching a device to a process
Reading data from a device
Writing data to a device
Closing or releasing a device
Protection and Security
 Protection – any mechanism for controlling access of processes or users to
resources defined by the OS
 Security – defense of the system against internal and external attacks
 Huge range, including denial-of-service, worms, viruses, identity theft,
theft of service
 Systems generally first distinguish among users, to determine who can do what
 User identities (user IDs, security IDs) include name and associated
number, one per user
 User ID then associated with all files, processes of that user to determine
access control
 Group identifier (group ID) allows set of users to be defined and controls
managed, then also associated with each process, file
 Privilege escalation allows user to change to effective ID with more rights
Networking
Establish a connection to a remote service
Listening for connection from remote client
Sending message to a remote system
Receiving message from remote system
Closing connection to a remote system
Operating Systems Services
1. Program creation
2. Program execution
3. Input/output operations
4. Error detection
5. Resource allocation
6. Accounting
7. protection
A View of Operating System Services
Operating System Services (Cont)
 One set of operating-system services provides functions that are
helpful to the user (Cont):
Communications – Processes may exchange
information, on the same computer or between
computers over a network
 Communications may be via shared memory or through
message passing (packets moved by the OS)
Error detection – OS needs to be constantly aware of
possible errors
 May occur in the CPU and memory hardware, in I/O devices,
in user program
 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
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
 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, extends
to defending external I/O devices from invalid access attempts
 If a system is to be protected and secure, precautions must be instituted
throughout it. A chain is only as strong as its weakest link.
Command-Interpreter System
Many commands are given to the operating
system by control statements which deal with:
process creation and management
I/O handling
secondary-storage management
main-memory management
file-system access
protection
Networking
Commands may have counterparts for use in
programming
Ascii command line vs. graphic interface,
Windows explorer, “add-ins” like Norton Utilities
Command-Interpreter System (Cont.)
The program that reads and interprets control
statements is called variously:
command-line interpreter (Control card interpreter in
the “old batch days”)
shell (in UNIX)
Command.com for external commands in DOS

Its function is to get and execute the next command


statement.
Example: DOS window, UNIX command line,
Windows “run” window
Dual Mode Operation
Hardware provides at least two modes:
 “Kernel” mode (or “supervisor” or “protected”)
 “User” mode: Normal programs executed

Some instructions/ops prohibited in user mode:


 Example: cannot modify page tables in user mode

Attempt to modify  Exception generated
Transitions from user mode to kernel mode:
 System Calls, Interrupts, Other exceptions
System Calls
System calls provide the interface between a running
program and the operating system– like invoking a
command from inside a program.
 Generally available as assembly-language instructions.
 Languages defined to replace assembly language for systems
programming allow system calls to be made directly (e.g., C, C++) - C
language: open, close, read, write, …
Three general methods are used to pass parameters between
a running program and the operating system.
 Pass parameters in registers.
 Store the parameters in a table in memory, and the table address is
passed as a parameter in a register – if parms complicated.
 Push (store) the parameters onto the stack by the program, and pop
off the stack by operating system – usually in assembly language.
Example of System Calls
System call sequence to copy the contents of one file to
another file
Types of System Calls
Process control
File management
Device management
Information maintenance
Communications
Examples of Windows and Unix System Calls
System Programs
System programs provide a convenient environment
for program development and execution. The can be
divided into:
File manipulation
Status information
File modification
Programming language support
Program loading and execution
Communications
Application programs
Most users’ view of the operation system is defined
by system programs, not the actual system calls
System Programs
 Provide a convenient environment for program development and execution
 Some of them are simply user interfaces to system calls; others are considerably more
complex
 File management - Create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories
 Status information
 Some ask the system for info - date, time, amount of available memory, disk space,
number of users
 Others provide detailed performance, logging, and debugging information
 Typically, these programs format and print the output to the terminal or other output
devices
 Some systems implement a registry - used to store and retrieve configuration
information
System Programs (cont’d)
File modification
 Text editors to create and modify files
 Special commands to search contents of files or perform transformations
of the text
Programming-language support - Compilers, assemblers,
debuggers and interpreters sometimes provided
Program loading and execution- Absolute loaders, relocatable
loaders, linkage editors, and overlay-loaders, debugging systems
for higher-level and machine language
Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems
 Allow users to send messages to one another’s screens, browse web pages,
send electronic-mail messages, log in remotely, transfer files from one
machine to another
Operating System Structure
Simple Structure
 In this section, we’ll look at some approaches to structuring an
operating system.
 Before we go into Virtual Machines, we will consider different
structural approaches for the operating system design and
implementation:
 Simple structure
 Layered approach
 Micro-kernel approach
 Modular approach
Simple Structure
 MS-DOS – written to provide the most functionality in the least space
 No vision as what it would develop into
 Not divided into modules
 Although MS-DOS has some structure, its interfaces and levels of
functionality are not well separated
 Means that application programmers can access basic I/O routines
and write directly to display devices and disk drives.
 Clearly, this leaves MSDOS open to malicious behaviors!
 Limited too by hardware of this era.
 There were few protection mechanisms available…

 Consider the next figure.


 This shows the original structure of MS-DOS.
 Again, designers were after the most functionality in limited space.
MS-DOS Layer Structure
Most of your
operating
system is
here

Low level (device


drivers) were
here…

Read-only memory
basic input/output
device drivers were
here. (burned in
chips)
Simple Structure (continued)

 Early Unix too suffered from a lack of structuring and protection.


 Hardware was very slow then and very limited.
 More modern capabilities of the hardware were not available.
 Operating System still had two essential components: kernel and system programs
Kernel = interfaces & device drivers – everything below system call interface

 (a device driver is an operating system module (usually in the kernel) that deals directly
with a device or I/O module) (different source)
 (kernel: a portion of the operating system that includes the most heavily used portions
of software. Generally, the kernel is maintained permanently in main memory. Kernel
runs in privileged mode and responds to calls from processes and interrupts from
devices) (different source)
 All below system call interface and above the physical hardware is the kernel.
 Kernel provides the file system, CPU scheduling, memory management, and other
operating-system functions; a large number of functions for one level
 Kernel activities are accommodated via system calls.
 In sum, this is an enormous amount of functionality combined into one level.
 This monolithic structure was difficult to implement and maintain.
UNIX System Structure
Layered Approach
The operating system is divided into a number of
layers (levels), each built on top of lower layers. The
bottom layer (layer 0), is the hardware; the highest
(layer N) is the user interface.
With modularity, layers are selected such that each
uses functions (operations) and services of only lower-
level layers.
Aids in maintainability, and ease and speed of
development.
Allows reusable code.
Layered Approach
 The operating system is divided into a smaller pieces arranged in number of
layers (levels), each built on top of lower layers.
 Bottom layer (layer 0), is the hardware; highest layer (layer n), is the user
interface.
 OS can retain much greater control over computer this way.
 This is a top-down approach
 Overall functionality and features
 separated into components.
 Implemented in layers

 Modularity is hence established via layers with very separate functionality


in each – designed that way as separation of concerns
 Under this layered architectural design, layers only use functions
(operations) and services of lower-level layers.
 Normally don’t skip over a layer, but can…
Layered Design Approach - Advantages
Simplicity of construction.
Divide and conquer design goal; cohesive…
Simplicity in debugging because functions only
use lower-level functions.
Layer 1 only uses hardware functions.
 Debugging is simplified.
Layer 2 can have bugs; however, they must lie within
that layer, because the layers below are already
debugged.

Upper level functions have no knowledge of how


a lower level function is implemented.
Thus we have the hiding of certain data
structures and operations.
Layered Design Approach - Disadvantages
 Must define and document purposes / constraints, features for various layers.
 Must carefully plan layer contents: layer can only use services of lower level.
 Some cases requirements may be quite complex; care must be exercised!
 We will discuss some of these details ahead.
 Layered approach tends to be less efficient. This is easy to see:
 A user executes an I/O instruction, that executes a system call that is trapped
in the I/O layer, which calls memory management layer, which in turn calls
CPU scheduling layer, which is then passed to the hardware.
 For each layer, parameters and other data may be passed and modified
 Thus each layer adds overhead to the system call, which may result in a
system call that is less efficient than that on a non-layered system.

 Result: we have a layered architecture with more functionality in each layer


 Provides for some of the advantages of layering (cohesion; info hiding) while
 Avoiding the difficult problems of layer definition and interaction.(clear
definitions of functionality, interface, responsibilities, etc.)
Layered Operating System
An Operating System Layer
Encapsulates data , uses “access methods”

API for layer M

API for layer M-1


Microkernel System Structure Design
Microkernel: a small privileged operating system core that
provides process scheduling, memory management, and
communication services and relies on other processes to
perform some of the functions traditionally associated with
the operating system kernel.
Moves a good bit of non-essential functionality from the
kernel into “user” space
Removed kernel functionality implemented as system
programs; sometimes user programs.

 In Microkernel OS Design: kernel provides


 Minimal memory management and
 Minimal process management and
 Minimal communications.
Microkernel System Structure Design
 Benefits:
 Easier to extend the OS
 new services are added to user space and not to the kernel.
 Easier to port the operating system to new architectures
 because kernel is smaller (as many services are running as user and not
kernel processes).

 Detriments:
 Communications occurs between user modules using message passing
 This means that Clients acquire service only indirectly by communication via
messages with the microkernel
 So, clearly, overall performance suffers because of increased system
function overhead (passing parameters, and more)
 This is very significant!
Kernel
Kernel provide basic interface between the m/c itself
&
the rest of the operating system. it is responsible for the
management of the central processor.
It takes control early in the boot process & manages
disk, n/w and process.
OS kernel can be seen as the interface between devices
& processes.
Function of Kernel
To provide a mechanism for creation and deletion of
process.
To provide CPU scheduling , memory management &
device management for the process
To provide synchronization tools so that processes can
synchronize their action.
To provide communication tools so that process can
communicate with each other.
Give security and privacy services.
System Call System Call System Call System Call

Hardware OS User

Kernel Shell or
Command interpreter

You might also like