XML

kent logo

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.


Question 61:

Submission reference: IN2927

Does the character echo program only echo one character a each poll, or can it echo multiple characters?

Answer 61:

It deals with a single character (8-bit ASCII byte) at a time. In slide 31 of lecture 9 the character being echo'd is stored in r16 — an 8-bit register, so it can only be a single character. Only at the end of the program does it loop for the next character. This of course means that if flow control is disabled, data will potentially be lost should the program not react fast enough (not a problem here, assuming a 38000 baud serial line vs. a 16 MHz processor).

Keywords: avr , usart


Question 62:

Submission reference: IN2928

In the mock paper what does the JEnb signal do?

Answer 62:

This is just an enable signal, "jump enable" in this case. The idea is that the comparator wouldn't look at its input, nor drive its output, until this signal goes high — i.e. the comparator should only be active at certain stages, not all the time.

Keywords: exam , architecture


Question 63:

Submission reference: IN2930

I don't understand how block requests are being given to the lower level code. I understand that it is to do the with private class at the top but I don't understand how the private class knows which block to process/pass. How does it do this?

Answer 63:

It doesn't — only the DSched class knows which block to pass next. Although this code necessarily uses classes and objects, it's not object-oriented as such (operating systems [broadly speaking] are not object-oriented either). So don't think of ReadReq (the private class) as being some meaningful object-oriented object, rather it's just a convenient way of storing information about a request that needs to be serviced at some point.

See also Question 56 (2013).

Keywords: assess5-1314


Question 64:

Submission reference: IN2931

For the assessment, when does the simulator know (or thinks it knows) when all requests have been serviced?

Answer 64:

The simulator is what produces the requests in the first place (from a file or dynamically and continuously generated). The simulator terminates when it has got nothing left to do, at which point hopefully all blocks have been serviced! Technically, the simulator terminates once it runs out of events (around line 1115 in DiskSim.java).

Keywords: assess5-1314


Question 65:

Submission reference: IN2932

Can you please provide some useful links that can help us with the assignment. I have found nothing that explains an algorithm in enough depth that I can then attempt to turn into code and it's really starting to annoy!

Answer 65:

I assume you've read the slide-deck (?) but am slightly concerned that you cannot find anything useful online. I just Google'd for "SSTF and FIFO" and all the hits look relevant. Also I'd expect most OS textbooks in the library to have some coverage of this and there are a lot of them. But these are not complicated algorithms (or at least they shouldn't be!) — not compared with algorithms like general graph algorithms, AVL trees or quicksort/mergesort. As a last resort, email me and arrange a time where I can go through this with you.

Keywords: assess5-1314


Question 66:

Submission reference: IN2933

Is there any reason why I would only get:

    finished at time 295 with 4 pending queues
    disk spent 31 idle, 253 seeking to track, 11 reading 15 blocks

and no more information?

Answer 66:

Because there's no more information to give. What's happening here is that your implementation is losing requests — 4 of the request queues had outstanding blocks. I'd suggest you make a much smaller requests file (just a handful of blocks, or maybe just two initially) and then run with the "-v" flag (verbose) to try and figure out what's going wrong. As always, your own debugging printouts are probably useful too (just so long as these are removed/commented before submitting!). This is a bit different from errors such as in Question 57 (2013) and Question 23 (2013) — rather than returning wrong blocks, your code isn't returning any (or all).

Keywords: assess5-1314


Question 67:

Submission reference: IN2934

I have been looking a multiple versions of C code on Google. I have noticed one thing in common that they all have a head starting track. I can't seem to find this in the code provided (unless I'm not seeing it). Can we assume that there is no head starting track and therefore set it to whatever we deem appropriate.

Answer 67:

See Question 27 (2013). But don't just convert someone else's C code to Java for this, that's potentially plagiarism if you don't acknowledge the source! The point of the assessment is to understand and implement a disk scheduling algorithm, and you don't need to look at [real] code for that!

Keywords: assess5-1314


Question 68:

Submission reference: IN2935

Are we allowed to add extra methods? Such as for building new data structures?

Answer 68:

Yes, that's fine (extra methods). If you needed extra classes, make them inner ones: submission is just the DSched.java file, nothing else. (any extra classes you create should just be wrappers for structured data, like the one already there). This is not, and should not, end up looking overly object-oriented.

Keywords: assess5-1314


Question 69:

Submission reference: IN2936

Where can I find the answers to the mock paper questions?

Answer 69:

You can't — see the email I sent!


Question 70:

Submission reference: IN2937

In the readcomplete() method, is the blk parameter the last block read?

Answer 70:

Assuming that it is >= 0, then yes, but not always: if the disk was idle at some point (i.e. no more requests for some period of time) then this will be called with an invalid block to say that the disk is idle and is ready for more.

Keywords: assess5-1314


Question 71:

Submission reference: IN2938

I am currently trying to set up the 5th Assignment so that i can easily work on it. Due to being at home (and the kent VPN is not working for me at the moment) I can't access my raptor files directly. I have used PuTTY to follow the raptor quick start and everything compiles and runs fine, I just now can't easily modify the DSched.java there. I tried importing a version into eclipse but the DiskSim doesn't have a main() to run (I feel I am missing something obvious here).

Would it be possible to explain how to get everything to work in an IDE like Eclipse or how I could possibly modify easily the DSched that is already on my raptor space without the VPN.

Answer 71:

Obviously there is a main() method in DiskSim, else the command-line way of launching it would fail. I wouldn't recommend using any IDE though — too cumbersome and not needed (wrong tool for the job I feel). But people have not reported problems in the past, so maybe your Eclipse is broken.. Not using Eclipse I can't help you I'm afraid. But there should be no problem editing the file on raptor, or transferring it to/from raptor between local edits. Editors like vim and pico will be available on raptor, but it might be easier to edit locally (Notepad++) for instance and then use WinSCP (SCP/SFTP) to copy the files to raptor. Or even better, edit the files locally, and run the simulation locally — just from the command-line, no need for fancy IDEs! Because the Windows environment sucks for programming (frankly) you might want to consider installing something like cygwin to give you a command-line that won't drive you insane. Or fix the VPN issue.

Keywords: assess5-1314


Question 72:

Submission reference: IN2939

I would like to use the C-SCAN approach, so I tried to build an array of queues, one to hold current requests, sorted, and th eother (idle queue) to store new requests. After the active queue is emptied, the two queues will be swapped around. However, at the end of operation there are still "pending queues" and the score value isn't reduced very much. What would cause the "pending queues" problem and is there any problem with my method? Is that some blocks are missed during the swap of active and idle queues?

Answer 72:

If you have pending queues, this is an error, and the score value means nothing (but in most cases it's better to try and continue rather than just stop hard). It sounds like blocks are being lost from either queue, so double-check the code. Even better, print out the contents of both queues at various places and see if they're as they should be — you'll probably want to create your own small request files to check for correctness, of course. I would hazard a guess that it's the sorting that's broken, as this is usually where errors creep in. Swapping queues should not involve anything other than pointer manipulation (or equivalent; it depends on what you mean by "array of queues" precisely).

Keywords: assess5-1314

Referrers: Question 93 (2013)


Question 73:

Submission reference: IN2941

I'm a little unsure as to how the scoring system works for assignment 5. Is lower better? Or higher? The supplied FIFO gets a score of 8701 on requests-big.txt. My SCAN implementation gets a score of 12944, I was under the assumption that lower was better as when I run requests.txt my score is lower than the FIFO implementation. Below is the output from requests-big.txt for my implementation.

finished at time 104787 with 0 pending queues
disk spent 21 idle, 92257 seeking to track, 12508 reading 2105 blocks
time for request in queue (min, max, avg): 0	, 103159, 2679.5  +/- 10210.2
time for request in read (min, max, avg):  1	, 259  , 49.8  +/- 64.1
time for request total (min, max, avg):    14	, 103176, 2729.2  +/- 10214.8
Score value: 12944

Answer 73:

Lower is better — it represents a time value: average plus deviation. I think your implementation is broken. My SCAN implementation (which is nothing special) reports around 2400 for requests-big.txt.

As explained elsewhere, just because a particular algorithm works well on one dataset, doesn't mean it'll work well on all.

Keywords: assess5-1314


Question 74:

Submission reference: IN2942

Where in the array should the C-SCAN add to?

Answer 74:

This is too specific a question, and unsuitable for anonymous Q+A pages! (as it only applies to people who have done C-SCAN using an array that is perhaps sorted somehow).

Keywords: assess5-1314


Question 75:

Submission reference: IN2943

Will all of the requests be submitted immediately or spaced over random time periods in assessment 5?

Answer 75:

Neither.. But it shouldn't matter. If you really want to find out, put together your own request files, run with verbose on and observe.

Keywords: assess5-1314


Question 76:

Submission reference: IN2944

I am getting the same error as in Question 23 (2013). Should entries be removed from the data structure once they have be completed? I have tried this by setting the blk in the data structure for a just read block equal -1, but then my program just stops and doesn't return anythings.

Answer 76:

Just setting the block number to -1 would work, but breaks its use as a queue — since now it will have "holes" for blocks that have already been dealt with. The slide-deck explains one way of handling this, which is swap that block (no longer of interest since it's been read) with the last one in the queue, and reduce the size of the queue by 1 (safe since the last item is now the done one). Again though, try a small request file and add debugging; something must be going wrong somewhere! When you say your program stops though, check to see if it's just eating 100% CPU (not stopped, but livelocked) that would suggest a non-terminating loop somewhere in your code.

Keywords: assess5-1314


Question 77:

Submission reference: IN2945

Hi, I don't have a clue where to start on assessment 5. I have read through all the material on Moodle and have conducted my own research online, but still cannot comprehend how to undergo the task. I have spoken to a large number of people and they all seem to be really struggling. Any more help would be very much appreciated!

Answer 77:

There are a few things that you need first (before attacking the code) in terms of understanding:

  1. An understanding of the problem: that disks are physically laid out in heads, tracks and sectors; that moving the read-write head between tracks takes time; thus there is a tangible benefit in ordering disk requests sensibly to minimize the amount of spent moving the head compared with the amount of time spent reading.
  2. An understanding of the code already present: i.e. how the (simulated) OS dispatches read requests (it calls blockread()) and how it informs the disk scheduler that a read is complete or that the disk is idle (it calls readcomplete()). Once a read has finished, the disk can accept another request immediately (if there is one).
  3. How the algorithm (FIFO and LIFO are given) is embodied in this code, by means of a request queue (called readqueue and readstack in the different implementations).

Hopefully you understand the problem, but understanding the code may be more of a challenge. If the whole head/tail thing in the FIFO implementation is causing confusion, start with the LIFO implementation instead (DSched-lifo.java) — this has a fixed-size array that acts as a stack. The way the simulated OS interacts with the disk scheduler code is not straightforward. Logically there are two fairly independent things going on: OS generating read requests at some arbitrary rate; and the disk processing requests one at a time. These things interact through the DSched code: new requests are added to a stack (or queue), and when the disk is able to accept another request, this is taken off the stack (or queue).

The code isn't deliberately intended to be complex, but that is the nature of such things in an OS. As we said early on in the module, part of the OS's job is to manage lots of things going on at once — this is part of that. If anything, this is much simpler than a real OS, that also has to deal with concurrency issues, such as protecting shared data structures. The simulator is completely single-threaded, whereas a real OS has things happening inside interrupt handlers (disk read complete perhaps) and the like.

That aside, a sensible first step in coding is to try and implement something like SSTF. I.e. rather than the bit of code in readcomplete() that picks the last thing on the stack (the entry at index readstack_size - 1), pick the request whose track is closest to the last one serviced. The code deals with block numbers — to get the corresponding track (which is most relevant for disk scheduling) you need to call DiskSim.block_to_track(int blk). Once you've identified which request you want to give to the disk next, you need to send it to the disk (calling disk_readblock()) and remove it from the stack/queue — the simplest approach is not to try and shuffle up the array contents or other complex things, but just swap with the request at the end (which is easy to remove as the existing code already does). The key bit of the SSTF algorithm here is "pick the request whose track is closest to the last one serviced". I.e. you need to search through the queue/stack of pending requests. An alternative is to keep the array contents sorted (and I'd only ever suggest you do this to the LIFO code, not try and mangle a quicksort over a circular buffer — what you end up with is hard). But observe that it's not actually needed: searching the array for the next best request is fine, since it's O(n). In a real OS, this would be an issue for efficiency of the OS code itself, as we would like things to be O(1) or O(log2(n)) preferably.

More complex algorithms such as SCAN, C-SCAN, elevator, etc. (some overlap here depending on whose definitions you read) require more complex implementations. In any case, I'd suggest you start by implementing SSTF — it should perform much better than FIFO or LIFO in general. Once you've got that (and have saved a copy in version-control, as an initial Moodle submission, or as a different file locally so you haven't lost it if you need to go back), then attempt the more complex things. Trying to jump from zero into C-SCAN for instance may be too much for many.

Keywords: assess5-1314

Referrers: Question 80 (2013)


Question 78:

Submission reference: IN2946

I am using the SCAN method and when I test it in --dynamic 32 mode, I get an average score around 6000 and is it a reasonable score? As I think I am doing correctly but the score seems a little bit high...

Answer 78:

My SCAN implementation in this mode came out at around 2500, so I'd suspect something isn't entirely right here. Double-check: run with --vis and a static request file and look to see if the SCAN is working in the way it ought to be. You can always construct your own request file (I'd suggest writing a script to do this if more than a handful of lines) so you know what behaviour to expect.

Keywords: assess5-1314


Question 79:

Submission reference: IN2947

I'm getting a lot of "logical errors". Stderr is full of lots of "highlevel_didread(): read queue foo got unexpected block bar". What does this mean? Is my implementation useless as a result?

Answer 79:

See Question 30 (2013). But yes, unfortunately, it means your implementation is broken and won't score anything in effect. At this point you need to start writing your own request files (starting with just a few blocks perhaps) and debug — running with "--verbose" or putting in your own "System.err.println(...)" statements.

Keywords: assess5-1314


Question 80:

Submission reference: IN2948

Is that I should compare between the track number rather than the block number when I try to sort the queue?

Answer 80:

As I've said in Question 77 (2013), don't try and sort a queue. This is just hard. Much easier if you start with the stack version (LIFO implementation). But yes, things like SSTF and others are (should be) concerned with the track number foremost, since changing tracks takes time.

Keywords: assess5-1314

Referrers: Question 87 (2013)

Valid CSS!

Valid XHTML 1.0!

Maintained by Fred Barnes, last modified Wed May 25 15:07:20 2016