XML

kent logo

CO538 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

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.

Keyword reference for q3

2012

Question 9 (2012):

Submission reference: IN2161

I am trying to start working on question 3 and have read all of the lecture slides about deterministic and non-deterministic choice from choice slides 1-29 but am still really confused on where to start ...

I think that I will need a BYTE variable that is set permanently to 'f' so that I can use this for comparing the keyboard? with to know when an 'f' is pushed? This confused me because I don't know how I would properly compare the BYTE value from keyboard? with the fixed VAL BYTE f I declared... Would it be the same as comparing numbers?

I then think that I will need a WHILE TRUE loop to run forever and then directly inside that I will need a PRI ALT to decide what to do. I don't know where to start with what else goes inside the PRI ALT (I know the structure of the the PRI ALT from the lecture slides) but how do I start demo running immediately, pause it when an 'f' is inputted (possibly an input guard?), actually get the demo process to pause and then resume when another character is inputted on keyboard?

I've flicked through the rest of the choice slides and couldn't find any other examples where similar code could be found to base my answer to this problem.

Answer 9:

We don't really need to declare a named VAL BYTE holding the constant 'f' – we can just use the literal 'f' in your code. Having said that, it's usually a good idea to give names for literal constants, so let's do it:

    VAL BYTE freeze.char IS 'f':

Then use freeze.char henceforth in our code. Now, should whoever is specifying the system we are programming change their minds and decide that 'F' would be more cool (than 'f'), all we have to do is change the above line. Otherwise, we have to hunt throughout our code and change 'f' to 'F' wherever we find it and hope we don't miss any.

How do we compare freeze.char with whatever value is received from the keyboard? channel? Well, if ch is the BYTE variable into which data was received from keyboard?, just test the condition:

    ch = freeze.char                  -- or: ch = 'f'

within an IF process.

You are correct: in the control process, you will need a WHILE TRUE and, in its loop body, a PRI ALT. You must decide for what guards the latter needs to be waiting and what the responses must be when/if it gets them. To do this, you must think on what control has to do: normally forward anything coming in from demo to the screen! ... unless a freeze.char arrives from keyboard? (in which case, it must wait for another BYTEany other BYTE – from keyboard?). Note: control does nothing to "get the demo process to pause and then resume" other than refusing its output for a while – demo is unchanged and unaware of its connection to control or the impact that has (which is irrelevant to its semantics). Note: programming this behaviour into your PRI ALT guarded processes of control takes around 10 lines (including local variable declarations for each guarded process). Programming the full behaviour of control (responding to 5 special characters from the keyboard) takes a few, but not many, more.

Starting the demo process running is not the responsibility of control (which may assume that demo, or something, has been started and will be sending BYTEs to one of its input channels – its other input channel receiving BYTEs only occasionally from the keyboard).

Starting demo and control running and connecting them up correctly is the responsibility of the q3 process, as shown in the diagram at the bottom of page 1 of the "more.exercises" sheet. The q3 process is declared as the last process in your starter file.

Keywords: q3

2011

Question 19 (2011):

Submission reference: IN2050

Hi, I am very confused with how to go about implementing the freeze part of q4. Unfortunately, I was not able to do this in q3 either! Help!

Answer 19:

Sorry – can't just tell you the answer ... it's too simple ...

Think this way: a data stream through a channel only flows if the processes through which it is routed are programmed to execute appropriate input and output instructions. If those instructions are not being executed (e.g. the code is doing something else ... like waiting for some signal to resume the flow), the stream cannot flow. The default action is no action. Data flows only if it is programmed to flow. What you see (in your code) is what you get.

Hope this helps!

Keywords: q3 , q4

2010

Question 10 (2010):

Submission reference: IN1904

Will the model answer for Q3 be available to look at before the Q4 submission deadline?

Answer 10:

Sorry, no! Q3 is a warm up exercise for Q4. The freeze control it asks for can be reused intact in Q4.

Keywords: q3 , q4


Question 4 (2010):

Submission reference: IN1899

I'm currently working on Q3 and have managed to get the output to the screen to freeze when 'f' is received. When the next key is pressed, numbers are again put to the screen but the process has kept on running and therefore some numbers are not printed. Is this correct or do I have to stop the numbers from incrementing (any pointers on how to do this would be appreciated)?

Answer 4:

It's not correct!

The question (Exercise 4) in the "more-exercises" sheet does say: "from wherever it left off". Keying 'f' should freeze screen output, which should resume from where it froze when the next character is entered.

It's actually simpler to program the above behaviour than to leave the demo process running without printing its output. Remember that a channel cannot lose any messages: if the receiver does not input, the sender just blocks (until such time as the receiver does input from the channel ... at which time, the message comes across). So to lose message from demo, we would need to program control explicitly to continue to take in messages but not forward them! To block messages from demo, just don't listen to it – simple!!

Keywords: q3 , q4

2009

Question 14 (2009):

Submission reference: IN1814

Would it be possible to get a model answer for Q3?

Answer 14:

Not on paper or electronically.

However, you can ask about it in your seminar group and you will be led to finding your own solution. If your seminar group this week has passed, ask your friends – Q3 is not for assessment and we want you to learn from each other.

NB: an elegant solution for the first part of the control process take 14 lines. Two of these are the PROC header and final colon line. Another line sets up an infinite loop (WHILE TRUE). Another one sets up a prioritised alternative (PRI ALT). Somewhere, you need to declare a variable (or two). To test if the input character is an 'f', you'll need an IF (but you'll find a CASE easier for checking all the later possibilities – same also for Q4 ... so read the final paragraph of Q4!).

Any longer solution is either wrong or, probably, inelegant, :).

Keywords: q3


Question 12 (2009):

Submission reference: IN1812

I am having a difficulty to understand how to activate a resettable process. The replace process would always use the reset channel. How does it actually get activated? I have tried to send the zero value in the reset channel but it still won't work. Am I missing something here?

Answer 12:

It sounds like your implementation is on the right lines. Such a process would normally have the implementation:

  PROC replace (CHAN INT in?, out!, reset?)
    WHILE TRUE
      PRI ALT
        INT v:
        reset ? v
          PAR
            INT tmp:
            in ? tmp
            out ! v
        INT x:
        in ? x
          out ! x
  :

Thus, if something comes in on the "reset" channel, this component will respond by swallowing up the next value received on "in", and outputting the reset value on "out". Ordinarily, in the absence of any communications on "reset", this process will just copy data from "in" to "out" (the second guard in the PRI ALT).

Regarding 'activation', the process once instantiated is always active — though it may spend most of its time waiting at the PRI ALT for one of the input channels to become ready. Of course, this means you'd have to wire it up inside the relevant process network, which involves modifying that original network (in the case of "numbers", "integrate", etc.). The code for these can be found in the lecture slides, or on raptor in "/courses/co538/libsrc/demo_nets.occ".

Keywords: q3 , q4 , reset

2007

Question 12 (2007):

Submission reference: IN1309

I am working on q3.occ and trying to get occam to throw some runtime errors. I am attempting to create a array out of bounds error. I manage to get a runtime error but the output then calls it a CSUB0 error.

Is this what I want? What is it? Cheers

Answer 12:

Yes, this is the error you get when attempting to access a non-existent array element. CSUB0 is the Transputer instruction that implements a particular range-check, and happens to be used when generating code that checks for array-bounds errors. Unfortunately that error message is not particularly user-friendly, something we plan to fix at some point in the future..

Keywords: range-error , q3

2006

Question 34 (2006):

Submission reference: IN987

In the older answers, you mention model answers. Are these still available to look at?

Answer 34:

OK - I've put model answers to completing q1.occ, q2.occ, q3.occ and q4.occ in the raptor folder:

    \courses\co631\answers\

Keywords: q1 , q2 , q3 , q4

2003

Question 15 (2003):

Are you going to release the answers for question 3 before the homework deadline? It's not an assignment so there shouldn't be any reason why its not up already.

Answer 15:

This is now available (as of Saturday 15th). The file can be found on raptor in:

    /usr/local/courses/co516/answers/a3.occ

With an executable version `a3' in that directory also. If you're browsing from windows, replace the leading `/usr/local/' with `\\raptor\files\' (and turn all the slashes into back-slashes).

Keywords: q3

2002

Question 8 (2002):

OK so before I go and do the instructions to question 3, is that what I need to do to edit, compile and run occam files on a windows PC? (With access to the internet). Cheers

Answer 8:

Sorry - don't understand this question at all ... to what does your "that" refer ... and why are you looking at question 3 when the assignment is to do question 2 and you should have done question 1 in your classes?

Information on accessing raptor from your own PC is in the answer to Question 3 (2002). You can't compile or run occam on any Windows platform - but you can use eXceed or putty or ssh to access a mchine that can. Of course, if you have Linux on your PC, then you can install the KRoC system and do the work on your own machine.

Keywords: q3 , windows

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:30 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.