CO527 Anonymous Questions and Answers |
This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.
We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course.
Submission reference: IN782
In response to Question 19 (2006), by "cell" I meant the length of each element of the inode table. I assumed that we got output like (3 - 3) because the length is one, therefore the block it starts on is also the block it ends on. My code was just me trying to do that, but is that what we're meant to be doing?
Yes, that's correct.
Keywords: coursework
Submission reference: IN786
Hi, Tried to compile the Java files using the "java c *.java" command and an error appeared which stated that there was an:
'Exception in thread "main" java.lang.NoClassDefFoundError: c'
I also tried compiling using BlueJ v2.1.3 (Java SDK v1.4.2_13) and four of the classes: "VDDev"; "Harness"; "DiskSchedulerFIFO"; and "BounderBuffer<T>" all had various compilation errors.
What's wrong and how do I get them to compile? Sorry if this isn't the right place to put such a question. Thanks :)
The "javac" command is the Java compiler; the "java" command is the Java interpreter (virtual machine). You've introduced a space in what should have been the first of these commands -- Java's telling you it can't run a class called 'c' because it doesn't exist.
As for the compiler errors, that's because this requires Java 1.5.0. Time to upgrade :-).
Keywords: coursework
Submission reference: IN787
I've having a few problems working out how to access the data for the inode tables. I've read the AQP and I understand that the data is stored in two arrays - however, I don't know how to access these arrays. I thought about using 'read_ubits' but this returns an int and not an array - is this a wrong approach?
I tried to explain the arrays in the answer to Question 10 (2006). They're nothing special really, just a consecutive series of values. Using "read_ubits" to read the values wouldn't work correctly; as the documentation for this method says, "Note: this will not work over byte boundaries, currently.". And each value in that array is 32-bits (the "uint32_t" type).
Reading individual values from these arrays is the right approach, rather than attempting to read the entire array in one go. As for reading those values, there's a method in the 'BM' class which reads 'uint32_t' values quite nicely..
Keywords: coursework
Submission reference: IN790
Hi, In regards to the first OS Programming Exercise, I've completed it, but I'm interested in how you intend us to deal with the list of inodes and their lengths. Since all the inodes are the same length (1), would it suffice to simply put something like:
[snip code that only deals with the offsets array]
Or would you prefer us to specifically query the 32bit int array for the lengths of the inodes and output that ... ? I'm thinking more in terms of what happens in a situation where some of the inodes are larger than one disk block. Cheers.
Assuming that the inode lengths are always 1 isn't a good idea. About the only safe assumptions you can make are: that the superblock values are in little-endian byte-order (which you don't need to worry about, because the BM class takes care of that); that there are 16 inode tables ('SFS_NTABLES'); and that the magic string is (in hex) "deadbeef". One of the things I'll be testing is that larger disk images (where the inode tables occupy several blocks each) print the correct values. So yes, your code should use the values in the 'itable_length' array.
Keywords: coursework
Referrers: Question 39 (2006)
Submission reference: IN791
How can we retrieve the array from the superblock so that we can use it to get the values of the inode table?
See the answer to Question 23 (2003) - don't try and read those arrays whole (you can do, but it doesn't really help). Read the values out individually instead.
Keywords: coursework
I have a few questions about the assessment I was hoping you would be able to help me out with. For the second part you state, check the file-system 'magic' bytes for the values specified. Is this a legitimate way of doing so?:
//let's check the magic int[] magic = new int[4]; magic[0] = Integer.parseInt("DE", 16); magic[1] = Integer.parseInt("AD", 16); ... [snip code]
Obviously the check above will only work for that particular magic value -- is that what you were after?
Secondly, can we use the "BM.tohexbuf()" method for the first part of the assessment when printing the 'magic'?
Third and finally, while I get the correct output, is this the correct way of doing the inode tables:
[snip code]
As far as comparing the values goes, what you have there will work, but it's a long way around. Calling on "Integer.parseInt" is a needless overhead. The loop to check the values is fine (there are simpler ways, however); setting up that array could be simplified to something like:
int[] magic = new int[] { 0xde, 0xad, ... };
As to the question about the check only working for one particular magic value, yes, that's what's wanted.
In answer to your second question, yes, you can use "BM.tohexbuf()" to do this (any other way is likely to be less pleasant).
For your third point, nope, that code isn't quite right. For instance, if one particular inode table had offset 123 and length 4, it should output (123-126). Your code will output something different.
Keywords: coursework
Referrers: Question 32 (2006)
Submission reference: IN792
Hi, I'm a bit confused about the line:
Inode tables at : (2-2) (3-3) (4-4) (5-5) ...
The first number in each tuple is obviously the location However for the second, is that the location in which the inode tables end, hence if the lengths were 2 instead of 1 would the output would be more like:
Inode tables at : (2-3) (4-5) (6-7) (8-9) ...
Or am I barking up the wrong tree. Cheers in advance :)
Yes, the tuples consist of the starting-block and ending-block numbers. The answer to Question 8 (2006) says this!
Keywords: coursework
Referrers: Question 43 (2006)
Submission reference: IN793
Hi, I'm having problems running the program. I have followed the instructions you gave on the website. After compiling the project with javac, I have typed "java Harness test.dsk". This however, is giving me an error saying "Exception in thread main java.lang.NoClassDefFoundError:Harness" I am a little bit confused by this. I would be grateful if you could tell me how I can fix this problem. Many thanks.
It sounds like your classpath is wrong. You need to have the current directory, "." in your 'CLASSPATH' environment variable, or pass it as a parameter to the 'java' command:
java -cp . Harness test.dsk
On raptor, the 'CLASSPATH' environment variable already contains the current directory. Setting it in your environment is probably more sensible than passing "-cp ." by hand each time..
Keywords: coursework
Submission reference: IN794
Hi there, I would be grateful if you could tell me how I can use the program within BlueJ. How do I get BlueJ to run with the test.dsk file ? Thanks for your help.
I assume you've imported all the various .java files into a new BlueJ project -- if you haven't, do this first. To run the program, select the "static void main (String args[])" method from the 'Harness' class. BlueJ should prompt for arguments to be given, pass it the name of the disk image ('test.dsk'). You might need to pass something like " {"test.dsk"} " to the BlueJ prompt, I can't remember.. (and graphical Java apps don't work quite right on my desktop).
Keywords: coursework , bluej
Submission reference: IN797
Hi, I'm getting a warning I was hoping you'd be able to help me out with.
BoundedBuffer.java:42: warning: [unchecked] unchecked cast found : java.lang.Object[] required: T[] buf = (T[])(new Object[size]); ^ 1 warning
Ignore it. It's a result of a deficiency (of sorts) with the generics mechanism in Java. The methods to get rid of the warning aren't at all pleasant (hack hack hack). If you're interested, I found this stuff on a Java forum. Google throws up a few more related things.
Keywords: coursework
Submission reference: IN795
Am I right in thinking that for printing the file system version, I just need to use "int fs_minor = BM.read_uint16 (superblock, 6);" as you gave on the webpage, and then just call that within a print statement? Or do I need to query the superblock for the major version? Thank-you.
If you didn't already know, version numbers tend to be written as follows:
major.minor major.minor.patch
So yes, you do need to query the superblock for the major version as well.
Keywords: coursework
Submission reference: IN796
I am bit confused as to how to print the file system magic. I have an int variable that stores the result from querying the superblock at byte 0. But the file system magic is a string. I would appreciate it if you could point me in the right direction as to how can I use the "read_uint8()" method in 'BM' (which takes an int), to return a string? Would casting be the correct method? Thanks alot.
If you want to know whether casting would be the right method, try it out and see.. You'll probably find that it won't compile. You could put the number in a string as you would do normally in Java, i.e.:
String str = "" + sbval[0] + ...;
But this would produce a string containing decimal digits, not hexadecimal ones. You can do it using the methods Java provides, specifically see the format() method in the 'String' class (documentation). But there is a simpler way - see the answer to Question 26 (2006).
Keywords: coursework
Submission reference: IN798
Hi, I was wondering if you could tell me if I've got this remotely right? I've tried to make it so the method will work even if the table length is greater than one:
[snip code]
Thanks very much.
Yes, that appears to be right (assuming it generates the correct numbers!). But it not the nicest of code.. I'm slightly against excessive variable naming, such as "itable_length_offset_place" (26 chars); in the absence of syntax highlighting it clutters the code somewhat. "l_offs" might be a more concise name (and you can always add a comment at the declaration to explain what it's for).
This isn't just me being picky by the way - if you look at real OS code, concise variable names are normal (makes the code easier to read, particularly if it's complex).
Keywords: coursework
Submission reference: IN799
Hi, concerning the second part of the coursework, I know there's been a few questions on it, and you said to do 4 8bit comparisons but whats stopping you doing it like this:
String magic = BM.tohexbuf(superblock, 0, 4); if (magic.equals("deadbeef") { ... } else { ... }
Because it relies on the BM.tohexbuf() method returning a lower-case string. I could fairly legitimately have it return 'DEADBEEF' or '0xDEADBEEF' or 'DE AD BE EF' for that data instead. Clearly it's all the same value though. This is why it's better to compare the value, not the string representation of it. See also Question 7 (2006).
Keywords: coursework
Submission reference: IN800
In 'SmallFS.java' it has a TODO which asks for values to be checked to be correct. What would you like it to do if it finds an incorrect value? throw an exception or just output in the terminal window the details of the error? Also I am guessing that it should only check that all values are positive or is there other checking aswell?
There aren't any TODO comments in that file - do you mean the assessment question..? By "incorrect value" I assume you're referring to the magic bytes at the start of the superblock, but in any error case, the code already there tells you what it should do:
/* * ... * * @return 0 on success, non-zero on failure */
As for checking the validity of other values, any numbers returned from methods in the 'BM' class will be positive -- it can only interpret unsigned values ("unsigned" means positive-only, effectively, but you should already know that :-)). But you don't need to check any other values for this part of the assessment (just the magic bytes). If other values in the superblock are logically wrong, they'll just get printed wrong for now (e.g. more used inodes than total inodes).
Keywords: coursework
Submission reference: IN801
Hi I am having a slight problem in printing the file system magic. My code currently is:
String magic = BM.tohexbuf(superblock,0,8);
However, this is returning me "deadbeef00000100" I am a little unsure as to why this is. I would appreciate any help you could give me.
The magic is 4 bytes long (from the C header file). Your code is generating a string for the first 8 bytes. 1 byte = 2 nibbles = 8 bits = 2 hexadecimal-digits.
Keywords: coursework
Submission reference: IN802
For printing the total number of inodes, do we need to query the superblock? I say this because in the assignment documentation, you say it is safe to assume that the size of the arrays are both 16. So by carrying some simple calculations the resultant total number of inodes (1024) can be derived. Is this acceptable or should the superblock be used to get the size of arrays ?
Deriving the number of inodes from the number of inode tables further assumes some particular calculation, which there isn't. Query the relevant superblock field to get this.
If you think about it, deriving the number of inodes from the number of inode tables is a bad idea: if I have this file-system on a 400 GB disk, there will still only be 16 inode tables - and by your calculation, 1024 inodes (which would be somewhat inadequate). This maybe assumes you know what an inode is for (something which you can glean from the C header file containing the superblock structure).
Keywords: coursework
Submission reference: IN803
Hi I am a bit unsure how to go about finding out whether or not an inode is being used or not. I would appreciate it if you could point me in the right direction. Thanks.
You don't have to find out whether a particular is used or not; just the total number of used (and free) inodes. Handily, the number of used inodes is given in the superblock structure (called "iused" in the C header file, next to the total number called "itotal").
Keywords: coursework
Submission reference: IN804
I'm having some trouble with outputting the inode table. I've got the following code but am not confident that its right..
[snip code]
Also the next part of printing the total inodes I am unsure about. Also I dont understand about printing out the used inodes as 1. Surely 16 are printed in the table?
For the first part, see the answers to Question 24 (2006) and Question 14 (2006). For the second part, only a single inode is used (in the disk image I've given you), so printing 1 is correct. The table displayed is information about the inode-tables (on-disk structures of inodes), not the inodes themselves.
Keywords: coursework
Submission reference: IN805
Would you say this is a good/efficient method of the second part of the coursework?
[snip code]
Yep, that looks pretty reasonable to me.
Keywords: coursework
Maintained by Fred Barnes, last modified Thu May 8 12:58:00 2014 |