Memory is an essential component of the computer. It is a hardware device that assembled on the motherboard for storing data and instructions for performing a task on the system. Two types of memory are used by the computer, one for storing data permanently and second for operating.
Types of Memory
Primary memory is hard to speed memory like RAM (Random Access Memory), and Secondary memory is slow – to – access memory for example hard disk where data stored permanently. To accelerate the speed of transferring data between primary and secondary memory, ‘Cache Memory’ concept used. Memory management one of the most crucial task performing by the operating system. Virtual memory, swapping, buffering, paging, blocks, Internal fragment, and external fragment more concepts associated with the memory.
History: In an earlier computer, there was no mechanism to store a significant amount of data in the system. We could save few bytes of data. The ENIAC First programmable computer vacuum tube accumulators are used to hold the data. In 1940, delay line memory became the part of computer memory. Delay Line Memory could store a thousand bits of information in the form sound waves. After that effort for volatile and non-volatile memory.
Volatile Memory (RAM): RAM is a Volatile memory. It is used to access data randomly. It is semiconductor memory require power to retain the information in the system. Once the power is switched, data will be deleted from the system.To operate any process, its necessary data and instruction should load into RAM from hard disk. After processing data stored back into hard disk.Accessing and processing Speed of the RAM as compared to a hard drive is very high. It is approximately 50 times faster for sequential reads and writes operation. Volatile memory can be either SRAM (Static Random Access Memory) or DRAM (Dynamic Random Access Memory).
SRAM retains its contents till power is switched on. It uses six transistors per bit. Dynamic RAM is more complicated; it requires regular refresh cycles to prevent losing its contents. It uses only one transistor and one capacitor per bit. SRAM is more expensive and faster than DRAM. DRAM used for cache memories.
RAM is too small in size as a comparison to Secondary Memory (Hard Disk) in the system. To execute any process, it should be present in RAM. Sometimes there is not sufficient space for the process to reside in RAM then some process temporary swap out from RAM and Swap in the hard disk. Part of hard drive occupied by RAM‘s process acts as a virtual memory. Once the process is completed in RAM than virtual memory ’s operation go back in RAM for execution.
Paging: Paging is memory management techniques that allocating physical memory address space on the noncontinuous space allocation. Physical Memory (RAM) is broken down into a fixed size of blocks is known as frames. Secondary memory is also broken down into fixed size blocks known as pages. Whenever any process is executed its pages from secondary disk to first loaded into the available frame. Secondary memory fixed size pages are same in size with a frame of physical memory. Every address generated by Secondary memory divided into two parts; Page Number (n) and Page Offset (m).The page number used as an index number in the page table and page offset is used to find the page location in physical memory.
Let us consider an example of a 32-byte memory with 4-byte pages to understand the entire processor paging:
The page size is 4 byte, and physical memory size is 32 byte that means physical memory has eight frames.
No of frames=Memory size/Page size
Now discuss how logical memory pages mapped into physical memory. Each page has an entry of 4 bytes. Logical address 0 is page 0,offset is 0 .we find that in page table page no 0 having frame number1.Then data will be in physical memory on physical address4(=(1×4)+0). Logical address 1 is paging no 0, offset 1. Found that is in again frame number 0, the physical address 5(=(1×4)+1). Logical address 8 is page no 2, offset 0 in frame number 6 than mapped to physical memory 24(=(6×4)+0).
Physical mapped address = frame number X Page size + offset value.
It gives you mapped memory address.
Offset value is depend upon page size. Suppose page size is 4 byte i.e. offset value lies between 0 to 3.
Cache: Memory-Processing speed of CPU is about 50 times faster than RAM. It is very time-consuming to access the data from RAM again and again. To boost up the speed, new memory concept is introduced that top up with the central processing unit. CPUs have at least three independent caches: an instruction cache to speed up executable instruction fetch, a data cache to speed up data fetch and store, and a translation look a side buffer (TLB) used to speed up virtual-to-physical address translation for both executable instructions and data.
Cache is available in different size and different types like L1, L2, and L3 according to the usage of memory.
Cache hit: If requested data is available in the cache, it called cache hit.
Cache miss: If requested data is not available in the cache, it is called cache miss.
The locality of reference: It is the phenomenon of accessing the same memory location and identical data values for any time in future. Loops and subroutine call follow this concept. In case of loops and subroutine call, the same set of instructions or data items fetched from memory. It is also known as the principle of Locality. It has two types-Temporal localities and Spatial Locality.
Temporal Locality-In temporal locality, same memory location and content that fetched will be a need in future for use.
Example: In array B,B,B…………………B[n] are different memory location with different data values. If we accessing B,B,B the same memory location than it show temporal locality.
Spatial Locality: In this type, if memory address location referenced at a particular time, then its nearby memory locations will be referenced shortly.
For example: In array B,B,B…………………B[n] are different memory location with different data values. If we are fetching B, then accessing memory Location B will show spatial locality.
Secondary Memory is permanent storage memory on the computer. It is non-volatile in nature means that its content will not lost after switching off the electricity. The hard disk is a secondary storage device in the computer. It is available in many sizes like in MB, GB, TB, etc.
The structure-hard disk is a hardware device having a cylinder, platters, track, sector, read-write head. Usually, the hard drive is a combination of drive known as platters connected to the spindle. Each platter has two surfaces. We can write and read data on both sides of platters. The arm is holding the read-write head for both sides of platters. Counting of read-write head depends upon the number of platters.
Track: Track is a concentric circle on a platter. Thousands of tracks placed on platters.
Sector: Tracks divided into some portions known as a sector. Number of Sector depended upon the manufacturer. The sector is used to store data and access the data. Sector has three parts-Header, Data, and Trailer.
Header: Header contains the information to identify the sector.
Trailer: Trailer contains the information to correct the error regarding to stored data in the sector.
Cylinder: Cylinder set of tracks, one from each platter that is the equal vertically distance from disk arm. A number of cylinders depending upon the number of track per surface. Suppose, if a hard disk has six platters. Each platter has ten tracks than disk exactly has ten cylinders.
Disk Capacity: To find out the disk capacity we should know about the number of cylinders, tracks per cylinder, sector per track and data bytes stored on sector.
Seek time: Time taken by disk arm to move the head on the desired cylinder is known as seek time.
Rotational Latency: Time taken by disk arm to move on the desired sector on the cylinder is known as rotational latency.
Transfer rate: Transfer rate defined as the rate at which data flow between the drive and the computer.
The operating system used many disks scheduling an algorithm to serve the process’s pending request for accessing the disk-like FCFS Scheduling, SSTF Scheduling, SCAN Scheduling, C-SCAN Scheduling, LOOK Scheduling, etc.