Skip to main content

8. Operating System - Virtual Memory and Input/Output



Definition: A computer can address more memory than the amount physically installed on the system. This extra memory is actually called virtual memory and it is a section of a hard disk that's set up to emulate the computer's RAM.

The main visible advantage of this scheme is that programs can be larger than physical memory. Virtual memory serves two purposes. First, it allows us to extend the use of physical memory by using disk. Second, it allows us to have memory protection, because each virtual address is translated to a physical address.

Demand Paging: A demand paging system is quite similar to a paging system with swapping where processes reside in secondary memory and pages are loaded only on demand, not in advance.

Page Replacement Algorithm: Page replacement algorithms are the techniques using which an Operating System decides which memory pages to swap out, write to disk when a page of memory needs to be allocated

Reference String: The string of memory references is called reference string.

FIFO Algorithm: Oldest page in the main memory is the one that will be selected for replacement  

I/O Hardware

Block devices: A block device is one with which the driver communicates by sending entire blocks of data. For example, Hard disks, USB cameras, Disk-On-Key, etc.
 
Character devices: A character device is one with which the driver communicates by sending and receiving single characters (bytes, octets). For example, serial ports, parallel ports, sound cards, etc.
 
Device Controller: Device drivers are software modules that can be plugged into an OS to handle a particular device.
 
The Device Controller works like an interface between a device and a device driver. I/O units Keyboard, mouse, printer, etc.) Typically consist of a mechanical component and an electronic component where the electronic component is called the device controller. There is always a device controller and a device driver for each device to communicate with the Operating system.
 
Direct Memory Access (DMA): Direct Memory Access (DMA) means CPU grants I/O module authority to read from or write to memory without involvement. DMA module itself controls the exchange of data between the main memory and the I/O device. CPU is only involved at the beginning and end of the transfer and interrupted only after the entire block has been transferred.
 
Polling I/O vs Interrupts I/O: Polling is the simplest way for an I/O device to communicate with the processor. The process of periodically checking the status of the device to see if it is time for the next I/O operation is called polling.
 
An alternative scheme for dealing with I/O is the interrupt-driven method. An interrupt is a signal to the microprocessor from a device that requires attention.

Input/Output Software

User Level Libraries: This provides a simple interface to the user program to perform input and output. For example, stdio is a library provided by C and C++ programming languages.
 
Kernal Level Libraries: This provides a device driver to interact with the device controller and device-independent I/O modules.
 
Hardware: This layer includes actual hardware and hardware controller which interact with the device drivers and makes hardware alive.
 
Device Drivers: Device drivers are software modules that can be plugged into an OS to handle a particular device.
 
Interrupt Handlers: An interrupt handler, also known as an interrupt service routine or ISR, is a piece of software or more specifically a callback function in an operating system or more specifically in a device driver, whose execution is triggered by the reception of an interrupt.
 
Device Independent I/O Software: The basic function of the device-independent software is to perform the I/O functions that are common to all devices and to provide a uniform interface to the user-level software.
 
User-Space I/O Software: These are the libraries that provide a richer and simplified interface to access the functionality of the kernel or ultimately interact with the device drivers.
 
Kernal I/O Subsystem (Scheduling, Buffering, Caching, Spooling and Device Reservation, Error Handling):
 
Caching - Kernel maintains cache memory which is a region of fast memory that holds copies of data. Access to the cached copy is more efficient than access to the original.

Comments

Popular posts from this blog

CPP

Basics Downloading and installing CodeBlock Creating and explaining first project Hello World – the terms (keyword, main, header file) Keyword – Keywords are reserved words for compiler whose purpose is already defined in compiler and user cannot use for personal use. E.g if, else, double, switch main – main is a necessary function to define to execute C/C++ program. Without main, we cannot run our program. Header file  - header file contains functions that perform certain tasks  Characters \n, \t, \a data types: int – 4b, float – 4b, double – 8b, char – 1b, string – equal to the number of characters variable: rules to define a variable cannot start with numbers and special characters. Only special character acceptable is _ e.g. _age Camel case: weightInKg Snake Case: weight_in_kg declaration vs initialization arithmetic operations (+, -, *, /, %) input from user – cin, getline() relational operators (>=, <=, >, <, ==, !=) if selection statement if…else – double s...

3.Operating System - Services

Program Execution: The OS is responsible for executing programs. It loads the program into memory and executes the program. Program execution also includes process sync, process communication, and deadlock handling.  I/O Operation :  An I/O subsystem comprises I/O devices and their corresponding driver software. I/O operation means read or write operation with any file or any specific I/O device. OS provides the access to the required I/O device when required. File System Manipulation:  A file represents a collection of related information. A file system is normally organized into directories for easy navigation and usage. The operating system gives the permission to the program for operation on file. Permission varies from read-only, read-write, denied, and so on. Operating System provides an interface for the user to create/delete files. Operating System provides an interface for the user to create/delete directories. Operating System...

OS Outline

Operating System - Overview OS Definition Memory Management  Processor Management  Device Management  File Management  Security  Error Detecting Aids  Job Accounting Operating System - Types  Batch Operating System Time-sharing Operating System Distributed Operating System Network Operating System Real-time Operating System Hard real-time Operating System Soft real-time Operating System Operating System - Services Program Execution  I/O Operations  File System Management  Communication  Error-handling  Resource Management  Protection  Operating System - Properties  Batch-processing Multi-tasking Multi-programming Interactivity  Real-time system Distributed Environment  Spooling  Operating System - Process Process Program Process Control Block (PCB) Operating System - Process Scheduling Definition Process Scheduling Queues Job Queue Ready Queue Device Queue Two-State Process Model  Running...