Introduction To Operating Systems
Introduction To Operating Systems
Operating System Concepts – 10h Edition Silberschatz, Galvin and Gagne ©2018
Introduction
● Definition of operating systems
● Single and multi-processor systems
● Operating system services
● System commands and system calls
● Interrupt
● System boot
● Operating system structure
● Types of OS
● Multi-user
● Multitasking
● Embedded
● Real-time
● Network
● Distributed
Operating System Concepts – 10th Edition 1.2 Silberschatz, Galvin and Gagne ©2018
Definition of Operating Systems
• Definition and Purpose:
• Operating systems (OS) act as an intermediary between computer
hardware and user applications.
• They manage system resources, provide a user interface, and ensure the
smooth execution of programs.
• Functions:
• Process management, memory management, file system management,
and device management.
• Security and protection of resources.
• User interface and application support.
• Examples:
• Windows: Widely used for personal computers.
• Linux: Open-source and popular for servers.
• macOS: Apple's operating system for Macintosh computers.
Operating System Concepts – 10th Edition 1.3 Silberschatz, Galvin and Gagne ©2018
Operating system goals
Operating System Concepts – 10th Edition 1.4 Silberschatz, Galvin and Gagne ©2018
Computer System Structure
Operating System Concepts – 10th Edition 1.5 Silberschatz, Galvin and Gagne ©2018
Four Components of a Computer System
Operating System Concepts – 10th Edition 1.6 Silberschatz, Galvin and Gagne ©2018
What Operating Systems Do
Operating System Concepts – 10th Edition 1.7 Silberschatz, Galvin and Gagne ©2018
Single and Multi-Processor Systems
• Single Processor Systems:
• Utilizes a single central processing unit (CPU).
• Sequential execution of instructions.
• Multi-Processor Systems:
• Multiple CPUs work simultaneously.
• Improved performance and parallel processing.
• Challenges include synchronization and coordination.
• Parallel Processing:
• Simultaneous execution of multiple tasks or processes.
• Enhances overall system performance.
Operating System Concepts – 10th Edition 1.8 Silberschatz, Galvin and Gagne ©2018
Operating System Services
● Operating systems provide an environment for execution of programs
and services to programs and users
● One set of operating-system services provides functions that are
helpful to the user:
● User interface - Almost all operating systems have a user
interface (UI).
4 Varies between Command-Line (CLI), Graphics User
Interface (GUI), Batch
● Program execution - The system must be able to load a
program into memory and to run that program, end execution,
either normally or abnormally (indicating error)
● I/O operations - A running program may require I/O, which may
involve a file or an I/O device
Operating System Concepts – 10th Edition 1.9 Silberschatz, Galvin and Gagne ©2018
Operating System Services (Cont.)
Operating System Concepts – 10th Edition 1.10 Silberschatz, Galvin and Gagne ©2018
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
4 Many types of resources - CPU cycles, main memory, file storage,
I/O devices.
● 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
4 Protection involves ensuring that all access to system resources is
controlled
4 Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access
attempts
Operating System Concepts – 10th Edition 1.11 Silberschatz, Galvin and Gagne ©2018
A View of Operating System Services
Operating System Concepts – 10th Edition 1.12 Silberschatz, Galvin and Gagne ©2018
System Commands and System Calls
• System Commands:
• Definition: System commands are user-initiated actions that instruct the
operating system to perform specific tasks.
• User Interaction: Users interact with the operating system through the
command-line interface (CLI) or graphical user interface (GUI) to execute
commands.
• Examples:
● ls: List the contents of a directory.
● cd: Change the current working directory.
● mkdir: Create a new directory.
● rm: Remove/delete files or directories.
Operating System Concepts – 10th Edition 1.13 Silberschatz, Galvin and Gagne ©2018
System Commands and System Calls
• System Calls:
• Definition: System calls are a mechanism that provides an interface between
applications (user-level programs) and the operating system kernel. They
allow processes to request services from the OS.
• Purpose: System calls enable processes to perform tasks that require
privileged access or interaction with hardware, which is restricted in
user-mode.
• Examples of System Calls:
● read(): Reads data from a file or input device.
● write(): Writes data to a file or output device.
● open(): Opens a file.
● fork(): Creates a new process (used for process creation).
● exec(): Executes a new program within the current process.
Operating System Concepts – 10th Edition 1.14 Silberschatz, Galvin and Gagne ©2018
Example of System Calls
● System call sequence to copy the contents of one file to another file
Operating System Concepts – 10th Edition 1.15 Silberschatz, Galvin and Gagne ©2018
Example of Standard API
Operating System Concepts – 10th Edition 1.16 Silberschatz, Galvin and Gagne ©2018
System Commands and System Calls
• Execution Process:
• User-level programs use high-level language constructs (functions).
• These functions map to system calls when compiled.
• During runtime, the system call invokes a specific kernel routine.
• Kernel Interaction: The operating system kernel performs privileged
operations on behalf of user-level processes, ensuring security and controlled
access to system resources.
• System Call Examples in C:
// Example of 'write' system call in C
#include <unistd.h>
int main() {
char message[] = "Hello, Operating Systems!";
write(1, message, sizeof(message)-1);
// '1' corresponds to standard output
return 0;
}
Operating System Concepts – 10th Edition 1.17 Silberschatz, Galvin and Gagne ©2018
API – System Call – OS Relationship
Operating System Concepts – 10th Edition 1.18 Silberschatz, Galvin and Gagne ©2018
Types of System Calls
● Process control
● create process, terminate process
● end, abort
● load, execute
● get process attributes, set process attributes
● wait for time
● wait event, signal event
● allocate and free memory
● Dump memory if error
● Debugger for determining bugs, single step execution
● Locks for managing access to shared data between processes
Operating System Concepts – 10th Edition 1.19 Silberschatz, Galvin and Gagne ©2018
Types of System Calls
● File management
● create file, delete file
● open, close file
● read, write, reposition
● get and set file attributes
● Device management
● request device, release device
● read, write, reposition
● get device attributes, set device attributes
● logically attach or detach devices
Operating System Concepts – 10th Edition 1.20 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
● Information maintenance
● get time or date, set time or date
● get system data, set system data
● get and set process, file, or device attributes
● Communications
● create, delete communication connection
● send, receive messages if message passing model to host
name or process name
4 From client to server
● Shared-memory model create and gain access to memory
regions
● transfer status information
● attach and detach remote devices
Operating System Concepts – 10th Edition 1.21 Silberschatz, Galvin and Gagne ©2018
Types of System Calls (Cont.)
● Protection
● Control access to resources
● Get and set permissions
● Allow and deny user access
Operating System Concepts – 10th Edition 1.22 Silberschatz, Galvin and Gagne ©2018
Examples of Windows and Unix System Calls
Operating System Concepts – 10th Edition 1.23 Silberschatz, Galvin and Gagne ©2018
Standard C Library Example
● C program invoking printf() library call, which calls write() system call
Operating System Concepts – 10th Edition 1.24 Silberschatz, Galvin and Gagne ©2018
System Commands and System Calls
Differences Between System Commands and System Calls:
User vs. Kernel Space:
• System Commands: Executed in user space.
• System Calls: Transition from user space to kernel space.
Privilege:
• System Commands: Executed with user-level privileges.
• System Calls: Invoked to perform privileged operations with
kernel-level access.
Implementation:
• System Commands: Implemented by utilities or programs in user
space.
• System Calls: Directly interact with the operating system kernel.
Operating System Concepts – 10th Edition 1.25 Silberschatz, Galvin and Gagne ©2018
System Commands and System Calls
Examples of System Commands and Their Corresponding System
Calls:
Command `ls`:
System Call Equivalent: opendir(), readdir(), closedir().
Command `cp`:
System Call Equivalent: open(), read(), write(), close().
Command `fork()`:
System Call Equivalent: fork().
Command `exec()`:
System Call Equivalent: exec().
Operating System Concepts – 10th Edition 1.26 Silberschatz, Galvin and Gagne ©2018
Interrupt
• Definition:
• An interrupt is a is a mechanism that allows external devices or
processes to interrupt the normal execution flow of the CPU. It is a
signal to the operating system to stop its current activity and
respond to an event.
• Types of Interrupts:
• Hardware interrupts (e.g., keyboard input).
• Software interrupts (e.g., system calls).
• Exception interrupts (e.g., division by zero).
Operating System Concepts – 10th Edition 1.27 Silberschatz, Galvin and Gagne ©2018
Interrupt
• Hardware Interrupts:
• Definition: Generated by external hardware devices to
signal that they need attention.
• Examples:
• Input/Output operations completion.
• Timer interrupts for scheduling tasks.
• Hardware errors.
• Handling: The operating system kernel has interrupt
service routines (ISRs) to handle hardware interrupts.
Operating System Concepts – 10th Edition 1.28 Silberschatz, Galvin and Gagne ©2018
Interrupt
• Software Interrupts:
• Definition: Generated by executing a specific instruction
in the code.
• Examples:
• System calls initiated by user programs.
• Software-generated exceptions.
• Handling: The kernel has specific handlers for software
interrupts.
Operating System Concepts – 10th Edition 1.29 Silberschatz, Galvin and Gagne ©2018
Interrupt
• Exception Interrupts:
• Definition: Generated by the CPU when it encounters an
exceptional condition during execution.
• Examples:
• Division by zero.
• Page faults in memory access.
• Handling: Exception handlers in the kernel deal with
exceptional conditions.
Operating System Concepts – 10th Edition 1.30 Silberschatz, Galvin and Gagne ©2018
Interrupt
Handling Process
•Interrupt Request (IRQ):
• Devices or processes generate IRQs to signal interrupts.
• IRQs are assigned specific priority levels.
•Interrupt Vector Table (IVT):
• A table in memory that maps interrupt numbers to their corresponding interrupt service routines
(ISRs).
•Interrupt Service Routine (ISR):
• A specific routine in the operating system kernel that is executed in response to an interrupt.
• Handles the interrupt and performs necessary actions.
•Context Switch:
• The operating system performs a context switch to save the current state of the CPU and
execute the ISR.
•Interrupt Acknowledgment:
• The CPU acknowledges the interrupt, and the ISR is executed.
•Restoration of State:
• After ISR execution, the operating system restores the saved state, and normal execution
continues.
Operating System Concepts – 10th Edition 1.31 Silberschatz, Galvin and Gagne ©2018
Interrupt
Uses and Significance
•Event Handling:
• Allows the operating system to respond promptly to external events.
•Efficiency:
• Enables asynchronous processing, improving system efficiency.
•Real-Time Systems:
• Essential for real-time operating systems where timely responses to events are critical.
Examples of Interrupts:
•Keyboard Interrupt:
• Generated when a key is pressed.
• OS responds to update the keyboard buffer.
•Timer Interrupt:
• Generated periodically by a system timer.
• Used for time-slicing in multitasking environments.
•Device Interrupt:
• Generated by peripheral devices upon completion of an operation.
• Allows the OS to manage multiple I/O operations concurrently.
Operating System Concepts – 10th Edition 1.32 Silberschatz, Galvin and Gagne ©2018
System Boot
• Bootstrapping Process:
• Loading the operating system into memory.
• Initialization of system components.
• Boot Loaders:
• Software that manages the boot process.
• Examples: GRUB, LILO.
• Sequence of Steps:
• Power-on self-test (POST).
• Boot loader activation.
• Loading the kernel.
• Initializing the system.
Operating System Concepts – 10th Edition 1.33 Silberschatz, Galvin and Gagne ©2018
Operating System Structure
1. Monolithic Architecture
2. Microkernel Architecture
3. Layered Design
Operating System Concepts – 10th Edition 1.34 Silberschatz, Galvin and Gagne ©2018
Monolithic Architecture
• Definition:
• The monolithic operating system architecture has a single, large
codebase where all operating system services run as a single program in
kernel space.
• Characteristics:
• Advantages:
• Simple design and implementation.
• Direct communication between components.
• Disadvantages:
• Lack of modularity.
• Changes in one part may affect others.
Operating System Concepts – 10th Edition 1.35 Silberschatz, Galvin and Gagne ©2018
Microkernel Architecture
• Definition:
• The microkernel architecture follows a modular design where the kernel
provides only essential services, and additional services are implemented
as separate user-space processes or modules.
• Characteristics:
• Advantages:
• Increased modularity and flexibility.
• Easier maintenance and extensibility.
• Disadvantages:
• Overhead due to inter-process communication (IPC).
• Potentially reduced performance compared to monolithic kernels.
Operating System Concepts – 10th Edition 1.36 Silberschatz, Galvin and Gagne ©2018
Microkernel System Structure
Operating System Concepts – 10th Edition 1.37 Silberschatz, Galvin and Gagne ©2018
Operating System Structure
Layered Design:
•Definition:
• The layered operating system design organizes the system into layers,
where each layer provides specific functionality, and each layer
communicates only with adjacent layers.
•Characteristics:
• Advantages:
• Modularity and ease of understanding.
• Layers can be added or modified independently.
• Disadvantages:
• Overhead due to layer interaction.
• Changes in one layer may impact others.
Operating System Concepts – 10th Edition 1.38 Silberschatz, Galvin and Gagne ©2018
Layered Approach
Operating System Concepts – 10th Edition 1.39 Silberschatz, Galvin and Gagne ©2018
Operating System Structure
Hybrid Architectures:
•Definition:
• Hybrid operating system architectures combine features from different
designs to achieve a balance between simplicity and modularity.
•Example:
• Windows operating systems use a hybrid architecture with a
microkernel-like structure for some components and a more traditional
monolithic kernel.
Operating System Concepts – 10th Edition 1.40 Silberschatz, Galvin and Gagne ©2018
Operating System Structure
Monolithic vs. Microkernel Comparison:
Operating System Concepts – 10th Edition 1.41 Silberschatz, Galvin and Gagne ©2018
Layered Design in Detail
• Kernel Layer:
• Core functionality like process management, memory management, and
device drivers.
• System Call Layer:
• Interface for user-level applications to request services.
• Utility Layer:
• Higher-level utilities and services.
• User Interface Layer:
• Interaction with users through command-line or graphical interface.
Operating System Concepts – 10th Edition 1.42 Silberschatz, Galvin and Gagne ©2018
Importance of OS Structure
• Modularity:
• The structure influences how easily new features or changes can be
incorporated.
• Maintenance:
• A well-structured OS is easier to maintain and debug.
• Extensibility:
• Allows for the addition of new features without affecting existing
components.
Operating System Concepts – 10th Edition 1.43 Silberschatz, Galvin and Gagne ©2018
Transition Between Layers in a Layered Design
• Communication:
• Layers communicate through well-defined interfaces.
• Data Flow:
• Data typically flows vertically through layers.
• Abstraction:
• Each layer provides an abstraction for the layer above.
Operating System Concepts – 10th Edition 1.44 Silberschatz, Galvin and Gagne ©2018
Types of Operating Systems
a. Multi-User
•Characteristics:
• Supports multiple users simultaneously.
• Time-sharing and resource sharing.
•Examples:
• UNIX, Linux, Windows Server.
b. Multitasking
•Definition:
• Simultaneous execution of multiple tasks.
•Benefits:
• Improved system efficiency and resource utilization.
•Examples:
• Windows, macOS, Linux.
Operating System Concepts – 10th Edition 1.45 Silberschatz, Galvin and Gagne ©2018
Types of Operating Systems (contd..)
c. Embedded
•Use Cases:
• Embedded in devices and systems.
• Real-time control and minimal resource usage.
•Examples:
• Android (for mobile devices), VxWorks (for embedded systems).
d. Real-Time
•Characteristics:
• Responds to events within a specific time frame.
• Critical for applications like aerospace and medical systems.
•Examples:
• RTLinux, FreeRTOS.
Operating System Concepts – 10th Edition 1.46 Silberschatz, Galvin and Gagne ©2018
Types of Operating Systems (contd..)
e. Network
•Role:
• Manages network resources and communication.
• Facilitates file and printer sharing.
•Examples:
• Novell NetWare, Windows Server.
f. Distributed
•Characteristics:
• Spreads tasks across multiple interconnected computers.
• Enhances reliability and performance.
•Examples:
• Google's Chrome OS, Amoeba.
Operating System Concepts – 10th Edition 1.47 Silberschatz, Galvin and Gagne ©2018