WHAT IS MAPPING? We need to bring data from the main memory to the cache for reducing the access time for the CPU as the cache is closer to the CPU than the main memory. ASSOCIATIVE MAPPING Data from main memory are placed randomly in cache.Let us say we have 16 bit memory address then out of that we have 12 bit tag bits & 4 bit word bits .That is cache will have total 2^12 blocks and each block will have 2^4 data words.if get 1111111111111111 then tag bits is 111111111111 & word bits is 1111,that is we will look for block with tage of 111111111111 and in that block we will search for 16th word block.refer the figure => benefits of associative mapping are like No thrashing as it happens in direct mapping DIRECT MAPPING Same like above , if we use 16 bit addressing then tag bits have 5 bits,block bits of 7bits & word bits have 4 bits .Word bit identifies the column number,block bit identifies the row number & tag bits refers the corresponding address
Basic Idea Of Virtual Memory Let us say we have a game of 50GB and RAM of 8 GB then by logic we will think that 50GB is greater than 8GB so the game can't fit in RAM so the game cant work. This is not the computers and world work pal... Of 50GB let us say we require only 2 GB of data of RAM for making a game run and RAM is 8GB, yes we will put those data in RAM that is in use and others in physical memory (disk ) that are not in use right now. The above process is done by the concept of virtual memory, it will show that it is doing hard work (running 50GB in 8GB space) but actually, it is doing smart work (running 2GB in 8GB). Take a look at the following diagram => 1. Processor issues for a virtual address asking for a physical address 2. Memory Management Unit converts the virtual address into a physical address using some internal methods. 3. You get data from that physical address either from cache or from main memory if that is not found in both o
This usually used in representation of graphs.If there are n vertices in graph then there are n rows and n columns in matrix. Let us take Ith row and Jth column then A[I][J] represents the edge between two nodes I & J.If a[I][J] == 0 then there is no edge between node I and node J & if A[I][J] == 1 then there is edge. These type of graph representation is used when there are more number of edges.Reason is that if there are e less number of edges then lot of space will wasted in storing the zeroes which is not good thing. Following is the graph and its adjancy matrix => # include < stdio.h > # include < stdlib.h > int main () { // n is number of edges int n ; printf (" Enter the number of edges => "); scanf (" %d ", & n ); // construct adjancy matrix int adjMatrix [ n + 1 ][ n + 1 ]; // iterate for status of connected or not for ( int i = 0 ; i < n ; i ++ ) { for ( int j
Comments
Post a Comment