Question: Question 2 : Memory Management ( Max Mark: 2 0 / 1 0 0 ) It is sometimes useful to know which pages in a

Question 2: Memory Management (Max Mark: 20/100)
It is sometimes useful to know which pages in a user programs virtual address space
have been accessed (read or write or both). This assignment requires you to write a
system call for xv6 that checks which page in a processs virtual address space has
been accessed. Note that a good understanding of Task 6.2 will be helpful. The kernel
function ptableprint() could be useful for debugging the code for this assignment.
Therefore you may want to use the same copy of xv6 that you have used for Task 6.2 for
this question.
Task: Write a system call named pageAccess() that will modify a bitmap that
indicates which of the 64 physical memory pages have been accessed. The function
prototype of this system call for user programs will be:
int pageAccess(char* buf, unsigned int npages, unsigned int* bmp);
This function should return a negative value if unsuccessful (for any reason). Any other
returned value indicates success.
buf points to the start address of the virtual address space that needs to be checked
for access.
npages gives the number of pages that should be examined. It should be not larger than
64.
bmp is a pointer to an unsigned integer that acts as a bitmap which indicates if a page
has been accessed. Each bit of the unsigned integer corresponds to a page. Since an
unsigned integer is 64 bits in size, npages is limited to 64.
2024 AUT 4
As an example, if pages 1,2, and 30 have been accessed, the lower 32 bits of this
integer should have 1s only for bits 1,2 and 30(the rest are 0s), giving a decimal value
of 230+22+21=1073741830(hexadecimal $40000006) as shown below.
This function should return a negative value if unsuccessful (for any reason). Any other
returned value indicates success.
An example test program for your system call has been provided in the file
pgaccess_test.c. This program should be compiled as a user program in xv6. It also
serves as an example of how the system call is to be used. The bitmap should be set to
the above value for this example test program. But you should check that your system
call returns the values correspondingly if other pages have been accessed.
A skeleton code of your kernel function of this system call, sys_pageAcess(), can be
found in the file sys_pageAccess.c. Note that sys_pageAcess() does not take any
arguments. This is because the call to pageAccess is made in the user program (in user
mode). Therefore, these arguments cannot be passed directly to a kernel function (in
kernel mode) in the usual way. Instead, you will need to access the arguments in
sys_pageAcess() using argaddr and argint as demonstrated in the skeleton code.
With the bitmap pointer, it is easier to store it in a variable in this function and then copy
it to the user space before returning using copyout(). The code to do this has also
been provided. The remaining code to implement this kernel function will need to be
supplied by you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!