![]() ![]() Qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 1 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus. Install QEMU and gcc for RISC-V following the directions on. Now add the prototype for pages() to user.h:Īdd the following user program to call pages() and print the $ cat pages.c This lab makes you familiar with xv6 and its system calls. The assembly functions that make the system calls are generating by the Perl script. Then, modify syscall.c to add sys_pages to the syscall table:Īdding the pages() syscall to the user directory Then, we need to modify syscalls.h to add the SYS_PAGES syscall: In the kernel directory, we will add sys_pages() to sysproc.c at the end of the file: To add a system call we need to make changes in the kernel and user directories. Qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 1 -nographic -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0 Printf("xv6 free pages: %d\n", kfreepages()) Īfter these changes, make the kernel and run in $ make qemu Now we can add a call to kfreepages() to main.c:main(): with QEMU and QEMU/GDB debugging, and warm you up with xv6s system call dispatch. Note, to be safe, we need to acquire the kmem.lock while counting so we don't count while another process is modifying the freelist.Īfter adding this function to kalloc.c we also need to add the kfreepages() prototype to def.s.h: ltrace traces the dynamically loaded library calls a process issues. Given this, in order to find the number of free pages, we just need to count the number of pages in the freelist: The links are embedded in the pages themselves, so you can imagine the freelist as a linked list of pages. The xv6 kernel keeps track of free pages in a singly linked list. This calls freerange(), which "frees" all unused pages that reside above the kernel code and data to the end of physical memory. During the initialization of the xv6 kernel, the kinit() function is called. ![]() Finally we will write a user-level program that calls pages() and prints the result.Īdding kfreepages() to kalloc.c in the kernel directoryįunctions related to page allocation can be found in kalloc.c. ![]() Then we will add a new system call, pages(), that will return the number of free pages. This starts up QEMU, but QEMU stops just before the processor executes the first. First we will write a function to determine the number of free pages and add this to main.c:main() to print the number of free pages on boot so we can make sure it is working. In this assignment, you will design a new system call for xv6. Let's add a system call that will return the number of free pages available in the xv6 kernel. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |