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

Mod-1

The document provides an overview of operating systems, detailing their functions, objectives, and various types, such as single-user, multi-user, and real-time operating systems. It discusses key areas like process management, memory management, file system management, and device management, along with services like user interfaces, error detection, and communication. Additionally, it outlines different operating system structures, including monolithic, layered, microkernel, and client-server architectures.

Uploaded by

sameerdhole84
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Mod-1

The document provides an overview of operating systems, detailing their functions, objectives, and various types, such as single-user, multi-user, and real-time operating systems. It discusses key areas like process management, memory management, file system management, and device management, along with services like user interfaces, error detection, and communication. Additionally, it outlines different operating system structures, including monolithic, layered, microkernel, and client-server architectures.

Uploaded by

sameerdhole84
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Operating Systems

Chapter 01
Operating System Overview
Operating System
• A program that controls the execution of
application programs
• An interface between applications and
hardware
OS as Resource Manager
Layers and Views
Need of OS
• Basically OS performs tasks, e.g. it identifying
input from input devices and sending output to
the output devices
• Keeping track of files and directories on the disk
• Controlling peripheral devices such as printers,
scanners, audio mixer.
• OS allocates memory to user program as per
their need .
• User programs interact with the other user
programs through devices like keyboard, mouse
and joy stick
Operating System Objectives
• Convenience
• Efficiency
• Ability to evolve
• The functions of an Operating System (OS) can be categorized into
several key areas, each essential for managing the computer's resources
and ensuring smooth operation. Here's an overview:
Process Management
• Process Scheduling: Handles execution of
processes, ensuring fair allocation of CPU time.

• Multitasking: Allows multiple processes to run


simultaneously.

• Process Creation and Termination: Manages


the lifecycle of processes (start, suspend,
resume, and stop).
• Deadlock Handling: Detects and resolves
situations where processes are waiting
indefinitely for resources.
Memory Management

• Allocation and Deallocation: Allocates


memory to programs and reclaims it when no
longer needed.

• Virtual Memory: Simulates more memory than


physically available using disk space.

• Memory Protection: Prevents processes from


interfering with each other's memory.
File System Management
• File Organization: Maintains the structure of
files and directories.

• Access Control: Manages file permissions to


ensure security.

• File Operations: Supports file creation,


deletion, reading, writing, and modification.

• Storage Management: Organizes data on


storage devices efficiently.
Device Management

• Device Drivers: Interfaces with hardware


devices like printers, keyboards, and disks.

• Device Scheduling: Manages and prioritizes


access to devices.

• I/O Control: Facilitates input/output operations


between devices and processes.
Security and Access Control
• Authentication: Ensures only authorized users
can access the system.

• Data Protection: Protects data against


unauthorized access or malware.

• Encryption and Firewalls: Safeguards


sensitive information and network
communications.
User Interface Management

• Graphical User Interface (GUI): Provides


visual elements like windows, icons, and menus
for interaction.

• Command-Line Interface (CLI): Allows text-


based interaction for advanced users.

• System Feedback: Displays error messages,


status updates, and logs.
Booting the Computer
• The process of starting or restarting the
computer is known as booting.

• If computer is switched off completely and if


turned on then it is called as cold booting

• A warm booting is the process of using the


operating system to restart the computer
Networking

• Communication Protocols: Manages


communication between devices over networks.

• Resource Sharing: Enables multiple systems


to share files, devices, and resources.

• Internet Connectivity: Supports protocols like


TCP/IP for web access and data exchange
Resource Allocation

• Fair Distribution: Ensures efficient allocation


of resources like CPU, memory, and devices.

• Load Balancing: Distributes workload to avoid


bottlenecks and maximize efficiency.

• Priority Management: Prioritizes tasks based


on importance and urgency.
Error Detection and Handling
• Error Reporting: Identifies hardware and
software errors.

• Recovery Mechanisms: Takes corrective


actions to maintain system stability.

• Logging: Records error details for diagnosis


and troubleshooting.
Support for Application
Software
• APIs (Application Programming Interfaces):
Provides standard libraries and frameworks for
developers.

• Execution Environment: Ensures applications


run consistently across different hardware
configurations.
Multitasking and Time-
Sharing

• Task Switching: Switches between tasks to


give an illusion of simultaneous execution.

• Time-Sharing: Allocates small time slices of


CPU to multiple users or processes in a shared
system.
• Types of Operating System
Single-User Operating
System
• Description: Supports only one user at a time.

• Key Features:
• Simple interface and limited multitasking.

• Examples: MS-DOS, early versions of macOS.

• Use Case: Personal computers and standalone


devices.
Multi-User Operating System

• Description: Allows multiple users to use the


system concurrently.

• Key Features:
• Provides user accounts and permissions.

• Manages system resources for multiple users.

• Examples: UNIX, Windows Server.


• Use Case: Servers, mainframes.
Multiprocessing Operating
System
• A multiprocessing operating system is designed to
support multiple processors (or CPUs) working
simultaneously on a single system.

• It enhances the system's performance, reliability, and


efficiency by allowing multiple tasks or processes to run
in parallel, utilizing the available processors.
• E.g. Linux, UNIX, Windows 2000, macOS
Multitasking Operating System

• A multitasking operating system allows a


computer to perform multiple tasks or
processes simultaneously.

• It ensures that the CPU is utilized efficiently by


switching between tasks so that users can
execute several programs concurrently.

• E.g. Linux, UNIX, Windows, macOS, Android


Multithreading Operating System

• A multithreading operating system is


designed to allow a process to be divided into
smaller units called threads, which can execute
independently and concurrently.

• These threads share the same process


resources, such as memory and file descriptors,
but execute different parts of the program.

• E.g. Linux, UNIX, Windows, macOS,


Android
Real-Time Operating System (RTOS)
• Description: Ensures tasks are completed within strict
time constraints.
• Types:
• Hard RTOS: Critical tasks must meet deadlines (e.g.,
medical systems, avionics).
• Soft RTOS: Deadlines are preferred but not
mandatory (e.g., multimedia systems).
• Key Features:
• High reliability and predictability.
• Minimal latency in response.
• Examples: FreeRTOS.
• Use Case: Embedded systems, robotics, automotive
systems.
Time-Sharing Operating System

• Description: Allows multiple users to access


the system simultaneously by sharing CPU
time.
• Key Features:
• Uses time slices for task switching.

• Ensures fairness and responsiveness for


multiple users.
• Examples: UNIX,
• Use Case: Multi-user systems like university
servers or shared workstations.
• Operating System Services
User Interface (UI)
• The User Interface (UI) is a critical
operating system service that enables
users to interact with the system and
perform tasks. It acts as a bridge between
the user and the underlying
hardware/software components of the
operating system
Types of User Interfaces in
Operating Systems
1. Command-Line Interface (CLI):
1. Description: A text-based interface where users input
commands directly to perform specific tasks.
2. Characteristics:
1. Lightweight and efficient.
2. Requires knowledge of commands and syntax.
3. Commonly used by advanced users,
administrators, and developers.
3. Examples:
1. Linux terminal.
2. Windows Command Prompt.
3. macOS Terminal.
1. Graphical User Interface (GUI):
1. Description: A visual-based interface
featuring windows, icons, menus, and
pointers (WIMP).
2. Characteristics:
1. User-friendly and intuitive.
2. Allows interaction through mouse clicks, touch, or
gestures.
3. Requires more system resources compared to CLI.

3. Examples:
1. Windows Desktop Environment.
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)

• ensures programs (applications or processes)


are loaded, executed, and terminated efficiently.
This service allows users and applications to
request the execution of programs, providing
the necessary environment for them to run
effectively.
I/O operations
⚫ A running program may require I/O, which may
involve a file or an I/O device

⚫ manages input and output operations between


the user, system applications, and hardware
devices.

⚫ This service ensures smooth and efficient data


transfer between the system's components,
abstracting the complexities of hardware
interactions.
Techniques for I/O Operations
1. Programmed I/O:
1. The CPU actively polls the device to check if it's ready
for data transfer.
2. Simple but inefficient for high-speed devices.
2. Interrupt-Driven I/O:
1. The device interrupts the CPU when it’s ready for
data transfer.
2. More efficient as the CPU can perform other tasks in
the meantime.
3. Direct Memory Access (DMA):
1. The device directly transfers data to/from memory
without involving the CPU for every byte.
2. Used for high-speed data transfers (e.g., disk I/O,
network I/O).
File-system manipulation
• Programs need to read and write files and directories,
create and delete them, search them, list file
Information, permission management.

• manages the creation, organization, access, and


manipulation of files and directories on storage devices.
It provides users and applications with a structured way
to store, retrieve, and modify data while abstracting the
complexities of physical storage.
Features of File-System Manipulation Service

1. File and Directory Management:


1. Handles the creation, deletion, and organization of
files and directories.
2. Manages directory structures, such as flat,
hierarchical, or networked models.
2. File Access:
1. Provides mechanisms to open, read, write, and close
files.
2. Supports sequential and random (direct) file access.
3. File Permissions:
1. Enforces access control, ensuring only authorized
users can read, write, or execute files.
2. Includes ownership and group-based permissions.
1. File Metadata Management:
1. Maintains metadata like file name, size, type, location,
timestamps (creation, modification, access), and
permissions.

2. File Allocation:
1. Allocates disk space for files efficiently, managing
fragmentation and ensuring reliability.
2. Supports various allocation methods (e.g.,
contiguous, linked, indexed).
Communication
• operating system facilitates the exchange
of information between processes, either
on the same system or across different
systems connected by a network.

• It provides the necessary mechanisms


and protocols to ensure reliable, secure,
and efficient data transfer.
Types of Communication
1. Inter-Process Communication (IPC):
1. Communication between processes running on the
same system.
2. Used for data sharing, synchronization, and
coordination.
3. Methods include:
1. Shared Memory: Processes share a common
memory region for data exchange.
2. Message Passing: Processes send and receive
messages through channels.
3. Pipes: Unidirectional or bidirectional data channels
between processes.
4. Sockets: Network-based communication
interfaces for local or remote communication.
1. Network Communication:
1. Communication between processes or systems
across a network.
2. Applications include file sharing, email, and web
browsing.
Error Detection

• operating system (OS) ensures the


reliability and stability of a system by
identifying and responding to errors in
hardware, software, or processes.

• It continuously monitors the system for


faults or anomalies, reports them, and, in
some cases, takes corrective action.
Key Features of the Error Detection
Service
1. Continuous Monitoring:
1. Tracks hardware and software operations in real time
to detect malfunctions.
2. Error Reporting:
1. Logs errors for further analysis and troubleshooting.
2. Notifies the user or administrator about critical issues.
3. Error Handling:
1. Attempts to recover from errors (e.g., restarting a
failed process or retrying a failed operation).
2. Prevents system crashes or data corruption.
4. System Integrity Checks:
1. Ensures data consistency in memory, storage, and
communication.
Types of Errors Detected by the OS
1. Hardware Errors:
1. Examples:
1. Memory failures (e.g., faulty RAM or address
errors).
2. Disk errors (e.g., bad sectors or drive failures).
3. CPU overheating or malfunction.
2. Software Errors:
1. Examples:
1. Division by zero.
2. Null pointer dereferencing.
3. Deadlocks or infinite loops.
1. I/O Errors:
1. Examples:
1. Corrupted data during transfer.
2. Device not responding or unavailable.
2. Network Errors:
1. Examples:
1. Packet loss or corruption.
2. Connection timeouts.
3. Security Errors:
1. Examples:
1. Unauthorized access attempts.
2. Malware activity.

2. .
Services Provided by the OS
• Accounting
– Collect usage statistics
– Monitor performance
– Used for billing purposes
A View of Operating System Services
Operating System Structures
• The structure of an operating system defines
how its components are organized and interact
to perform core tasks such as process
management, memory management, file
handling, and device control.

• Different structures balance performance,


complexity, scalability, and maintainability
based on the system's goals.
Types of Operating System Structures
• 1. Monolithic Structure
• Description:
• All OS components (e.g., process management,
memory management, file systems, and device
drivers) are part of a single, unified program that runs
in kernel mode.
• Components communicate directly through function
calls.
• Advantages:
• High performance due to minimal overhead.
• Simpler and faster system calls.
• Disadvantages:
• Difficult to debug and maintain.
• A failure in one part can crash the entire system.
• Examples:
Layered Structure
• Description:
• The OS is divided into multiple layers, each built on
top of the previous one.
• Layer 0 (hardware) is at the base, and the user
interface is at the topmost layer.
• Advantages:
• Modular design simplifies debugging and
maintenance.
• Fault isolation, as lower layers are shielded from
upper-layer failures.
• Disadvantages:
• Overhead in layer-to-layer communication.
• Difficult to define strict boundaries between layers.
• Examples:
• THE Operating System,
Microkernel Structure
• Description:
• Only the most essential services (e.g., inter-process
communication, basic scheduling, and memory
management) run in kernel mode.
• Non-essential services (e.g., file systems, device
drivers) run in user mode as separate processes.
• Advantages:
• High reliability, as failures in non-kernel components
do not crash the OS.
• Easier to extend or replace components.
• Disadvantages:
• Performance overhead due to frequent context
switching and message passing.
• Examples:
• macOS, Windows NT
Client-Server Structure

• Description:
• The OS is split into a client (user-level processes) and
server (kernel or other system processes).
• The client requests services, and the server provides
them.
• Advantages:
• Good fault isolation.
• Modular and scalable.
• Disadvantages:
• Communication overhead between clients and
servers.
• Examples:
• Distributed systems
Comparison of OS Structures

Aspect Monolithic Layered Microkernel Client-Server

Performance High Moderate Low Moderate

Modularity Low High High High

Reliability Low Moderate High High

Complexity High Moderate High High


Operating System Functions
• Provide User Interface
• Manage Resources
• Run applications
• Support for built in programs
• Control Hardware
Advantages of OS
• Easy to Use
• User Friendly
• Intermediate between Hardware &
Software of the System
• No need to know technical Language
• Platform for all programs
Disadvantages of OS
• If problem occurs in OS may loose all
contains
• Unauthorized User may use the System.
Kernel
• The kernel is the core component of an
operating system (OS).

• It acts as a bridge between hardware and


software, managing system resources and
enabling communication between hardware
components and application programs.

• The kernel operates at the lowest level of the OS


and has full control over the system.
Monolithic Kernel:

1. All OS services (e.g., file systems, drivers, memory


management) run in the kernel space.
2. Provides high performance due to direct
communication between services.
3. Examples: UNIX, Linux.
1. Advantages:
1. High performance.
2. Direct hardware interaction.
2. Disadvantages:
1. A single failure can crash the entire system.
2. Harder to debug and maintain.
Microkernel:
•Only essential services (e.g., process management,
memory management, IPC) run in the kernel.

•Non-essential services (e.g., file systems, drivers) run in


user space.

Advantages:
•High reliability and modularity.
•Easier to extend or update.
Disadvantages:
•Slower performance due to frequent context switching
and message passing.
Shell
• A shell in Linux is a command-line interpreter that provides
a user interface for interacting with the operating system.

• It allows users to execute commands, run scripts, and


manage system resources.

• The shell interprets the commands you type and


communicates with the kernel to perform tasks such as file
manipulation, program execution, and process
management.
• Types of Shells in Linux
• Linux systems support several types of shells, each with
unique features. Some common shells include:
1. Bash (Bourne Again Shell)
1. Default shell in many Linux distributions.
2. Powerful scripting capabilities.
3. Compatible with older Bourne shell scripts.
4. Includes features like command history, tab completion,
and aliases.

2. Zsh (Z Shell)
1. Popular among developers for its customizability.
2. Supports advanced features like enhanced tab
completion and themes.
1. Ksh (Korn Shell)
1. Combines features of the Bourne shell and C shell.
2. Known for robust scripting capabilities.
2. Fish (Friendly Interactive Shell)
1. Designed for user-friendliness.
2. Colorful syntax highlighting.
3. Offers suggestions based on command history.
3. Tcsh (TENEX C Shell)
1. Enhanced version of the C shell (csh).
2. Popular for its scripting and programming-style
syntax.
System calls
• System calls are interfaces provided by the operating system
kernel that allow user-space applications to request services
or interact directly with hardware resources.

• They act as a bridge between the user-space (where


applications run) and the kernel-space (which has access to
system resources such as memory, hardware, and file
systems).
Purpose of System Calls

• System calls are used to:


1. Perform operations that require access to hardware
resources (e.g., read/write files, allocate memory).

2. Manage processes (e.g., create, terminate, or


communicate between processes).

3. Access kernel-level services while ensuring security


and stability.
Types of System calls

1. Process Control System Calls


These system calls manage the execution and behavior of
processes.
Examples:
•fork(): Creates a new process.
•exec(): Replaces the current process image with a new one.
•wait(): Suspends execution until a child process terminates.
•exit(): Terminates a process.
•kill(): Sends a signal to terminate or control a process.
•getpid() / getppid(): Retrieves the process ID or parent process
ID.
2. File Managemnt System Calls
•Used to create, manipulate, and manage files and directories.
•Examples:
•open(): Opens a file for reading, writing, or both.
•read(): Reads data from a file.
•write(): Writes data to a file.
•close(): Closes an open file.
•stat() / fstat(): Retrieves information about a file (e.g., size,
permissions).
•mkdir(): Creates a directory.
3. Device Management System Calls
•Enable interaction with hardware devices through their
associated device drivers.
•Examples:
•ioctl(): Sends control commands to a device.
•read() / write(): Transfers data to/from a device.
•open() / close(): Opens or closes a device for use.
4. Information Maintenance System Calls
•Provide mechanisms to gather and modify system and process
information.
•Examples:
•getcwd(): Retrieves the current working directory.
•gettimeofday(): Gets the current time.
•settimeofday(): Sets the system time.
•uname(): Retrieves system information (e.g., OS name,
version).
•getpid(): Gets the process ID.
•setuid() / getuid(): Sets or gets the user ID of a process.
5. Communication System Calls
Facilitate inter-process communication (IPC), allowing
processes to exchange information.
Examples:
•pipe(): Creates a pipe for unidirectional data flow between
processes.
•shmget(): Allocates shared memory.
•shmat() / shmdt(): Attaches or detaches shared memory
to/from a process.
•msgget(): Allocates a message queue.
•sendmsg() / recvmsg(): Sends or receives messages
through sockets.
•socket(): Creates a network communication endpoint.
•connect(): Establishes a connection to a remote socket.
6. Protection and Security System Calls
Control access to resources and manage permissions to
ensure system security.
Examples:
•chmod(): Changes file permissions.
•chown(): Changes file ownership.
•umask(): Sets default permissions for new files.
•setuid() / setgid(): Changes the user or group ID.
•getuid() / getgid(): Retrieves the user or group ID.

You might also like