Académique Documents
Professionnel Documents
Culture Documents
Memory Unit
Essential component in any computer Needed for storing programs and data Small computers no need of additional storage. In general purpose computers its not possible to accommodate all programs in a single memory unit Not all information is needed by the CPU at the same time Economical to use low-cost storage devices for backup of storing the information that is not currently used by CPU
Memory unit that communicates directly with CPU - main memory Devices that provide backup storage - Auxiliary memory
Magnetic disks and tapes
Memory Unit
Datas currently used by Processor resides in main memory Transferred from auxiliary memory to main memory when needed
Memory Hierarchy
Consists of all storage devices employed in a system From the slow but high-capacity auxiliary memory to a relatively faster main memory and a smaller, faster cache memory
Memory Hierarchy
Very high speed special memory - Cache Used to increase the speed of processing By making current programs and data available to the CPU at a rapid rate To compensate the speed difference between main memory and processor Datas used frequently and datas used in present calculations will be stored in cache By this, it is possible to increase the performance of processor
6
Memory Hierarchy
Economics Storage capacity increases, cost per bit decreases and access time is longer Auxiliary memory
Large storage, inexpensive, low access speed
Cache memory
Small, expensive and high access speed.
Speed increases cost also increases Highest possible average access speed at low cost
Typical access time ratio between cache and main memory is about 1to7 Auxiliary memory access time is usually 1000 times that of main memory Block size
Auxiliary memory 256 to 2048 words Cache memory 1 to 16 words
Memory Hierarchy
Multiprogramming
Number of independent programs concurrently. Possible to keep all parts of the computer as working A program is executed in CPU, but an I/O transfer is required, then CPU initiates I/O processor to do that work Then CPU can execute other programs All programs cannot reside in main memory at all time Resides in auxiliary memory, when the program is executed, transferred to main memory Memory management system flow of data between main and auxiliary memory
9
Main Memory
Central storage unit Made up of RAM, but a portion may be of ROM chips also RAM Random Access memory
Two possible operating modes, Static
Flip flops to store binary information. Retains value indefinitely, as long as it is kept powered. Faster and more expensive than DRAM.
Dynamic
Form of electric charge through capacitors Value must be refreshed every 10-100 ms Reduced power consumption and large storage capacity. Slower and cheaper than SRAM.
10
ROM portion of main memory is needed to store initial program bootstrap loader
To start the computer software RAM is volatile its not possible So ROM is used When power is ON hardware sets PC to first address of bootstrap loader
11
The capacity of the memory is 128 words 8 bits (one byte) per word
12
RAM
13
ROM
Since it is read only, data bus will be in output mode only No need of R/W
14
Pictorial representation of assigned address space for each chip in the system An example, assume that a system needs 512 bytes of RAM and 512 bytes of ROM The RAM have 128 byte and need seven address lines, where the ROM have 512 bytes and need 9 address lines
15
16
17
18
19
Auxiliary Memory
Common auxiliary memory devices
Magnetic disks and tapes Magnetic drums, Magnetic bubble memory and optical disks
Properties
Access mode Access time Transfer rate Capacity and Cost
20
Average time required to reach a storage location in memory and obtain its contents - Access time Access time = seek time + transfer time
Seek time: required to position the read-write head to a location Transfer time: required to transfer data to or from the device
Number of characters or words that device can transfer per second transfer rate
21
Magnetic Disk
Circular plate constructed of metal or plastic coated with magnetized material. Both sides are used and several disks are stacked on one another. Rotate at high speed (5400 to 7200 RPM) and not stopped for accessing. Bits are stored in magnetized surface in spots along circles tracks. Tracks are divided into sections - sectors.
22
Magnetic Disk
23
24
Finding sector
Addressed by address bits
Disk number, Disk surface Sector number and Track within the sector.
R/W heads are positioned in a track It has to wait until the rotating disk reaches the specified sector under the R/W head Information is transferred when the beginning of the sector is reached
25
Tracks near the circumference is longer than center of the disk. Bits are recorded at equal density, some tracks will have more bits. For equal length variable recording density is used Higher density near the centre of the tracks Number of bits on all tracks is equal. Two types of disks
Hard disk Floppy disk
26
Information distribution
27
Magnetic tapes
Strip of plastic coated with magnetic medium Bits are recorded as magnetic spots along several tracks
28
Associative memory
Memory unit accessed by its contents. Also called as CAM (Content Addressable Memory)
29
30
Locality of reference
Analysis shows that the references to a memory at a given time tends to be enclosed within a few localized areas in memory. Computer programs flows through loops and subroutines. When a loop is executed CPU refers to a set of instructions in memory repeatedly. Sometimes data also tend to be localized tables Thus in short time, programs refers to a few areas in the memory, while the remaining portion is accessed infrequently
31
Cache memory
If the active portions of program and data are placed in a fast small memory, the average memory access time can be reduced. Thus total execution time is reduced Such a fast small memory - cache memory Cache is the fastest component in the memory hierarchy and approaches the speed of CPU.
32
Operation
When CPU needs to access memory, the cache is examined If the word is found in the cache, it is read from it. If the word is not found in the cache, the main memory is accessed to read the word. Block of word containing the one accessed is transferred from main memory to Cache. Block size one word or 16 words adjacent to the one just accessed.
33
Performance
measured in terms hit ratio When the CPU refers to memory and finds the word in cache, it is said to produce a hit Otherwise, it is a miss Hit ratio = hit / (hit+miss)
34
Cache memory
The transformation of data from main memory to cache memory mapping Three types of mapping
Associative mapping Direct mapping Set-associative mapping
35
Mapping
36
Fastest and most flexible cache organization uses an associative memory Associative memory stores both the address and data of the memory word The address value of 15 bits is shown as a 5-digit octal number and its corresponding 12-bit word is shown as a 4-digit octal number.
Associative mapping
37
Associative mapping
38
15 bit address is placed in the argument register and the associative memory will search for a matching address If the address is found, the corresponding 12-bits data is read and sent to the CPU If not, the main memory is accessed for the word Address, data pair is also transferred to cache memory If the cache is full, an address-data pair must be displaced Based on the displacement algorithm.
FIFO policy.
39
Associative mapping
Direct Mapping
Associative memory is expensive compared to RAM RAM as cache memory CPU address of 15 bits is divided into two fields.
9 LSB bits - index 6 bits tag
In general, there are 2K words in cache and 2N words in main memory N bit memory address is divided into two fields:
Kbits for the index N-K bits for the tag field
40
Direct Mapping
41
42
43
Set-Associative Mapping
An improvement over the direct mapping. Each word of cache can store two or more words of memory under the same index address. Set size is 2 and it can be increased
44
Set-Associative Mapping
45
Replacement
Random replacement FIFO LRU (Least recently used)
46
Write back
Cache is updated and the location is marked by a flag When the word is removed from cache it is copied in main memory Many times value will be updated
47
Cache initialization
Initialized when the power is applied or when the main memory is loaded with programs from auxiliary memory. After initialization it contains some invalid data. Valid bit
To indicate whether or not the word contains valid data or not. Set to 0 when the data is invalid Set to 1 - when a word is loaded from main memory.
48
Is used to give programmers an illusion that they have large memory. Provides a mechanism to translate program generated address into correct main memory location. Mapping or translation done by hardware (mapping table)
Virtual memory
49
Virtual Memory
Address used by a programmer - virtual address. Set of such addresses address space. Address in main memory - physical address. Set of such locations memory space
50
CPU will reference instructions with 20 bit address. But main memory can able to address only 15 bits A table is needed to map a virtual address of 20 bits to a physical address of 15 bits.
51
52
53
Address space 8K and Memory space 4K. If divided into 1k words 8 pages and 4 blocks.
54
Mapping
Virtual address has 13 bits. Higher order 3 bits one of the 8 pages and remaining 10 bits line address within the page.
55
56
57
58
Page Replacement
Virtual memory system combination of H/W & S/W Software
Which page has to be removed when new page is arrived When a new page is to be transferred Where the page has to be placed
60
Segment
Set of logically related instructions or data associated with a given name.
Logical address
Address generated by segmented program. Same as virtual address but this has variable length
61
62
64
Example
65
Consider a program loaded into memory that requires 5 pages OS assigns program segment 6 and pages 0 to 4
66
67
TLB
68
Memory protection
Can be assigned to physical address or logical address Better for logical address. Content of each entry in the segment table descriptor
Contains base address field and one or two additional fields for protection
69
Protection
Specifies the access rights
Full read and write Read only Execute only System only (OS protection)
70
Page Replacement
What if there is no free frame? Page replacement find some page in memory, but not really in use, swap it out
71
72
Page Replacement
73
FIFO
When a page is to be replaced, oldest page is chosen
74
75
Least-recently-used (LRU)
LRU chooses the page that has not been used for the longest period of time
76
Least-recently-used (LRU)
77
78