Operating System Lecture1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

Operating Systems

Lecture 2
Agenda for Today
 Hardware (I/O, memory, and CPU)
protection
 Operating system components and
services
 System calls
 Operating system structures

May 15, 2024


Hardware Protection
 Dual-Mode Operation
 I/O Protection
 Memory Protection
 CPU Protection

May 15, 2024


I/O Protection
 All I/O instructions are privileged
instructions

 Must ensure that a user program


could never gain control of the
computer in monitor mode

May 15, 2024


Memory Protection
 Address space may also denote a range of physical or virtual
addresses which can be accessed by a processor.
 While a Process Address space is set of logical addresses that a
process can access legally access
 Must provide memory protection outside the address space of a
process.
 In order to have memory protection, add two registers that determine
the range of legal addresses a program may access:
 Base register – holds the smallest legal physical memory address.
 Limit register – contains the size of the range
 Memory outside the defined range is protected.
Use of Base and Limit
Register

May 15, 2024


Hardware Support

Usually this error is known as Segmentation Fault


May 15, 2024
CPU Protection
 CPU Scheduling:managing the execution of multiple processes
or tasks on a computer's (CPU)
• It involves deciding which process should execute next
and how much CPU time should be allocated to each
process

 Timer – A timer is set to interrupt the computer after a


specified period
• When timer reaches the value 0, an interrupt occurs.ISR is executed
to switch CPU to another process
• The ISR's purpose is to manage the process of switching the CPU to
another process.

May 15, 2024


• Another use of the timer is to compute the current time
• Example:
• Let's say it's 1:00 PM, and the timer interrupts every second.
• After 1427 interrupts, the computer figures out that it's now 1:23:47 PM.

• In simpler terms, the timer helps the computer keep time by


counting seconds, but sometimes it needs a backup clock to
ensure the time is accurate, especially when it's busy with
other things.
OS Components
 Process management: Running multiple programs
(like a web browser, music player, and word processor) at
the same time without them interfering with each other.
 Main memory management: Keeping track of
which apps are open
 Secondary storage management: Storing files
on your computer's hard drive, like photos, documents,
and videos.
 I/O system management (buffer cache
management): Loading frequently used data (like a
webpage) into a temporary storage area (cache) to make it
May 15, 2024
quickly accessible.
Filemanagement: Organizing and storing files in folders,
Protection system: Setting permissions so only
authorized users can access certain files or features, like a
password protecting a folder.
Networking:Connecting your computer to the internet or
a network to share information, like sending emails or
browsing websites.
Command-line interpreter (shells):Using a text-
based interface to interact with the computer by typing
commands
Operating System Services
Services for user and user’s programs:
• Program Execution:
• The OS loads programs into memory and manages their execution.
• It allocates resources, schedules tasks, and monitors program progress.
• I/O Operations:
• Handles input and output operations for devices like keyboards, monitors, and
printers.
• Manages data transfer between programs and external devices.
• File System Manipulation:
• Provides services to create, delete, read, write, and manipulate files.
• Organizes and maintains the file structure on storage devices.
• Communications between Processes/Users (Concurrent Processes):
• Facilitates communication and coordination between multiple processes running
concurrently.
• Error Detection and Handling:
• Monitors system activities for errors and faults.
Operating System Services …
Services for efficient system operation:
• Resource Management:
• Allocates and deallocates resources such as CPU time, memory, and I/O devices.
• Ensures optimal utilization to enhance system performance.
• Accounting:
• Tracks resource usage by different users and processes.
• Keeps track of CPU time, memory usage, disk I/O, and other resource metrics.
• Protection:
• Implements security measures to prevent unauthorized access and data
corruption.
• Defines access controls and permissions for users and processes.
OS Kernel
• A Kernel is a computer program that is the heart and core of an
Operating System
• Since the Operating System has control over the system so, the Kernel
also has control over everything in the system
• It is the most important part of an Operating System
• Whenever a system starts, the Kernel is the first program that is
loaded after the bootloader because the Kernel has to handle the rest
of the thing of the system for the Operating System.
• The Kernel remains in the memory until the Operating System is shut-
down.
General Structure of Computer
System
Users
Applications
Operating System API, AUI:
(Application Programming Interface):
Serves as an interface between applications and the operating system.
AUI (Application User Interface):
Represents the user-facing part of the operating system.
Includes graphical user interfaces (GUIs) or command-line interfaces (CLIs).
Allows users to interact with the computer system, launch applications, and manage files.
Real work is done in the kernel
• Operating System kernal:
• Manages hardware resources and provides essential services to user
programs.
• Handles tasks like process scheduling, memory management, and
device control.
• Interacts directly with the computer hardware.
• Computer Hardware
Entry Points into Kernel

System Call Signal

Interrupt Trap
System Calls
 User can’t access directly to the kernel
code
 The system call interface layer contains
entry point in the kernel code
 Any user or application request that
involves access to any system resource
must be handled by the kernel code
Types Of System Calls
 Process Control:Controls the execution of programs and their communication.
• File Management:Handles operations related to files and directories.
• Manages file permissions and access.

 Device Management:Ensures proper communication between software and


hardware.
 Information maintenance:Manages information about system attributes and
resources
 Communications:Facilitates communication and data transfer between processes.
System Call Execution
 user program initiates a system call indirectly through a
library function
 The library routine associated with the system call is
responsible for preparing and organizing the necessary
parameters for the operation.
 The trap instruction is executed to change mode from
user to kernel.
 Control goes to operating system.
 Operating system determines which system call is to be
carried out.
Semantics of System
Call Execution …
 Kernel indexes the dispatch table, which contains
pointers to service routines for system calls.
 Service routine is executed and return parameter or
error code placed at well-known places (usually a CPU
register).
 Control given back to user program.
 Library function executes the instruction following
trap.
System Call …
Process

Library Call

System Call

trap

Dispatch Table
Service
Code
Kernel
Code
System Calls and Library
Functions

https://www.thegeekstuff.com/2012/07/system-
calls-library-functions/
Operating System
Structures
 Simple Structure
 Layered Approach
 Microkernels
 Virtual Machines
Simple Structures
MS-DOS : written to provide the most functionality in the least
space, so it was not divided into modules carefully
Simple Structures …
UNIX Monolithic
System Structure

KERNAL: this is part of


kernel when changes
for example in CPU
Scheduling it effects
the whole. DRAWBACK

You might also like