Unit 1 - Overview of OS
Unit 1 - Overview of OS
UNIT 1
OVERVIEW OF OPERATING SYSTEM: 6 HOURS
SYLLABUS CONTENT
1.1 Introduction:
Operating System operations
Process management
Memory management
Storage management
Protection and security
Distributed and special purpose Systems.
1.2 System Structure:
Operating system services and interface
System calls and its types
System programs
Operating System Design and implementation
OS structure
Virtual machines
OS debugging and generation
System boot
A program that acts as an intermediary between a user of a computer and the computer hardware (interface)
An operating system (OS) is a collection of software that manages computer hardware resources and provides
common services for computer program
User View of an OS
Ease of use
Performance
Resource utilization
System View of an OS
OS is a resource allocator / manager
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the computer
VIEW OF A KERNEL
STORAGE STRUCTURE
STORAGE HIERARCHY
STORAGE-DEVICE HIERARCHY
COMPUTER-SYSTEM ARCHITECTURE
Single-Processor system
Multi-Processor system
Clustered System
Loosely coupled system v/s tightly coupled system
HPC
Parallel Computing, etc.
The OS is designed in such a way that it is capable of differentiating between the execution of OS code and user
defined code.
To achieve this, OS needs two different modes of operations (User and Kernel / supervisor / system /
privileged)
This is controlled by mode bit added to hardware of computer system
When a user application is executing on the computer system, OS is working in user mode. (mode bit = 1)
When a user application requests a service from OS (via a system call), the computer system transits from user
mode to kernel mode to service that request (mode bit = 0)
Some instructions designated as privileged, only executable in kernel mode
COMPUTER STARTUP
TIMER
MAJOR OS FUNCTIONS
Process management
Memory management
Storage management
Information protection and security
Distributed and special purpose Systems
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
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 directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media
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
Partitioning
Protection
Mounting and unmounting
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape
Still must be managed – by OS or applications
Varies between WORM (write-once, read-many-times) and RW (read-write)
CACHING
Important principle, performed at many levels in a computer (in hardware, operating system, software)
Information in use copied from slower to faster storage temporarily
Faster storage (cache) checked first to determine if information is there
If it is, information used directly from the cache (fast)
If not, data copied to cache and used there
Cache management important design problem
Cache size and replacement policy
Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage
hierarchy
Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most
recent value in their cache
Distributed environment situation even more complex
Several copies of a datum can exist
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
DISTRIBUTED SYSTEMS
Traditional computing
Portal
Wireless network
Thin / Thick client
Mobile computing
iOS and Android
Client / server architecture
Compute server
File server
Peer-to-Peer (P2P)
Virtualization
Cloud computing
Real-Time Embedded Systems
Free and Open Source OSs
VIEWS OF OS
3 views:
The services that the system provides
The interface that it makes available to users and programmers
Its components and their interconnections
Security: the user needs to authenticate him or her to the system before using
Protection: access to system resources in a controlled manner
USER-OS INTERFACE
SYSTEM CALLS
Generally, system calls are made by the user level programs in the following situations:
Creating, opening, closing and deleting files in the file system.
Creating and managing new processes.
Creating a connection in the network, sending and receiving packets.
Requesting access to a hardware device, like a mouse or a printer.
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): strong correlation between a function in the API and its associated system call within
the kernel
SYSTEM CALL EXAMPLES: THE HANDLING OF A USER APPLICATION INVOKING THE OPEN() SYSTEM CALL
1. Process control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication
6. Protection
EXAMPLE: MS-DOS
Single-tasking
Shell invoked when system booted
Single memory space
Loads program into memory
Program exit -> shell reloaded
EXAMPLE: FREEBSD
Unix variant
Multitasking
User login -> invoke user’s choice of shell
Shell executes fork() system call to create process
Executes exec() to load program into process
Shell waits for process to terminate or continues with user commands
Exit ( ) system call to terminate
Process exits with:
code = 0 – no error
code > 0 – error code
2. File Management
Some common system calls are create, delete, read, write, reposition, or close.
Also, there is a need to determine the file attributes – get and set file attribute.
File attributes include the file name, file type, protection codes, accounting information.
Additional system calls: Move and copy
Many times the OS provides an API to make these system calls.
Similar functions for directories too
3. Device Management
Process usually require several resources to execute, if these resources are available, they will be granted and control
returned to the user process.
These resources are also thought of as devices.
Some are physical, such as a video card, and others are abstract, such as a file.
User programs request the device, and when finished they release the device.
System Calls
request device, release device
read, write
get device attributes, set device attributes
4. Information Maintenance
Some system calls exist purely for transferring information between the user program and the operating
system. An example of this is time, or date, number of current users, version of OS, amount of free
space etc.
The OS also keeps information about all its processes and provides system calls to report this
information.
System Calls
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
5. Communication
There are two models of inter process communication, the message-passing model and the shared memory model.
Message-passing uses a common mailbox to pass messages between processes.
Shared memory use certain system calls to create and gain access to regions of memory owned by other processes.
The two processes exchange information by reading and writing in the shared data.
System Calls
Get hostid and get processeid
Open connection and close connection
create, delete communication connection
send, receive messages if message passing model to host name or process name i.e. From client to server
Shared-memory model create and gain access to memory regions
transfer status information
attach and detach remote devices
6. Protection
Control access to resources
Get and set permissions
Allow and deny user access
SYSTEM PROGRAMS
System programs (system utilities) provide a convenient environment for program development and execution.
Some of them are simply user interfaces to system calls.
The can be divided into:
File manipulation
Status information
File modification
Programming language support
Program loading and execution
Communications
Background services
Application programs
Most users’ view of the operating system is defined by system programs and application programs, not the actual system calls
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
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
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
Background Services:
Some processes terminate after completion of their task while others continue until system is halted
Launch at boot time
Some for system startup, then terminate
Some from system boot to shutdown
Provide facilities like disk checking, process scheduling, error logging, printing
Constantly running system program processes are known as services, subsystems, or daemons
n/w daemon, process schedulers
Application programs
Don’t pertain to system
Run by users
Not typically considered part of OS
Launched by command line, mouse click
Include word processors and text formatters, spreadsheets, database systems, statistical-analysis packages, etc.
Implementation:
Earlier in Assembly language
Then system programming languages like Algol, PL/1
Nowadays, in HLL like C/C++
Problems with HLL: reduced speed and increased storage requirements
Performance improvement:
through better data structures and algorithms than excellent assembly codes
The critical and high performance parameters like MM and CPU scheduler can be coded in assembly (if becoming performance
bottleneck)
So, usually a mix of languages: Lowest levels in assembly, Main body in C, Systems
programs in C, C++, scripting languages like PERL, Python, shell scripts
Simple Structure
No well defined structure
Started as small, simple and limited systems
MS-DOS: written to provide the most functionality in the least space
Not divided into modules
Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated
Another example, Original UNIX
LAYERED APPROACH
Structures the OS by removing all non essential components from kernel and
implementing them as system and user level programs.
The result is smaller kernel.
The main functionality, communication, takes place using message passing.
Program and service never interact directly, indirectly by message passing with
microkernel
Disadvantages: System overhead due to communication
BENEFITS OF MICROKERNEL
Ease of extending OS: new services are added to user space, no modification required for
kernel.
Easier to port from h/w design to another
Provides more security and reliability: since most services are running as user rather than
kernel processes. If a service fails, rest of the OS remains untouched.
Examples:
Tru64 UNIX (formerly Digital UNIX) provides a UNIX interface to the user, but it is
implemented with a Mach kernel.
The Mac OS X kernel (Darwin)
QNX, a real-time operating system
MODULES
Kernel has a set of core components and links in additional services via modules at boot or
run time
Many modern operating systems implement loadable kernel modules (to be loaded
dynamically)
Uses object-oriented approach
Each core component is separate
Each talks to the others over known interfaces (Adv. over layered Approach (pass thru all the layers))
Each is loadable as needed within the kernel (similar to microkernel but adv over microkernel as
communication is not needed)
Overall, similar to layers but with more flexibility; similar to microkernel but no need of
communication
Linux, Solaris, etc.
DR. NEEPA SHAH 74
HYBRID SYSTEMS
Most modern operating systems are actually not one pure model
Hybrid combines multiple approaches to address performance, security, usability needs
Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of
functionality
Windows mostly monolithic, plus microkernel for different subsystems
Apple Mac OS X hybrid, layered,Aqua UI plus Cocoa programming environment
Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically
loadable modules (called kernel extensions)
Mach: MM, IPC and RPC, Message-passing and thread scheduling
BSD: CLI, Network and FM, POSIX API and Pthread.
kernel environment
BSD
Mach
VIRTUAL MACHINES
VMWARE ARCHITECTURE
JVM
Operating systems are designed to run on any of a class of machines; the system must be configured
for each specific computer site
SYSGEN program obtains information concerning the specific configuration of the hardware system
What CPU is to be used?
How much memory is available?
What devices are available?
What OS options are available?
Booting–starting a computer by loading the kernel
Bootstrap program–code stored in ROM that is able to locate the kernel, load it into memory, and start
its execution.WHY ROM?
SYSTEM BOOT
Operating system must be made available to hardware so hardware can start it.
Small piece of code –bootstrap loader, locates the kernel, loads it into memory, and starts it
Sometimes two-step process where boot block at fixed location loads bootstrap loader
When power initialized on system, execution starts at a fixed memory location
Firmware used to hold initial boot code
BIOS Kernel
Lives in motherboard Lives in boot drive
OS independent OS dependent
Should be up and running
before kernel
Used during booting process 1st thing that is loaded and
remains in main memory for
entire session