1. Homepage
  2. Programming
  3. COMP604 Operating Systems - Lab 6 Assignment: pageAccess

COMP604 Operating Systems - Lab 6 Assignment: pageAccess

Engage in a Conversation
AUTCOMP604Operating SystemspageAccessCSystem call

COMP604 – Operating Systems CourseNana.COM

Lab 6 Assignment CourseNana.COM

Introduction CourseNana.COM

This assignment requires you to write a system call for xv6 that checks which page in a process’s virtual address space has been accessed. Note that a good understanding of Task 6.2 will be needed. The kernel function ptableprint() could also be useful for debugging the code for this assignment. Therefore, you may want to use the same copy of xv6 that you have completed for Task 6.2 in this assignment. CourseNana.COM

Detailed Description CourseNana.COM

It is sometimes useful to know which pages in a user program’s virtual address space have been accessed (read or write or both). To facilitate this, you will write a system call named pageAccess(), that reports this. The function prototype of this system call for user programs will be: CourseNana.COM

int pageAccess(char* buf, unsigned int npages, unsigned int* bitmap); CourseNana.COM

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.
bitmap is the pointer to an unsigned integer that acts as a bitmap indicating 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.
It should return a negative value if unsuccessful (for any reason). Any other returned value indicates success.
CourseNana.COM

Note: In the code provided for pageAccess, you will note that the function sys_pageAccess does not have any arguments. This is because the call to pageAccess is made in the user program (in user mode). Therefore, they cannot be passed directly to a kernel function (in kernel mode). Instead, the values of the arguments are obtained using argaddr, and argint as appropriate. CourseNana.COM

If pages 1, 2, and 30 have been accessed, the lower 32 bits of this integer should have 1’s only for bits 1, 2 and 30 (the rest are 0’s), giving a decimal value of 230+22+21 = 1073741830 (hexadecimal $40000006) as shown below. CourseNana.COM

31 24 16 8 0 CourseNana.COM

An example test program for your system call has been provided in 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. CourseNana.COM

In the implementation of your system call function, you will need to access the arguments using argaddr and argint. This part of sys_pageAcess() is provided for you in pageAccess.c. You should put this function in sysproc.c. With the bitmap, 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. CourseNana.COM

School of Engineering, Computer and Mathematical sciences, AUT 1 CourseNana.COM

CourseNana.COM

COMP604 – Operating Systems CourseNana.COM

Also note that: CourseNana.COM

  1. The kernel function walk() in vm.c is useful for finding the right page table entries (PTEs). CourseNana.COM

    A pagetable entry is the content of one element of the pagetable array. This function requires 3 arguments. The first argument is a pointer to the pagetable of the process. This should be obtained from the Process Control Block of the current process. The second argument is the virtual address whose pagetable entry we are looking for (This is what is returned by the function). The third argument should be 0 in our case. Read the comments for this function in vm.c CourseNana.COM

  2. You will want to define PTE_A in riscv.h to indicate the access bit in the PTE. As examples of how this could be done, see PTE_V, PTE_R, PTE_W, etc. (they define different bits) that can be found in that file. Consult the lecture slides on xv6 Pagetable or the xv6 Book for the position of these flags. CourseNana.COM

  3. You must clear PTE_A after checking if it is set. Otherwise, this bit will be set for all the pages you have examined. CourseNana.COM

  4. In C, “<<” is a bitwise shift left operator. For example, v << 3 means shift the value of v left 3 bits. Hence, in the test program, when you see 1 << 3, it means shift the value of 1 left by 3 bits. Since 1 is represented in binary as 0...0001, shifting left 3 bits means the value becomes 0...1000, i.e. 8 in decimal. CourseNana.COM

  5. In C, “|” is a bitwise OR operator. So a | b means performing OR between the corresponding bits of a and b. Hence, bitwise OR of two numbers (in binary) 0...110 and 0...011 results in 0...010. CourseNana.COM

Submission
You are to submit an archive of the whole content of xv6-riscv. To avoid the archive being too big for submission, you must do the following: CourseNana.COM

1. Execute the command make clean in the xv6-riscv directory.
2.
cd to the parent directory (i.e. the directory above) of the xv6-riscv directory, run CourseNana.COM

tar cvf Lab6-<GROUPNUM>.tar xv6-riscv CourseNana.COM

where <GROUPNUM> is your lab assignment group number. For example, Group 20 should use CourseNana.COM

3. Use the command tar tf Lab6-<GROUPNUM>.tar to check that all the sub-directories and files have been archived. CourseNana.COM

4. Submit this file to Canvas. CourseNana.COM

This lab will contribute 5% towards your overall course marks. CourseNana.COM

Lab6-20.tgz CourseNana.COM

School of Engineering, Computer and Mathematical sciences, AUT 2  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
AUT代写,COMP604代写,Operating Systems代写,pageAccess代写,C代写,System call代写,AUT代编,COMP604代编,Operating Systems代编,pageAccess代编,C代编,System call代编,AUT代考,COMP604代考,Operating Systems代考,pageAccess代考,C代考,System call代考,AUThelp,COMP604help,Operating Systemshelp,pageAccesshelp,Chelp,System callhelp,AUT作业代写,COMP604作业代写,Operating Systems作业代写,pageAccess作业代写,C作业代写,System call作业代写,AUT编程代写,COMP604编程代写,Operating Systems编程代写,pageAccess编程代写,C编程代写,System call编程代写,AUTprogramming help,COMP604programming help,Operating Systemsprogramming help,pageAccessprogramming help,Cprogramming help,System callprogramming help,AUTassignment help,COMP604assignment help,Operating Systemsassignment help,pageAccessassignment help,Cassignment help,System callassignment help,AUTsolution,COMP604solution,Operating Systemssolution,pageAccesssolution,Csolution,System callsolution,