0% found this document useful (0 votes)
27 views21 pages

Os Study Material - UNIT 1

The document provides an overview of operating systems, defining their functions, types, and structures. It discusses key concepts such as process management, memory hierarchy, interrupts, and system calls, as well as various operating system examples like Windows and Linux. Additionally, it outlines the architecture of computer systems and the role of Direct Memory Access (DMA) in improving data transfer efficiency.

Uploaded by

sathiya.set
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views21 pages

Os Study Material - UNIT 1

The document provides an overview of operating systems, defining their functions, types, and structures. It discusses key concepts such as process management, memory hierarchy, interrupts, and system calls, as well as various operating system examples like Windows and Linux. Additionally, it outlines the architecture of computer systems and the role of Direct Memory Access (DMA) in improving data transfer efficiency.

Uploaded by

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

UNIT- I OPERATING SYSTEMS OVERVIEW

Introduction to Operating System - Computer System Organization, Architecture -


Operating system structure - OS Operations - Computing Environments - OS Services -
System Calls - System Boot - Process - Threads – Multithreading

1. INTRODUCTION TO OPERATING SYSTEM


Definition of OS
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.

Examples of Operating Systems:

 Windows
 macOS
 Linux
 Android
 iOS

Functions of an OS:

1. Process Management – Handles execution, scheduling, and termination of programs.


2. Memory Management – Allocates and deallocates memory for processes.
3. File System Management – Organizes, stores, and retrieves data efficiently.
4. Device Management – Controls hardware devices like printers and disks.
5. Security & Access Control – Protects data and resources from unauthorized access.

Types of Operating Systems:

 Batch OS – Executes jobs in batches without user interaction.


 Time-Sharing OS – Allows multiple users to share system resources efficiently.
 Real-Time OS – Processes tasks within a strict time limit (e.g., medical or industrial
systems).
 Distributed OS – Manages multiple interconnected computers as a single system.
 Embedded OS – Designed for specialized devices like smartphones and IoT gadgets.
1. Computer System Organization and Architecture

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

Timer Generated by a timer within the processor.

I/O Generated by an I/O controller, to signal normal completion of an


operation

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:

 An interrupt triggers a number of events, both in the processor hardware and


in software. When an I/O device completes an I/O operation, the following
hardware events occurs:

 Device sends an interrupt signal.


 CPU finishes the current instruction.
 CPU detects the interrupt and acknowledges it.
 CPU saves its current state (PSW, program counter).
 CPU loads the interrupt handler address.
 CPU saves register values before handling the interrupt.
 Interrupt handler executes.
 CPU restores saved register values.
 CPU restores PSW and program counter, resuming the previous task.

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.

Nested interrupt processing:


A second approach is to define priorities for interrupts and to allow an interrupt of
higher priority to cause a lower- priority interrupt handler to be interrupted.

MEMORY HIERARCHY
Key Considerations in Memory Design:

 Performance: Memory must match processor speed to avoid delays during


instruction execution.
 Cost: Memory cost should be balanced with other components.
 Tradeoffs: Memory has three key characteristics—capacity, access time, and cost—
each influencing the others:
o Faster access = higher cost per bit
o Greater capacity = lower cost per bit but slower access speed

Types of Memory Hierarchy:


1. External (Secondary) Memory:
o Examples: Magnetic Disk, Optical Disk, Magnetic Tape
o Accessible by the CPU through an I/O module, typically slower and with
larger capacity.
2. Internal (Primary) Memory:
 Registers: Fastest, smallest storage, storing frequently used data (16-
64 bits).
 Cache Memory: Fast, small memory close to the CPU, stores recently
used data from main memory to reduce access time.
 Main Memory (RAM): Larger storage, slower than cache. It stores
data and instructions currently in use.

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:

o Circular plates made of metal, plastic, or magnetized material, providing high-


speed data storage.

Magnetic Tape:

o Magnetic-coated plastic film, used for data backup, with slower access times.

CACHE MEMORY:

 A CPU cache is a Cache used by the central processing unit (CPU) of a


computer to reduce the average time to access data from the main memory.
 The cache is a smaller, faster memory which stores copies of the data from
main memory locations. Most CPUs have different independent caches,
including instruction and data caches, where the data cache is usually organized
as a hierarchy of more cache levels (L1, L2, etc.)
 The cache memory is small, fast memory between the processor and main
memory.

CACHE PRINCIPLES:

 Cache memory provide memory access time similar to that of fastest


memories available and at the same time support a large memory size that has
the price of less expensive types of semiconductor memories.
 The cache contains a copy of a portion of main memory.
 When the processor attempts to read a byte or word of memory, a check is
made to determine if the byte or word is in the cache.
 If so, the byte or word is delivered to the processor.(CACHE HIT)
 If not, a block of main memory, consisting of some fixed number of bytes,
is read into the cache and then the byte or word is delivered to the processor.
(CACHE MISS)

 In the above diagram the Main memory consists of up to 2n addressable words,


with each word having a unique n-bit address.
 This memory is considered to consist of a number of fixed length blocks of K
words each. That is, there are M= 2n/K blocks.
 Cache consists of C slots of K words each, and the number of slots is considerably
less than the number of main memory blocks (C << M).
 If a word in a block of memory that is not in the cache is read, that block is
transferred to one of the slots of the cache.
 Each slot includes a tag that identifies which particular block is currently being
stored. The tag is usually some number of higher-order bits of the address and
refers to all addresses that begin with that sequence of bits.

READ OPERATION IN A CACHE:

 The processor generates the real address, RA, of a word to be read.

 If the word is contained in the cache, it is delivered to the processor. Otherwise,


the block containing that word is loaded into the cache and the word is delivered
to the processor.
CACHE DESIGN:
The key elements of cache design includes,
 Cache size
 Block Size
 Mapping Function
 Replacement algorithm
 Write policy

DIRECT MEMORY ACCESS


Direct Memory Access (DMA) is a method that allows peripherals (such as disk drives,
network cards, or sound cards) to communicate directly with the computer’s memory without
involving the CPU. This improves the overall efficiency of data transfer between devices and
memory, as it frees up the CPU to perform other tasks.
Key Features of DMA:

1. Data Transfer Without CPU Involvement:


o Normally, the CPU handles all data transfers between memory and
peripherals. With DMA, the peripheral can directly transfer data to/from
memory without the CPU’s intervention, allowing faster data transfer.
2. DMA Controller (DMAC):
o A DMA controller is responsible for managing the data transfer between the
device and the memory. It controls when and how data should be transferred,
without interrupting the CPU's operation.

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

 A basic design used for small,simple system.


 This architecture has minimal components and limited functionalities.
 It is easy to design and develop.
 Eg-MS-DOS(Microsoft Disk Operating Systems)

Monolith Structure

 The central piece of code called kernel.


 All the components are integrated and runs in a single,large block of code in kernel
space.
 The Kernel is responsible for all major operations such as memory management,
device management, file management.
 Eg-Linux,Unix
Micro-Kernel Structure

 In Monolithic structure, there was single kernel, in micro-kernel, we have multiple


kernels each one specialized in particular service.
 Each microkernel is developed independent to the other one and makes system more
stable.
 If one kernel fails the operating sytem will keep working with other kernel's
functionalities.
 Eg-Minix,QNX

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 Calls in Operating Systems

System Call

 A System Call is a request made by a program to the OS kernel for performing


privileged operations, such as accessing hardware or managing processes.
 It acts as a bridge between user-level applications and the OS.
 Mode switching:
o User Program → System Call → Kernel Mode → OS Service Execution
→ Return Result → User Mode
o The OS executes the requested service and returns the result.

Types of System Calls

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.

Working of System calls

 User programs run in user mode, OS runs in kernel mode.


 System calls allow user programs to request OS services.
 A context switch occurs to switch from user to kernel mode.
 The kernel performs the requested operation and checks permissions.
 The CPU switches back to user mode, returning the result.
 Common system calls: fork(), open(), read(), mmap().
 Example: read() fetches data from a file to the user program.

Operating System Services/operations/functions

 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.

3. File System Management:


o Provides services for file creation, deletion, reading, and writing.
o Organizes and manages file directories.
o Enforces file permissions and access control.
✅ Example:
o Opening or saving a file in an application.
o Managing folders and their permissions.

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.

6. Security and Access Control:


o Provides user authentication and access control.
o Protects data through file permissions and encryption.
o Prevents unauthorized access to system resources.
✅ Example:
o Logging in with a username and password.
o Setting file read/write permissions.

7. Error Detection and Handling:


o Monitors the system for hardware and software errors.
o Generates error messages and logs for troubleshooting.
o Takes corrective actions to prevent crashes.
✅ Example:
o Displaying an error message when a program crashes.
o Logging system failures for debugging.

8. Networking and Communication:


o Provides services for network communication and data transfer.
o Uses protocols (TCP/IP) for network interactions.
o Enables remote access and file sharing.
✅ Example:
o Accessing the internet.
o Sharing files between computers over a network.

9. User Interface (UI):


o Offers Graphical User Interface (GUI) or Command-Line Interface (CLI).
o Allows users to interact with the system easily.
o GUI uses visual elements, while CLI uses text-based commands.
✅ Example:
o Windows Explorer (GUI).
o Linux Terminal (CLI).

System Booting

 Booting is the process of starting up a computer or device.


 It involves loading the operating system from storage into the system's memory
(RAM) to make the system ready for use.

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:

1. Power is applied to the system.


2. BIOS/UEFI performs POST to check hardware functionality.
3. BIOS/UEFI loads the bootloader (e.g., GRUB).
4. Bootloader loads the operating system into memory.
5. OS initialization begins (loading system services, drivers, etc.).
Process

 A process in an operating system (OS) is a program in execution.


 It is an active entity that has a state, resources, and performs tasks or operations.
 Each process has its own address space and runs independently, isolated from other
processes.
Example: Running a web browser or text editor as separate processes.

Process States

 New − The process is being created.


 Running − In this state the instructions are being executed.
 Waiting − The process is in waiting state until an event occurs like I/O operation
completion or receiving a signal.
 Ready − The process is waiting to be assigned to a processor.
 Terminated − the process has finished execution.
Thread

 A thread is the smallest unit of execution within a process.


 Threads within the same process share the same memory space and resources, making
them lightweight compared to processes.
 Threads are used to perform specific tasks concurrently within the same process.
 Example: A web browser may have separate threads for rendering a webpage and
handling user input.

User thread and Kernel threads User threads

 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

 Supported directly by the OS.


 Thread creation , management and scheduling are done in kernel space.
 Slow to create and manage.
 When a kernel thread performs a blocking system call ,the kernel schedules another
thread in the application for execution.
 Example: Windows NT, Windows 2000 , Solaris 2,BeOS and Tru64 UNIX support
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:

 Many user-level threads mapped to single kernel thread.


 Used on systems that does not support kernel threads.

2. One-to-One:

 Each user-level thread maps to a kernel thread.


 Examples- Windows 95/98/NT/2000, - OS/2

3. Many-to-Many Model:

 Allows many user level threads to be mapped to many kernel threads.


 Allows the operating system to create a sufficient number of kernel threads.
 Solaris 2
 Windows NT/2000
Threading Issues:
 fork() and exec() system calls.
 Thread cancellation.
There are two types of cancellation
1. Asynchronous Cancellation
2. Deferred Cancellation
 Signal handling
 Thread pools\
 Thread specific data

You might also like