



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




September 15, 2008 The following description applies to ASST1a andASST1b.
diff files, commonly called patches, describe the difference between two source code directories. When a change is made in source code, and this change needs to be communicated to others, it is convenient to supply only the change itself to others in a compact and easily readable format. For example, the current Linux kernel source code tree is over 200MB (~40MB when compressed). It is a lot more convenient to communicate a change to some of its files as a single file that describes the entire collection of changes. Such a file could be quite small (a few kilobytes or even less), in comparison to distributing another 40MB file containing the changes. Additionally, if this diff (patch) file is generated by automated means, it guarantees that one will not forget to attach some of the parts of every file that might have been changed. Patch files are one of the most widespread, and accurate, mechanisms for distributing source code changes. B) CREATING A PATCH FILE: A patch file will be used to submit a soft copy of your implementation of the ASST programming assignments for OS/161. There are two directories that are needed for the creation of a patch file. One is your current working directory with your modifications, os161-1.10_asst1 and the other is an unmodified baseline directory (as obtained from the tarball) also initially called os161-1.10_asst1. Both need to be prepared (including being renamed) in a certain way so that the patch can be created in a way that it can be tested by the TA and grader in the environment on their machines. The following steps show how to do this. Preparing your working directory for the patch:
1. rename your os161-1.10_asst1 working source directory to os161-1.10.ASST1 with the mv command. For example, assuming you have worked in the directory os161-1.10_asst1 , as extracted from the archive, use the command: mv os161-1.10_asst1 os161-1.10.ASST This both adds a suffix to make patch naming convenient and makes the directory name os161-1.10_asst1 available again for the tarball extraction procedure. 2. Just as you did when compiling os161-1.10_asst1 for the first time proceed as follows: $ cd os161-1.10.ASST $ ./configure $ make $ cd kern/conf $ ./config ASST $ cd ../compile/ASST $ make depend $ make && make install These steps just run the configure script for os161-1.10.ASST1 and then build a new os kernel and install it in cs161/root as kernel-ASST1 in the same way we did for os161-1.10_asst after extracting it from the tarball.
3. Now your modified sources will be in the os161-1.10.ASST1 directory hierarchy. You should then follow these steps: $ cd os161-1.10.ASST1/kern/compile/ASST $ make clean $ cd ../../../ /* gets you to os161-1.10.ASST1 / $ make clean $ cd .. / gets you to your home directory */ Preparing a baseline directory for the patch: You need to do this only once and use it to create as many patches as you want as long as you don't touch it.
Looking at the diff program, you can see that it uses the suffix of the modified directory name for the prefix of the patch name. So the reason for changing the name of the source tree that was going to be modified from os161-1.10_asst1 to os161-1.10.ASST1 was to set things up so that our patch containing changes would be named ASST1.patch. TESTING YOUR PATCH FILE To be sure that your patch is correct and will work when we grade it you should test it as indicated in this section. This is the way we will test it. There are actually two reasons why your patch might not work. Your program could be incorrect or the program could be correct but the patch not be properly generated. As the graders view it, the patch file is the final word on whether your program works. On ASST1a it is worth 4.8 points and on ASST1b it is worth 6. points .That is it counts as 40% of the project grade on these assignments although it was only worth 1 point and about 17% of the grade on ASST0. There is no partial credit for patches. So on the ASST1 assignments, your patch grade is full credit (4.8 or 6.4) or 0!! The following is the equivalent of how we will apply your patch files to test them and grade you:
1. Starting with os161-1.10.ASST1 (your working copy of the modified source), os161-1.10_asst1.original (the renamed copy of the baseline os161-1.10_asst original from the tarball) and ASST1.patch (the diff file you created above) in your home directory, save your working copy of the modified source in case you need to continue modifying it later. $ mv os161-1.10.ASST1 os161-1.10.ASST1.saved 2. create a new baseline directory named os161-1.10.ASST cp –r os161-1.10_asst1.original os161-1.10.ASST 3. Then use the "patch" utility to make a test run by applying your patch ASST1.patch to os161-1.10.ASST1 (which is a copy of the original os161-1.10_asst1 renamed for patching purposes) to see if the patch applies cleanly to it: $ patch --dry-run -p0 < ASST1.patch The patch utility should produce something like the following output: patching file os161-1.10.ASST1/kern/asst1/catsem.c patching file os161-1.10.ASST1/kern/compile/ASST1/depend.mk patching file os161-1.10.ASST1/kern/compile/ASST1/vers.c patching file os161-1.10.ASST1/kern/compile/ASST1/version 4. If the patch could be applied with no conflicts as above, then do the following to actually apply it. $ patch -p0 < ASST1.patch This inserts the source code modifications contained in ASST1.patch that you got using the diff utility on the original and modified sources into a copy of the original unmodified os161-1.10_asst1 files now called os161-1.10.ASST.
Looking back, the rationale for the rather convoluted series of copies you have gone through can be seen. The patch utility is set up by default to apply patches with prefix names such as ASST1 , i.e., ASST1.patch , to original directories with the same suffix name, e.g., os161-1.10.ASST.
5. Now starting in the os161-1.10.ASST1 directory, use the patched os161.1.10.ASST1 sources to construct a new kernel object with your modifications as you do in the Building and Installing OS/161 Source Programs for ASST1a steps in the ASST1a write-up and check that this new kernel works the same way as your original modified and debugged kernel did by booting it and executing the command that invokes your synchronization program, e.g., catsem. If it did not, change the name of os161-1.10.ASST1.saved back to os161-1.10.ASST (overwriting the patched OS161-1.10.ASST1 that you just created which was not properly working) and continue the debugging, modifying, configuring, compiling, running and patching procedure until you have fixed the bugs in your synchronization program or your patching procedure. If the patched os161-1.10.ASST1 worked, then use the following procedure to send the patch, ASST1.patch , to the TA and grader. Note: More can be found on the diff and patch utilities with the linux man diff and man patch commands.
Note: before submitting your patch, check its size. The size of the patch file should be about 9KB. If the size is much greater you need to reexamine your procedure for creating it. Please, do not submit files with sizes in the range of MBs. Your patch file must be sent using to the MyASU CSE430: Operating Systems (2008 Fall) Digital Drop Box. Here is how to do it.
1. download your patch from one of the 5 BY214 machines to the PC you are running on. Don’t convert its type. It should remain a .patch file. Use the single sign-on for myASU blackboard