XML

kent logo

CO538 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.

When asking questions, please do not simply paste in your code and ask what is wrong with it, as these types of question are hard to answer in a public forum (resulting in either no answer, or an answer which will only be of use to the person asking the question). In many cases, a question about code can be formulated in general terms. For example, if you have an `IF' block that results in an `incorrect indentation' error, you might ask, ``what is the correct syntax for an occam `if' statement ?''. Questions of this form are easier to answer, and are meaningful to all.

Questions that are not suitable for these public pages (i.e. those that contain assignment-specific code), should be mailed to your seminar-leader.


Question 141:

Who is doing the revision session on Friday? I would find it handy to have some revison on C and hard occam topics such as how to write PROCs with timeouts e.t.c. and a run through of JCSP (what we need to know).

Answer 141:

It will be your usual seminar leader.


Question 142:

If I am stuck on a question in the exam, if I write out the algorithm and say what I intended to code, will I gain any marks ?

Answer 142:

In all likelihood, yes (assuming such an algorithm is correct, or heading that way).

Keywords: exams


Question 143:

Hi, I can't remember from last year, but if we want scrap paper do we get given any if we ask, or is some made available anyway ? Its just I have found I need to do a lot of scribbling before I produce understandable code (for you to mark :)).

Answer 143:

You use the back of the answer book and put a single line through it (in pencil preferably, i.e. a big / across the page). The reasoning being that if you botch the answer, we can look at your rough work to see what the process might have been (and award marks accordingly). Just for the record, please don't use tip-ex, or heavily scribble something out.

Keywords: exams

Referrers: Question 149 (2004)


Question 144:

What was the point in the Q How many anonymous questions did you ask ? Is it to see how many people use it ?

Answer 144:

Basically yes, and to get some indication of the distribution.

Keywords: questions


Question 145:

In Q3(c) of the exam 2003 I did the following for the watch process:

  PROC watch (CHAN INT in?, out!, CHAN BOOL error!)
  INT count:    -number of consecutive zeros
  SEQ
    count:= 0
    WHILE TRUE
      INT i:
      out ! i
      SEQ
        in ? i
        IF
          i=0
            SEQ
              count := count + 1
              IF
                count = 5
                  SEQ
                    error ! TRUE
                    WHILE i = 0
                      SEQ
                        in ? i
                        out ! i
                    error ! FALSE
                TRUE
                  SKIP
          TRUE
            count := 0

Is this correct? I think it is, but I am not sure if I am outputting to the correct channel...

Answer 145:

These sorts of (code-based) questions are best directed at your seminar leader, but given the closeness of the exam..

You'll see that I've edited your code slightly -- evened out the indentation and separated an IF combined with its first condition. In answer to the question, yes, the code is mostly correct. There are some small things though. Firstly, the first output is in the wrong place -- it should go after the input in the SEQ. I.e.:

    WHILE TRUE
      INT i:
      SEQ
        in ? i
        out ! i
        IF
          ...

The second is that non-zero output after 5 or more zeros doesn't cause "count" to be reset, so if more zeros then come in (say infinitely more), "count" will keep getting incremented until "count := count + 1" overflows (and the last "error" output was FALSE). Not fatal for the exam, but pretty bad news for a nuclear reactor!

Keywords: exams


Question 146:

Does the new rubric mean that both the occam questions will be code based ? As opposed to the 2004 exam paper where the second question on occam was more knowledged based asking questions about real time systems etc. and not actually requiring more than fragments of code in one instance to be written?

If it is the case that we will see questions such as this, can you give a sample response to the first part of this question:

What extra requirements on real-time systems differentiate them from non-realtime systems.

as I cant seem to find enough on this for 3 marks in the slides or on google. Thanks.

Answer 146:

No, the new rubric does not change the nature of the questions, only the structure of the exam. So you could be asked either (or a mix, in whole or in part).

For real-time systems, the main requirement (generally) is that the system must respond to external events within a given amount of time. This has a variety of implications for programs/systems. Exploring one of these will likely gain you the required marks (using a guideline of 6 minutes for answering the question). E.g. if a "control" process blocks on a channel output indefinitely (say because some external hardware broke down), it might not be able to respond to some other important event until the output completes (which may never happen). How would you go about designing the system so that this doesn't happen ?

Critical for this are tricks like avoiding starvation when servicing data streams from real-time sources -- which we do by `fair'-ALTing -- and the use of overwriting buffers (to discard data that we don't have time to deal with; though we should also record the fact that data *has* been so discarded). See the chapter in the slides on "Managing Hard Real-Time Systems" (chapter 8, I think) and the paper in the course notes with that same name.

The key point: real-time systems differ from non-real-time ones in that their correctness depends not only on the answers they deliver but on the timeliness of that delivery. For example, computing evasive course corrections too late to avoid the crash is not good enough!

Keywords: exams


Question 147:

Question 4e of 2002 exam looks really tricky, I don't know where to start the diagram from. What will the diagram look like ?

Answer 147:

That's kind of a hard question to answer here -- but would have been exactly the right question to ask in the revision seminars last week! But looking at the question, I'd probably start by drawing a big "box" process, and its three channel-arrays. The question talks about a ring of alternate "multiplex" and "catch" processes, so draw those 8 processes and connect up in a ring. Then it's just wiring.

But here goes ... the following is much easier to draw by hand (or a drawing package) than with this ASCII-art!

                                           | |              |
                                    tap[0] | | tap.out[0]   | in[0]
                                           v ^              v
                                           | |              |
             +-----------------------------|-|--------------|-----------------------------+
             |                             | |              |                             |
             |               r[0]       +-------+  r[1]  +------+     r[2]                |
             |       ,--------->--------| catch |---->---| plex |------->--------.        |
             |       |                  +-------+        +------+                |        |
             |       |                                                           |        |
             |       |                                                           |        |
             |    +------+                                                   +-------+    |  tap[1]
       in[3] |    |      |                                                   |       |--------<---
      -->---------| plex |                                                   | catch |    |
             |    |      |                                                   |       |-------->---
             |    +------+                                                   +-------+    |  tap.out[1]
             |       |                                                           |        |
             |       ^  r[7]                       box                     r[3]  v        |
             |       |                                                           |        |
  tap.out[3] |   +-------+                                                    +------+    |
      --<--------|       |                                                    |      |    |  in[1]
             |   | catch |                                                    | plex |--------<---
      -->--------|       |                                                    |      |    |
     tap[3]  |   +-------+                                                    +------+    |
             |       |                                                           |        |
             |       |                                                           |        |
             |       |       r[6]        +------+ r[5]  +-------+      r[4]      |        |
             |       `---------<---------| plex |---<---| catch |-------<--------'        |
             |                           +------+       +-------+                         |
             |                              |              | |                            |
             +------------------------------|--------------|-|----------------------------+
                                            |              | |
                                            ^              v ^
                                      in[2] |   tap.out[2] | | tap[2]
                                            |              | |
The code is easier:

  PROC box ([n]CHAN OF INT in, tap.out, [n]CHAN OF BOOL tap)
    [2*n]CHAN OF INT ring:
    PAR i = 0 FOR n
      PAR
        catch (tap[i], ring[2*i], ring[(2*i) + 1], tap.out[i])
        multiplex (in[i], ring[(2*i) + 1], ring[(2*(i + 1))\(2*n)])
  :

Note: in the above diagram, the names multiplex and ring were shortened to plex and r, respectively.

Keywords: exams


Question 148:

Just curious if you will/have selected any more dining philosopher solutions to add to the raptor answers collection ?

Answer 148:

Possibly -- I've already put one into the KRoC/Linux distribution's set of dining philosophers, but this can't go on raptor because it uses some of the occam-pi extensions (not supported by the version of KRoC installed on raptor). We might put some more in, and put on raptor (if compatible).

Keywords: q7 , model-answers


Question 149:

Relating to Question 143 (2004), Three additional questions I have about the exam:

  1. Can we write out occam and diagrams (if we choose to do them) in pencil in case we make mistakes.
  2. Can we take a highlighter to highlight the important bits from your essay styled Question.
  3. How much of each question do we need to answer if we are taking the 3Q easier route ? For example in the 2004 exam, am I corrcet in thinking if we answered just 3a, b, 4a, b and 5a, b we could get a good mark ? At the end of the day is the advised strategy if we are taking this route to start doing as many of the easy Q's that we can, do John Bovey's C and then of we have time come back to occam and JCSP. It would be handy to know roughly how much of 3 Q's we need to do as all that has been said recently is "Do the easy bits" but I just wanted clarification on exactly how much that is.

Answer 149:

  1. Yes; we prefer diagrams to be drawn in pencil rather than pen.
  2. Not sure whether highlighters are allowed, but it's not strictly necessary -- we'll decide which bits of your answer are important when marking :)
  3. If you answered those quetions you mention, then the maximum marks obtainable for each question would be 9, 7 and 3 respectively. The new rubric states that the lowest scoring question (in the case where you answer 3) is given half-credit. That would be question 5 in this case, so the maximum mark you could get is 9+7+1.5 = 18. Out of 40, that's not high (45%). Having a go at some of the other parts to these questions would probably gain extra marks. But.. if you feel that you can answer two of the questions fully, then do that. Only go down the "easy" route if you find yourself struggling with the later parts of some questions, or know that you can't answer these parts.

Keywords: exams

Referrers: Question 152 (2004) , Question 153 (2004)


Question 150:

What did you say about leniency in syntax errors we won't be marked down on ?

Do they include the following: incorrect indentation in occam (once and several times); forgetting the classes to implement in JCSP; and little Java syntax errors.

Answer 150:

There will be a certain amount of leniency in occam indentation, but only up to a point. I.e. missing SEQs will probably incur some small penalty, but not indenting by exactly 2 spaces will not. Small (trivial) errors will probably not incur any penalty either, e.g. forgetting the colon at the end of a declaration, or putting an array-specifier in a slightly wrong place (writing "INT[2] x:" instead of "[2]INT x:", for example).

For JCSP/Java, same thing probably. Forgetting which class to implement is acceptable as long as you're on the right lines. E.g. if you implemented "Process" rather than "CSProcess", or used an "InputChannel" instead of a "ChannelInput". For syntax errors, small ones are acceptable. E.g. writing things like "new Parallel ({a, b, c}).run ();" instead of "new Parallel (new CSProcess[] {a, b, c}).run ();". Missing semi-colons probably acceptable too. Also, confusing occam's ":=" for Java's "=" ... and occam's "=" for Java's "==" will not be penalised.

In general, simple syntax/class-name errors that would be picked up by a compiler will incur no penalty provided the context of your writing gives enough clues that I understand what you meant.

Keywords: exams


Question 151:

When writing the final class in JCSP, e.g. in the folder Q2 (from the course directory on raptor), the class Q2 has a main() method and does not implement CSProcess. Is this always the case ?

Answer 151:

If it is the "top-level process", then yes; in this case, Q2 is the top-level process (i.e. the overall application/program).

A class should implement CSProcess if something is going to run() it. That might be directly, or indirectly as an embedded process within a Parallel (which is itself, of course, a CSProcess). JCSP processes can be fired up from many sources - e.g. Java applets or applications. In this case, Q2 is a Java application and execution starts from main(...).

You will not be troubled by such considerations in the exam!

Keywords: exams , jcsp


Question 152:

In reference to Question 149 (2004) (highlighters); I meant could we higlight key bits of the exam paper e.g. the bits we need to implement in occam?

Answer 152:

Yes, I think you're allowed to write on the question paper (unless instructions in the exam explicitly say otherwise). I don't think you're allowed to take the question paper away with you, though.

Keywords: exams


Question 153:

In reference to Question 149 (2004) (3 vs. 2 questions); how much of each question do we need to do / how many marks would we need in each section ?

Answer 153:

You should be able to work that out for yourself! -- or write a bit of code to do it (Prolog is good for this sort of thing). The number of marks associated with each part are given, so you could think of a mark and work backwards. The lowest scoring part will be given half-credit, with marks capped at 40 for that section. It's theoretically possible to score more than 40 (and get the mark capped), but unlikely given the amount of time available.

Keywords: exams


Question 154:

Just a quick question about the 2003 past paper. In relation to the JCSP question (q6, part b) on the Merge2 Process, should we be reading in from both the channels in Parallel or ALT over them taking input from whatever one is ready?

I would have thought ALTing seemed best, but the channels given to Merge2 aren't ALTing ones - just standard ChannelInputInts which (as I understand it) you cannot ALT over?

Answer 154:

You are right - you cannot ALT over a ChannelInputInt. You need AltingChannelInputInts for ALT guards. But Merge2 should be programmed without ALTing on its input channels and without reading from them in Parallel!

Before entering the loop, read one number from each input channel - in SEQence, any order.

At the start of the loop, the invariant is that we have the latest number from each input channel that has not yet been output. Look for the smaller one and output it, followed by reading another number from the channel that had supplied that smaller number (which re-establishes the loop invariant) - end-of-loop. Exception: if both numbers are equal, output either of them (just the once!), follwed by reading a new number from each channel (again, in SEQence, any order) ... re-establishing the loop invariant ... end-of-loop.

Keywords: exams , jcsp


Question 155:

When's the latest we can submit a Question here to you before the exam?

Answer 155:

Well ... this is a bank holiday! And we have never answered (or had) questions the day before the exam before!! There is no set time limit but I think time is about out ... in any case, you need to get a good night's sleep ...

Keywords: exams


Question 156:

Where can I find out about the replicated PARS/SEQ's e.t.c. in the occam book?

What does /\, \/, and <> mean in occam?

Answer 156:

Replicators are introduced in Chapter 5 of the course notes. There's a summary at the end of the on-line Chapter 5 slides (which were added after the notes were printed). They are also explained in the "OCCAM2 CHECKLIST" - the first paper following the slides in the course notes.

The operators listed are respectively: bitwise-AND, bitwise-OR and not-equal. Bitwise-AND is an infix binary operator between two INT values (of the same precision) or between two BYTE values. The result is an INT (or BYTE) whose individual bits are the logical ANDs of the corresponding bits of the operands.

(Sorry ... I'm going off-line now. Questions unanswered are all of the form: "Is the following code a correct answer to Qxxx?" ... which we have always said are not suitable for this forum ... see notes at the top of this page. Good luck tomorrow.)

Keywords: exams

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:23 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.