Reference no: EM132248800
Assignment: You will need to write the following functions to perform the given operations in mmu.cpp:
void mmu_disable()
This function will turn off the MMU by changing the SATP's mode bit. DO NOT change anything other than the mode bit!
void mmu_enable(PROCESS *p)
This function will enable the MMU for the given process. Remember, there is a context switching mechanism, so your mmu_enable must handle any process that needs to be enabled. This function does not build the page tables. That will be done later using mmu_map. Instead, this function is used to program the SATP register so that the process pointed to by *p's page tables are correctly loaded before it runs.
This function must do nothing if p->mmu_table is == 0. A table that is NULL means that mmu_map has not been called.
void mmu_map(PROCESS *p)
This function will map a process' program pointer and stack pointer into the MMU. This is typically used for USER mode processes, but may also be used for SUPERVISOR processes. NOTE: This function does NOT change SATP. Instead, it will write the root table into p->mmu_table. You will notice that there is a global array, which is essentially a pot of memory you are free to create your page tables in. This function is responsible for building the page tables in RAM and setting the root of those page tables into p->mmu_table. Again, this function does NOT change SATP...that's the responsibility of your mmu_enable() function.
void mmu_unmap(PROCESS *p)
This function will completely unmap a process from the MMU. Essentially, it needs to free the memory associated with p->mmu_table by making those entries non-valid (V bit must be 0).
Since the page table array is statically allocated, you will not be freeing the entries as your normally would using dynamic memory functions, such as free or delete. Instead, all you need to do is invalid every entry of your page tables. Remember that bit index 0 of a page table entry is the V bit (Valid). If this is set to 0, then that page table entry is "freed" in the loosest sense of the word.
void test()
This function is called from the init() process. You can use new_process (prototyped in mmu.h) to create new processes to test your code. My operating system will automatically call your mmu_enable(), mmu_map(), mmu_unmap(), and mmu_disable() functions. Therefore, all you need to do is write the functionality, and my OS will take care of calling these functions at the appropriate time.
Information related to above question is enclosed below:
Attachment:- assignment.rar