程序代写|CS-GY 6233 – Fall 2022 Homework #1 xv6 disk usage user program
这是一篇来自美国的关于xv6磁盘使用情况的用户程序代写
● For this assignment, you will work exclusively with the xv6 operating system
● You will use a class-provided container, hosted on Anubis. This container: ○ Automatically manages a private GitHub repository for you, and autosaves your work ○ Already contains the xv6 source code and the necessary compiler/linker ○ Provides you with a VSCode web interface for development ○ Will ‘autograde’ certain parts of your code (visible case results only) ● For those of you with a C background, or those of you adept at Googling for C functions, it is important to note that xv6 is not compiled with the C standard library. ○ While a lot of the subparts of the assignment might look “easy,” do not wait until the last minute to begin work. ○ There are many nuances to what functions and patterns will work within xv6, and a lot of these nuances are learned only through practice. ● The autograder is not guaranteed to be available (the TAs and the Anubis team will maintain a best-effort SLA). ○ Designing your own test cases is important. ○ Read the requirements carefully, ask questions, and prepare for somewhat-unexpected test cases. ○ Your final submission will be graded against new/different cases than are present in the autograder. |
Where we’re going with HW1…
In 1971, Dennis Ritchie released a tool named ‘du’ (disk usage) for AT&T’s Unix operating system, and throughout the years this utility has become quite ubiquitous across *nix OSs.
Disk Usage does just that; it calculates the amount of data associated with file and directory entries within the filesystem. Various options (called flags and/or arguments) can change this behavior – for this assignment, we will implement a generic ‘du’, as well as a very small subset of flags, for the xv6 OS.
Related Commands (already available in xv6): ‘ls’, ‘mkdir’, ‘rm’
Part 1 – Boot xv6 from Anubis
1.A – Setting up Anubis
Whether working in pairs or not, it’s important for each team member to perform the following:
- You need a GitHub account for this course and to use Anubis. Create an account now if you do not have one already. It does not matter whether you use your NYU email for this account or not.
- Visit anubis-lms.ioand sign in with your NYU credentials.
- Within Anubis, our first goal is to connect your GitHub account to the system. To do this, click the hamburger at the upper left to open the side panel, and select “Profile.” Connect your GitHub account to Anubis.
- Join our course by clicking on “Courses” on the left, and adding our course with code: ilovegrados
1.B – Initializing Assignments
Again, each team member should perform the following:
- In the “Assignments” section, you should see Homework 1 listed. Open it.
- Any time you start an assignment, your first step is to click on the “create a repo” button at the top right corner
- Clicking on this button will create a private repository that contains the source code for the NYU version of xv6 (or other starter code if an assignment is outside of xv6)
- The repository is owned by Anubisand shared with you as a collaborator
- All of your work should be completed within this repository, and the only committer can be Anubis (through the cloud IDE).
- The state of this repository at the time of the due-date is what will be graded.
- Immediately after the repository has been created by Anubis, go and claim it! (Seriously… immediately… these invitations expire and they cannot be resent) – click “view repo” where the create repo button used to be, and you will be taken to an invitation page on GitHub.
1.C – First Boot
Start up your container and your IDE by clicking on “Open Anubis Cloud IDE” and follow the prompts. This will open up a VScode window in your browser. Click first on the folder icons at the top left to see the contents of your container (which should match your repository in github), and then click on Terminal on the menu bar in order to start a terminal on your Anubis container.
You should be able to boot xv6 immediately. Here are some commands for setting up, booting, and tearing down xv6 (in your vscode session on Anubis, open a terminal and execute these from the root directory of the assignment code where the Makefile is located):
- make qemuwill compile, link, prepare the filesystem, and boot xv6 using QEMU emulator.
- You should see something similar. You now have a shell. Try something like lsto see which binaries are already built and available to you within user space.
- In order to exit QEMU itself, the following key combination/sequence is required: [CTRL+A]then [X]. If you’re on a Mac, sometimes this works, sometimes it doesn’t – we’re investigating. You can shut down xv6 by simply closing the terminal itself and opening a new one.
- This should return you back to your container’s shell. You’ll see that make has generated quite a few new files in the subdirectories. For this course, we’re using “in-tree” builds, meaning your compiled artifacts will live in the same directory as your source code. DON’T DELETE THINGS ON YOUR OWN. Instead:
- make cleanwill remove all of the artifacts that were built, returning you to your original state of just the source files. Any changes to those source files remain, and any new source files you create will remain, it just simply removes any compiled artifacts that it generated.
- Helpful Hint
Within xv6 itself, there are some provided test binaries that can verify the integrity of the OS. usertests in particular is a great way to verify that all parts of the kernel are operating as expected. You won’t need this for this assignment because you won’t be modifying the kernel, but it’s a helpful tool to have around when you do start making changes inside the kernel in later assignments. Feel free to run it now to see what all is tested (and be warned that it takes a few minutes to complete)
Part 2 – Hello, World!
Objective:
Create a user program named “hello” that prints “Hello, World!” to the console.
User call:
hello |
Expected Output:
Hello, World!
|
(you must include a single newline character after the !)
IMPORTANT REQUIREMENT:
EVERY user binary in xv6 must use the xv6 system call exit() to return from the main() function. Some binaries also use exit() as a way of terminating when there are unhandled or invalid program states, but at the very least you must use exit() at the end of your main() (instead of returning an integer).