Functions of OS

This topic speaks about the functions of the os

Author:Author ImageZachary Kublalsingh

Edu Level: Unit2

Date: Aug 8, 2024

⏱️Read Time:



Interrupt Mechanism:

An interrupt is a signal sent to the CPU by hardware or software, indicating that an event requires immediate attention. It temporarily suspends the current process and allows the operating system to handle the event.

How it works: 1. Signal Reception The CPU receives an interrupt signal from a source (e.g., I/O device, timer, software).

  1. Interrupt Handling The CPU pauses the current process, saves its state (registers, program counter), and transfers control to a specific program called an interrupt handler.
  2. Interrupt Service Routine (ISR) The ISR addresses the event that caused the interrupt (e.g., reading data from a disk, servicing a timer).
  3. Return to Process Once the ISR completes, the CPU restores the state of the interrupted process and resumes its execution.

Deadlock:

a situation where two or more processes are stuck waiting for each other to release resources, causing a standstill in the system.

Conditions for Deadlock: • Mutual Exclusion Processes hold resources exclusively.

• Hold and Wait The process holds resources while waiting for others.

• No Preemption The Resources cannot be forcibly taken away from processes.

• Circular Wait A cycle of resource dependencies exists among processes.

Deadlock Resolution • Prevention Avoid deadlock conditions through resource allocation strategies or careful process design.

• Avoidance Dynamically check for potential deadlocks and take actions to prevent them.

• Detection and Recovery Detect deadlocks after they occur and recover by terminating processes or revoking resources.

Process Control Block (PCB)

A data structure maintained by the operating system for each process, containing essential information about its current state, resources, and execution.

Key Elements:

  1. Process ID: Unique identifier for the process.
  2. Process State: Current state (running, ready, blocked).
  3. Program Counter: Memory address of the next instruction to be executed.
  4. Registers: Values of CPU registers.
  5. Memory Allocation: Information about memory areas assigned to the process.
  6. Open Files: List of files opened by the process.
  7. I/O Status: Information about pending I/O operations.
  8. Accounting Information: Data about resource usage (CPU time, memory usage).

Scheduling Algorithms

  1. Pre-emptive Algorithms Shortest-Job-First (SJF) Always selects the process with the shortest remaining execution time to run next. Can prioritize short tasks, but requires knowing the job length beforehand.

Round Robin

Assigns a fixed time slice (quantum) to each process in a circular fashion. This ensures fairness and responsiveness, but can introduce overhead for frequent context switching.

  1. Non-pre-emptive Algorithms First Come First Serve (FCFS) Processes are executed in the order they arrive. Simple but can lead to starvation for longer processes.

Shortest-Job-First (SJF)

Non-pre-emptive version prioritizes shortest jobs but only at process arrival or completion.

Functions of the OS

  1. Memory Management: • Virtual Memory Creates illusion of larger memory using disk space.

• Paging Swaps memory pages between RAM and disk for efficient usage.

• Thrashing Excessive paging that degrades performance, avoid by adjusting memory usage.

  1. File Management: • Directories/Folders Organize files hierarchically with metadata.

• Files Collections of data with functions for creation, manipulation, and access.

• File Compression Reduces file size for storage and transmission.

  1. Security (of files): • User IDs/Passwords Authenticate users and control access.

• Access Control Lists (ACLs) Specify permissions for individuals or groups.

• File Encryption Protects sensitive data by scrambling it.

• Activity Logs Track file access and modifications for auditing purposes.

  1. User Interfaces: • Command Prompt Text-based interface for interacting with OS via commands.

• Menu Hierarchical structure for selecting options.

• Graphical User Interface (GUI) Visual interface with windows, icons, and pointers for user interaction.

  1. Device Management: • Device Drivers: Software programs enabling communication between OS and hardware devices.

• Interrupts: Signals from devices alerting OS to events or service requests.

Networking

Network Management: • User Accounts: Individual profiles that control access to network resources and track activity.

Access Logs: Records of who accessed what resources, when, and from where, for security and troubleshooting purposes.

Networking Protocols (TCP/IP)

TCP/IP (Transmission Control Protocol/Internet Protocol): The foundational protocol suite for the internet and most modern networks. It defines how data is divided, addressed, transmitted, routed, and reassembled.

Dont't forget to check out our Instagram Page!
edukatte_tt