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

5.Operating System - Process

Process:   A process is basically a program in execution. The execution of a process must progress in a sequential fashion. To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process that performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data. Program:  A computer program is a collection of instructions that performs a specific task when executed by a computer. When we compare a program with a process, we can conclude that a process is a dynamic instance of a computer program. Process Life Cycle (Start, Ready, Running, Waiting, Terminate/Exit): Process Control Block (PCB):  A Process Control Block is a data structure maintained by the Operating System for every process. The PCB is identified by an integer process ID (PID). A PCB keeps all the information needed to keep track of...

1. Operating System - Overview

  Definition: An operating system is a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs. Memory Management:   Memory management refers to the management of Primary Memory or Main Memory. It keeps track of primary memory, i.e., what part of it is in use by whom, what parts are not in use. It allocates and de-allocates the memory when a process requests it to do so. Processor Management :   Processor Management k eeps track of the processor and the status of a process. The program responsible for this task is known as a  traffic controller . It is responsible for a llocating and de-allocating the processor (CPU) to a process. Device Management :  An Operating System manages device communication via their respective drivers.  Device Management keeps track of all devices. The program responsible for this task is known as the I/O Controller. It d ecides which process gets the d...