Os Study Material - UNIT 1
Os Study Material - UNIT 1
Windows
macOS
Linux
Android
iOS
Functions of an OS:
One or more CPUs, device controllers connect through common bus providing access to
shared memory.
i) Processor: It Controls the operation of the computer and performs its data
processing functions. When there is only one processor, it is often referred to as the
central processing unit.
ii) Main memory: It Stores data and programs. This memory is typically volatile;
that is, when the computer is shut down, the contents of the memory are lost. Main
memory is also referred to as real memory or primary memory.
iii) I/O modules: It moves data between the computer and its external environment.
The external environment consists of a variety of devices, including secondary
memory devices (e. g., disks), communications equipment, and terminals.
iv) System bus: It provides the communication among processors, main memory, and
I/O modules.
INSTRUCTION EXECUTION:
A program to be executed by a processor consists of a set of instructions
stored in Memory. The instruction processing consists of two steps.
The processor reads (fetches) instructions from memory one at a time
(fetch stage)
Execute the instruction.(execute stage)
INTERRUPTS:
An interrupt is defined as hardware or software generated event external to the
currently executing process that affects the normal flow of the instruction
execution.
Interrupts are provided primarily as a way to improve processor utilization
Types
Software Interrupts
Hardware Interrupts
Classes of Interrupts:
Program Generated by some condition that occurs as a result of an instruction
execution, such as arithmetic overflow, division by zero
Hardware failure Generated by a failure, such as power failure or memory parity error.
Program Flow of Control without and with Interrupts
Interrupts and the Instruction Cycle:
When the external device becomes ready to accept more data from the
processor, the I/O module for that external device sends an interrupt request
signal to the processor.
The processor responds by suspending operation of the current program. This
process of branching off to a routine to service that particular I/O device is
known as an interrupt handler and resuming the original execution after the
device is serviced.
Interrupt Processing:
Multiple Interrupts:
One or more interrupts can occur while an interrupt is being processed. This is called
as Multiple Interrupts.
Two approaches
Sequential interrupt processing
Nested interrupt processing
Sequential interrupt processing:
It handles interrupts one by one, in the order they arrive. The CPU stops its current
task, processes the interrupt, and then resumes the previous task.
MEMORY HIERARCHY
Key Considerations in Memory Design:
Types of RAM:
Static RAM (SRAM): Fast access, stores data in flip-flops, used in cache memory.
Dynamic RAM (DRAM): Slower, stores data as charge on capacitors, requires
refreshing, more memory cells per unit area.
Secondary Storage:
o Hard Disk Drives (HDD) and Solid-State Drives (SSD): Non-volatile, large
capacity, slower access, and cost-effective compared to RAM.
Magnetic Disk:
Magnetic Tape:
o Magnetic-coated plastic film, used for data backup, with slower access times.
CACHE MEMORY:
CACHE PRINCIPLES:
Types of DMA:
o Burst Mode: Data is transferred in large chunks, and the CPU is not involved
until the entire transfer is complete.
o Cycle Stealing: The DMA controller temporarily "steals" a cycle from the
CPU to transfer one word of data at a time. The CPU can continue execution
in between these cycles.
o Block Mode: The DMA controller transfers a block of data in one go, and the
CPU is only involved when the entire transfer is complete.
o Transparent Mode: The DMA controller transfers data only when the CPU is
not using the memory, making it less disruptive.
Advantages of DMA:
Faster Data Transfers: Since the CPU is not involved, the data can be transferred at
higher speeds.
Reduced CPU Load: The CPU can perform other tasks while data is being
transferred, improving overall system performance.
Efficient Resource Utilization: DMA allows peripherals to operate independently,
improving system throughput.
Structure of OS
Structure of OS depends on how the various components of the OS are interconnected and
how it is communicated together.
Types
Simple Structure
Monolith Structure
Micro-Kernel Structure
Exo-Kernel Structure
Layered Structure
Modular Structure
Simple Structure
Monolith Structure
Exo-Kernel Structure
The aim of this design was to keep Kernel size minimal while allowing the
application programs to manage hardware resources directly.
The purpose of removing abstraction of operating system for hardware resources was
to enable application programmer to write high performance code while exo-kernel
handles other operations.
Eg-XOK
Layered Structure
In Layered Structure, the system is divided into different layers, where each layer is
responsible for a specific function.
The lower layer manages hardware, basic functions and higher manages user
interaction, application program.
Each layer communicates only with the adjacent layers(either above or below)
Fault in one layer are less likely to affect the other alyers
Eg:Multics OS
Modular Structure
Focusing on dividing the system into independent modules that can be reused,
replaced or updated without affecting other parts of the system.
New features can be added without altering the entire OS.
Eg-Basic linux OS System.
System Call
1. Process Control:
o Process: A program in execution.
o Create new processes or terminate existing ones.
o Load and execute programs within a process's space.
o Schedule processes
o Wait for a process to complete or signal upon its completion
o Examples:
fork() → Creates a new process.
exec() → Executes a new program.
exit() → Terminates a process.
2. File Management:
o Reading from or writing to files.
o Opening and closing files.
o Deleting or modifying file attributes.
o Moving or renaming files.
o Examples:
open() → Opens a file.
read() → Reads data from a file.
write() → Writes data to a file.
close() → Closes a file.
3. Device Management:
o Manages hardware devices (e.g., printers, disks).
o Requesting device access and releasing it after use..
o Reading from or writing to devices.
o Mapping logical device names to physical devices.
o Examples:
open() → Opens a device.
read() / write() → Reads from or writes to a device.
ioctl() → Controls device parameters
4. Information Maintenance:
o Retrieves or sets system information.
o Retrieve or modify various system attributes.
o Set the system date and time.
o Query system performance metrics.
o Examples:
getpid() → Gets the process ID.
gettimeofday() → Retrieves the current time.
uname() → Retrieves OS information.
5. Communication:
o Facilitates Inter-Process Communication (IPC) and network
communication.
o Sending or receiving messages between processes.
o Synchronizing actions between user processes.
o Examples:
pipe() → Creates a communication channel.
shmget() → Allocates shared memory.
send() / recv() → Sends and receives data over a network.
An Operating System (OS) is system software that manages computer hardware and
software resources while providing services to users and applications.
It acts as an interface between users and the computer hardware.
Services provided by OS
1. Program Execution:
o The OS loads and executes user programs.
o Ensures proper allocation of CPU and memory resources.
o Manages the execution flow and program termination.
o Returns the exit status of the program after execution.
✅ Example: Running an application like MS Word or executing a Python
script.
2. I/O Operations:
o Manages input and output devices (e.g., keyboard, mouse, printer).
o Performs reading and writing operations from/to devices.
o Uses buffering and caching to optimize performance.
✅ Example:
o Reading data from a file.
o Printing a document using a printer.
4. Process Management:
o Handles the creation, execution, and termination of processes.
o Manages CPU scheduling to allocate processing time efficiently.
o Provides process synchronization and communication services.
✅ Example:
o Running multiple applications concurrently (multitasking).
o Switching between running programs.
5. Memory Management:
o Allocates and deallocates RAM to running processes.
o Provides virtual memory to extend physical memory.
o Ensures memory protection by preventing unauthorized access.
✅ Example:
o Running a large program that uses virtual memory.
o Multitasking multiple applications without running out of physical memory.
System Booting
Types of Booting:
Cold Boot (Hard Boot):
o Occurs when the computer is turned on from a completely powered-off state.
o The computer performs a Power-On Self Test (POST), checks hardware
components, and loads the operating system.
Warm Boot (Soft Boot):
o Occurs when the system is restarted without powering off (e.g., pressing the
reset button or selecting "Restart").
o The system bypasses hardware initialization and directly reloads the OS.
Working of Booting:
Process States
Supported above the kernel and implemented by a thread library at the user level.
Thread creation, management and scheduling are done in user space.
Fast to create and manage
When a user thread performs a blocking system call, it will cause the entire process to
block even if other threads are available to run within the application.
Example: POSIX Pthreads, Mach C-threads and Solaris 2 UI-threads.
Kernel threads
MULTITHREADING MODELS
Multithreading Models in an operating system refer to the ways in which threads are
managed, scheduled, and executed in a system.
There are different models to handle how user-level threads are mapped to kernel-
level threads, and these models can affect performance, efficiency, and system
responsiveness.
1. Many-to-One
2. One-to-One
3. Many-to-Many
1. Many-to-One:
2. One-to-One:
3. Many-to-Many Model: