 Hello everyone. Today we are going to continue with layout of system memory. Here we are going to consider memory architecture which supports pages. The memory architecture who supports pages has paging mechanism. So, we are going to learn in detail about pages and page tables in Unix operating system which supports architecture using paging. The learning outcome of this session are at the end of this session student will be able to define addressing physical memory as pages and apply address translation techniques. Now, the memory admin the memory management architecture based on pages divides the physical memory into equal size pages that we know that it is already a paging mechanism. So, here the page size can range from 512 bytes to 4 kilobytes. Now, every addressable location in physical memory can be referred as the page number and byte offset in a page pair. So, every physical location in memory can be referred by this pair that is page number and byte offset. So, suppose we have a machine with 32 bit address. So, it has 2 raise to 32 bytes of physical memory with size page size as a 1 kb. Then it will contain 2 raise to 22 pages and this 32 bit physical memory can be address as 22 bit page number and 10 bit address. So, total 32 bit memory is divided into 10 bit byte offset and 22 bit page number. So, here the physical memory 32 bit physical memory can be address as a page with 10 bit offset and 22 bit page number. Now, let us see how the physical memory can be address as a pages. Now, here we will consider an hexadecimal address of a physical memory that is 58432. Now, to convert it as a page or to represent it as a page we will first convert this hexadecimal address into binary. So, for that we will write binary representation of each number as shown here. So, binary representation of 5 is given for 8 is given 4 and 3 and 2 is given. Now, recall that if machine has 32 bit address then the 2 raise to 32 byte of that physical memory can be address as 22 bit page number and 10 bit offset. So, what we will do here we will convert this number into 10 bit page offset and 22 bit page number. So, we will start from lower's number and here the 10 bit of this binary we will consider as a byte offset and which is 10 bit byte offset and the remaining bits are considered as a page number. So, after converting this 10 bit into hexadecimal we will get number 32 which is a byte offset and after converting that 22 bit into page number we will get 161 which is page number. So, here the hexadecimal address 58432 is converted into page as 161 page number with byte offset 32. So, this address is located in page number 161 at byte offset 32. This is how the physical memory is addressed as a pages in a paging memory. So, here we have converted it into hexadecimal numbers. So, just pause a video and consider a hexadecimal address 46321 and convert this physical address into a page where the system supports paging mechanism. Let us see now as I already told you whatever hexadecimal number is given convert that hexadecimal number first in binary. So, binary representation of 4642 and 1 is given. Now we have to convert this binary number into 10 bit page offset and the remaining bits will be the 22 bit page number. So, here the 10 bit page number page offset is given and 22 bit page number is given. Now again after converting this into hexadecimal we get 21 as a page offset and 119 as a page number. So, hexadecimal address 46421 is converted into a page number that is 119 and page offset 21. So, this is located in page number 119 at byte offset 21. Now let us see mapping of logical to physical page numbers. Now when kernel assigns physical pages of memory to a region it need not necessary to assign pages continuously or in particular order. So, purpose of this page memory is to give greater flexibility and reduce the amount of unused space. So, kernel correlate this virtual address of a region to their physical machine address. Region is what continuous address space and this continuous address space can be converted into physical machine address to increase the flexibility. So, here kernel assign pages of memory to region and then virtual address is converted into the physical address. Now this address translation is done by mapping the logical page number in a region to physical page number on a machine. Now since the region so here we have a page table which contains logical page number corresponding to the physical page number. Now region is continuous range of virtual addresses in a program and the region table entry region table entry contains a pointer to table of physical page numbers. Now this is a physical page number and the whole table is nothing but a page table. Here the logical page number acts as an index for physical page number in the given page table. So, the logical page number 0 is located at physical page number 171. Logical page number 1 is located at physical page number 54 like this the every logical page number has corresponding physical page number in the memory. Now let us see how this how this virtual address can be converted into physical address. Now consider a process consider one process whose per process region table is given along with virtual addresses as we already know process contains three region text region data region and stack region. So, text region here starts at 8k data region starts at 32k and stack region starts at 64k. Corresponding page tables are also given for all these three region. So, text region has its corresponding page table, data region has its corresponding page table and stack region has its corresponding page tables along with the physical addresses. Now consider that the size of the page is 1 kb. Now assume that the process wants to access virtual memory address 68432. So, as shown here the stack region starts at 64k by converting into decimal it gives 65536. So, assuming that stack growth is in upward direction we can say that the virtual memory address 68432 is present in stack region. So, the page table corresponding to the stack region is given that page table starts at byte offset 65536. So, to find the location of this virtual memory in stack region we need to subtract the virtual memory address we need to subtract the starting address of stack from the virtual memory address. So, by subtracting 65536 from 68432 we will get 2896 in stack region. Now, where this 2896 lies in this stack region that we need to find out. Now here we have page size 1 kb. 1 kb is nothing but 1024 bytes. So, assuming that here the page 0 starts from 0. So, it will end size of this page is 1 kb. So, it will end at 1023. So, the page number 1 will start at 1024. Page number 2 will start at 2048. Page number 3 will start at 3072. Like this the next pages have their starting locations. So, here we get the offset 2896. So, as we can see here this 2896 will lie in page number 2 because page 2 starts at 2048 ok. Now, we got the page number. Now we need to find out the byte offset in this page number. So, as the page size is 1 kb 2896 will be located in page 2 at byte offset 2896 minus 2048 because 2048 is starting address of page 2. So, we will get the byte offset 848 which is located at physical address 986 in the physical memory. So, the virtual memory address 68432 is located at physical address 986 k. In this way the virtual address is converted into physical address using page table. This is all about converting virtual address to the physical addresses. These are the references. Thank you.