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 101:

Submission reference: IN1159

Hi, I havn’t used the two.motor process to control the robot; instead I made a process to better handle the kind of calculations I wanted as raw angles. Am I likely to be penalised for this?

Answer 101:

Nope – that's fine!


Question 102:

Submission reference: IN1158

Can you give us a rough idea how long would be an acceptable time that the robot should take to complete a circuit of the square?

30 secs? 45 secs? 1 minute ... or two? :)

Answer 102:

Sorry – the people who know are off-line. [It is a bit late really for all these questions to be asked ... you have had around 5 weeks plus 5 terminal classes ... we do our best!]

So long as you can explain your performance (where your system works well and why, where it doesn't and why and, maybe, how it could be fixed if you had more time) in your report, you will do just fine.


Question 103:

Submission reference: IN1174

Did we get additional marks for using shared channels on the dining philosophers assessment?

[Ed: this question has been combined with the following for a single answer.]

There is not much feedback on my dining philosophers assessment, I did not even know what the mark was out of until my friend told me, I would like to know what I lost marks on... seen as my dining philosophers worked and had additional features within it. Who can I ask about this?

Answer 103:

Using shared channels simplifies the solution, which may result in a higher mark. Extra marks were allowed for shared channels, protocol inheritance etc., but markers had freedom to award other marks for specially nice things. Quality (e.g. simplicity, no repetitive lengths of code differing only with magic numbers) and animations beyond the minimum requirement were the main sources of extra marks. Marks over the maximum were not allowed though! Extra marks usually compensated for minor ommisions/errors in otherwise good solutions – resulting in a maximum score.

I'm sorry if your returned script contained little feedback. Some contained a great deal! Below is the marking scheme and guidelines given to the markers, which should let you see how your marks were awarded. If you think your marks do not represent a fair assessment of your work, please contact me (phw@kent.ac.uk) directly. Thanks.

    
            =====================================================
            Dining Philosophers Animation - Marking Scheme (2007)
            =====================================================
    
    This year, they do not have to submit diagrams if their solution is the
    standard one (i.e. 11 reports channels from the college to a multiplexing
    display ... or 1 SHARED report channel from the college to a display).
    
    If they have done something else, they were asked to provide a diagram
    (e.g. a GIF, JPG etc. image in their submission directory or hard copy,
    could be hand-drawn, handed in to CAS).
    
    However, it would be harsh to penalise those who have something more ambitious
    (e.g. with extra animation processes) but a poor diagram.  So, treat those
    diagrams as aids to understanding their system - but no penalty if no diagram.
    Give additional marks for more ambitious animations.  The basic animation
    (run ./a7 on raptor at /proj/ofa/631/answers/) is all they need for full marks.
    
    This year, I never got around to specifying any keyboard interaction - e.g.
    for setting the random number seed to a known start value ... or for freezing
    the display.  Award extra marks if any do this.
    
    Here is the breakdown:
    
      4 : decent PROTOCOL declaration(s) - deduct 2 marks if no commented
          explanation of any component fields of, for example, tagged variants.
          CHAN INT report channels, reporting VAL INT *named* codes, are OK
          but only get 3 marks.
    
      7 : the philosopher PROC - roughly 3 marks for random timeouts when
          thinking/eating (and for getting/setting the seed correctly and
          uniquely) plus 4 marks for making sensible reports.  Note: the
          seed should be set *once* before starting the philosophers and
          passed to each philosopher (who adds his-her id number).  I gave
          them a random number warm-up PROC in the anon Q-and-As (Q55) that
          they should use - but no penalty if they don't.
    
      3 : the fork PROC - for adding sensible reports.
    
      3 : the security PROC - for adding sensible reports.
    
      4 : the code for the networks - 2 for the modified secure.college (with
          all the report channels) and 2 for the top-level network code.
    
      9 : the display PROC - 2 marks for some sensible initialisation;
          6 marks for everything else.  This year, we also never got around
          to making them work out fair alting, :(.  Extra marks if they did,
          though this is only relevant for a report array.  Award extra marks
          if they used a SHARED channel, and more if they used PROTOCOL
          inheritance (so that the phils, forks and security had their own
          protocol and the report channel itself combined all three).
    
    ----
     30
    ----

Keywords: q7 , coursework

Referrers: Question 30 (2008)


Question 104:

Submission reference: IN1177

Hi, I've been looking at last year's exam paper and came across the following question:

    (e)  Write a server loop that receives and processes one PACKET per loop
         from channel deliver. It must save payload data into suitably
         declared variables and process them in some way (leave blank lines in
         your code for this processing ... or use the ‘three-dots’ notation to
         indicate their position). The loop must terminate if poison is received.

Would the following be an acceptable answer to this?

    PROC server (CHAN PACKET deliver?)

      INT x:
      [1024]REAL64 y:
      INITIAL BOOL running IS TRUE:

      WHILE running
        deliver ? CASE
          BYTE size
          payload; x; size::y
            ...  deal with this variant
          poison
            running := false
    :

Thanks in advance.

Answer 104:

The protocol was declared in the previous part of this question:

    PROTOCOL PACKET
      payload; INT; BYTE::[]REAL64
      poison
    :

You would have scored the full (3) marks for your answer above. However, since the largest size value is 255, your array y is unnecessarily large. Also, the variables used for receiving the message should probably be localised just to the reception area – and their declarations, like all declarations, should end with a colon. For example:

    PROC server (CHAN PACKET deliver?)
      ...  local state (declarations and initialisation)
      WHILE running
        deliver ? CASE
          INT x:
          BYTE size:
          [255]REAL64 y:
          payload; x; size::y
            ...  deal with this variant
          poison
            running := false
    :

Keywords: protocol , server

Referrers: Question 66 (2007) , Question 66 (2007)


Question 105:

Submission reference: IN1178

Hi, How many timeouts can be set in occam-pi? What constraints exist on the length of a timeout to guarantee correct behaviour?

I've looked at the slides, checklist and these Q&A pages but I still can't find a definite answer.

Answer 105:

The question you are quoting asks: "How may timeouts can be set in occam-pi?". Not: "How many"! The answer to "How many?" is as many as you like. Further, an individual ALT can have multiple timeout guards.

The answer to "How may?" is on slide 53 of basics.ppt/pdf and/or sections 3.4/3.5 of the "occam-pi Checklist". The answer to "What constraints exist" is on slide 60 of the same set, explained by the previous slides and further illustrated by slides 62-64.

Of course, timeouts may also be set as ALT guards. These work in the same way as plain timeouts, constraints and all. The question only asks how timeouts may be set, so describing plain timeouts answers it – no reference to alting is needed.


Question 106:

Submission reference: IN1172

Hi, I know there were a few things in the slides that you said were not examinable. Could you please state everything that isn't examinable. Thank you.

Answer 106:

The motivation.ppt/pdf slides are just that – there is nothing specific in them that is examinable. The material on blood clotting, in the second half of this show, is only there as a taster for next year's module (Co632)!

Everything in basics.ppt/pdf is examinable. Everything in replicators.ppt/pdf, apart from slides 70-80 on the sort grid (which was put there as a challenge), is examinable. Everything in choice.ppt/pdf is examinable. Everything in applying.ppt/pdf up to slide 60 (i.e. all the material on the dining philosophers) is examinable. Everything in protocol.ppt/pdf is examinable. Everything in shared-etc.ppt/pdf is examinable, apart from the material on on VALOF expressions and FUNCTION declarations (slides 88-93) and data types (slides 94-116). Please note that knowing how to use functions given to you (e.g. random) is expected.

Also examinable are ideas and mechanisms covered in the terminal classes (e.g. the robotics) and seminar groups (e.g. fair servicing of multiple input channels).

Material in the various papers in the Courses\co631\etc\ directory is for background information and not examinable – apart from those that specifically write up material covered by the slides (e.g. o-pi-checklist.pdf and oate-2006.pdf).


Question 107:

Submission reference: IN1196

Is it possible to put a guard on a variant protocol? TRUE & in ? CASE or TRUE & poison doesn't seem to work.

Answer 107:

Yes, but only if that precondition is part of an ALT. You can't selectively precondition against individual cases – that would require the outputting process to first check the inputting process's ability to handle the particular case, which is not supported. Examples of things which do work are:

  ALT
    cond & in ? CASE
      INT x:
      first; x
        P (x)
      second
        Q ()
    INT x:
    cond2 & in ? CASE first; x
      P (x)

Note: the last guarded process above needs explaining. It could have been written:

    cond2 & in ? CASE
      INT x:
      first; x
        P (x)

It's just that if we only have to deal with one of the variants (e.g. under condition cond2 above), we can write out that variant on the same line as the CASE input. It's just a syntactic shorthand, saving one line of code. It's part of the language, but I don't usually bother with it (and never showed it to you).

Keywords: tagged-protocol , alternation


Question 108:

Submission reference: IN1045

Occam is awesome. Why don't we have a choice in the first year to choose this module?

Answer 108:

Good question.. :-). Instruction in computer programming has always traditionally started with sequential languages (BASIC, Algol, Modula, etc.), and this trend continues, except now we have sequentially languages with concurrency bolted on (like Java, C++, C#, etc.). This is what we still do, albeit a bit more paradigm-oriented, with the "objects first" approach. I'm (Fred) of the opinion that a "concurrency first" approach would probably work just as well, maybe even better, as Java is now not a trivial language (as we are historically accustomed to). But you'd still have to learn Java and OO techniques (as this is what most of the world is using at the moment). Perhaps over the next 10-15 years ideas about teaching programming will shift into the concurrency-first arena, particularly as massively multicore hardware becomes available. We'll see :-).


Question 109:

Submission reference: IN1249

Did this course have a different name before last year? I can't find any other past papers.

Answer 109:

Yes, previously this module was CO516 (parallel and imperative programming), and before that CO502 (parallel programming and formal logic). The material taught has changed over the years, in terms of what and how, so there will undoubtedly be some past questions which you can't obviously answer (which are not C or formal-logic!).

Keywords: exams


Question 110:

Submission reference: IN1250

Will the format of this years exam be the same as last years? That is, the first question on OCCAM, then a choice between another question on OCCAM and 2 questions on robotics?

Answer 110:

Yes, the format is the same. But there is no specific topic called "robotics". All the questions will need knowledge of occam and the concurrency model it provides. There is a compulsory part (a) question, consisting of many short questions. Then, part (b) gives you a choice of 2 from 3 questions. Some (or none) of the questions may have a robotics theme.


Question 111:

Submission reference: IN1251

In the 2005 paper, the first question asks, "Explain the difference between a replicated PARand SEQ construct in occam. State any constraints on the process being replicated, giving an example of one that is legal to replicate in sequence but illegal to replicate in parallel".

I'm not really sure what this question is looking for. Does it simply want us to say that you can not monitor and change a variable in parallel, nor output to a channel in parallel or read from a channel? If possible, would you mind giving an example?

thank you for your time

Answer 111:

Yes, it does simply want you to say what you said for the constraints. Explaining the difference: the replicated SEQ executes its body process repeatedly in sequence — it loops for a fixed number of times; the replicated PAR executes its body in parallel a fixed number of times.

Example legals:

  SEQ i = 0 FOR n            -- sum the array
    total := total + a[i]

  SEQ i = 0 FOR n            -- stream output the array
    out ! a[i]

  SEQ i = 0 FOR n            -- stream input the array
    in ? a[i]

All the above examples would be illegal if SEQ were a PAR.


Question 112:

Submission reference: IN1253

unfortuately i missed the class on "fair" ALTing. if it's at all possible, would you mind running through it here? i figure a good solution may be something to do with the use of a shared channel.

Answer 112:

Attendance at the seminar groups is compulsory. If you missed anything – and the session on fair alting was specifically advertised – I'm afraid it is your responsibility to find out what you missed. These answer pages are not to reproduce teaching material.

However, your observation that a shared channel provides fairness is correct. But shared channels only work if we are always willing to accept messgaes from all sending processes. Sometimes, we want to refuse to listen to some whilst still fairly servicing others and, for such circumstances, we need an array of individual channels – one from each sender – and the algorithm (for dynamically switching the listener's highest priority channel) discussed in the seminar.


Question 113:

Submission reference: IN1255

I have borrowed a bit of code from bar.occ and cut it down to make this:

    VAL INT s IS SIZE in:
    PRI ALT i = favourite FOR s
      VAL INT X IS (i \ s):
      INT any:
      in[X] ? any
      SEQ
        out ! any
        favourite := (X + 1)

Assuming this does do fair ALTing, would I be right in saying if there are 10 channels on CHAN in, and the first result comes from the 5th channel, then next loop it will only take results from channels 6 - 10?

Answer 113:

Yes, this does fair ALTing. No, if the last result came from channel 5, the next loop listens to channels 6, 7, 8, 9, 0, 1, 2, 3, 4 and 5 – in that order of priority.


Question 114:

Submission reference: IN1258

could you use a replicated IF to count the number of times a certain value appears in an array, or once a value a is found (for the first time) will the replicator stop?

Answer 114:

No. Once the first condition in an IF (or replicated IF) turns out to be TRUE, that's the end of it – no further conditions are investigated.

To do what you asked, you need a replicated SEQ, whose body is a simple IF whose first condition governs an increment of a count and whose second is TRUE and governs a SKIP.

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.