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

7.Operating System - Memory Management

Process Address Space:   The process address space is the set of logical addresses that a process references in its code. Static vs Dynamic Loading:  The choice between Static or Dynamic Loading is to be made at the time of the computer program being developed. If you have to load your program statically, then at the time of compilation, the complete programs will be compiled and linked without leaving any external program or module dependency. If you are writing a dynamically loaded program, then your compiler will compile the program and for all the modules which you want to include dynamically, only references will be provided and the rest of the work will be done at the time of execution. At the time of loading, with static loading, the absolute program (and data) is loaded into memory in order for execution to start. If you are using dynamic loading, dynamic routines of the library are stored on a disk in re-locatable form and are loaded into memory only when they a...

9. Operating System - Extra

Interrupt:   In system programming, an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. Trap:   In computing and operating systems, a trap, also known as an exception or a fault, is typically a type of synchronous interrupt caused by an exceptional condition (e.g., breakpoint, division by zero, invalid memory access). Signal:   A signal is a software-generated interrupt that is sent to a process by the OS because when the user press ctrl-c or another process tells something to this process. There is fix set of signals that can be sent to a process. Signals are identified by integers. A signal number has symbolic names. System call:   The interface between a process and an operating system is provided by system calls. System calls are usually made when a process in user mode requires access to a resource. Then it request...