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

Are these funny demos (shown in the first lecture) available somewhere?

Answer 1:

Some components from the RMoX demonstrator were taken from student answers to question 7 from the "occam Exercise Sheet". Executables can be run on raptor by changing to the answers directory:

  cd /usr/local/courses/co516/answers

and then executing one or more from:


The full RMoX demonstrator will be available shortly. You will have to make this as a PC boot floppy. Details later ...

Keywords: demos

Question 2:

What is the syntax for "doesn't equal to"?

Answer 2:

See the table in Section 1.2 from "An occam2 Checklist" (in the course notes). That document is just a summary though and doesn't spell things out explicitly. So, spelling it out explicitly: the symbol for testing for equality is "=" and the symbol for testing for inequality is "<>".

Keywords: not-equal

Question 3:

Is there any information on how to get CS Unix Hosts (eXceed) tool to work on a stand alone PC?

Answer 3:

Presumably, by "stand alone" you don't mean a PC with no network connections at all - but you do mean either (a) a PC is a study-bedroom connected to the campus network or (b) a PC at `home' with some dial-up ISP.

For (a), first go to a public PC and put on your desktop a shortcut to:

  programs -> departmental software -> computer science -> CS unix hosts

You should have that anyway! Then, drag-copy the desktop icon (for the "CS unix hosts" shortcut) to your home directory on raptor (say). Then, from your study-bedroom PC, drag-copy that file (assuming you have your raptor files mapped) to your own PC's desktop. With a bit of luck, double-clicking that icon will fire things up - you will have to have eXceed installed locally, of course.

For (b), it's probably best not to use eXceed and just come in via Putty. Details can be found on:


From Putty, you will not be able to use X-based utilities - like gvim. You will have to use a non-X editor - like vi. If you choose to edit your occam files on your PC, you will need to be able to move files between your home PC and raptor. To do this (from a dial-up ISP), you will need to use WinSCP:


Keywords: exceed

Referrers: Question 8 (2002)

Question 4:

Is it possible to take input from a channel un-synchronised? For example, you want to listen for input on the keyboard, but do not wish to hold up the process if a key is not pressed.

Answer 4:

Un-synchronised is not the right word. What you describe is polling the channel to see if input is available from it. If none is available, you would like to be able to do something else and - usually - try again later.

Warning: writing such polling loops is usually the result of bad design. For occam, it's usually simpler to leave a process blocked waiting for input and have another process, running in parallel with it, do that something-else work.

However, if you really need to poll a channel to see if input is available, see slide 5-37. But you will have to study the earlier slides on the ALT construct (and read section 4.3 of the `occam2 Checklist' paper) first to understand it.

Keywords: polling

Question 5:

For question 1 of the Exercise sheet, how do you get process q1 to actually communicate processes a and b?

Answer 5:

Don't really understand this question. Process q1 contains one instance each of processes a and b - it doesn't communicate them?!! If still puzzled, go to your classes and ask your class supervisor.

Keywords: q1

Question 6:

Is q2 an assessment? If yes, do we email you the file?

Answer 6:

See my news posting on this dated Monday, 21st. October. That posting is also archived on raptor in the course directory:


Question 7:

Could we get solutions to bugs.occ and q1.occ?

Answer 7:

Model solutions are available on raptor in the course directory:


I've just made bugs.occ readable by everyone. A compiled executable is in the file bugs. The model answer for q1.occ is in the file a1.occ, but this is not yet readable by you. However, its compiled executable, a1, is executable by you. The same is true for model answers to questions 2 through 6.

I'll make a1.occ readable at the end of this week. Executing a1 outputs too fast for you to read - try a1_slow instead (which waits one-tenth of a second between each line of output). I'll make a1_slow.occ readable also at the same time. These programs were not designed to terminate - end them by typing [CTL-C], which instructs unix to kill them.

Keywords: model-answers

Question 8:

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

Question 9:

Hi, I was just wondering if the source code for the integrate process is supposed to available?

Answer 9:

It's on slide 5-8 and on raptor at:


Please browse the course directories to find things like this. As has been said before, start from:


to help you navigate.

Keywords: source-code

Question 10:

For q2, the keyboard channel takes a BYTE. How do I cast a BYTE to an INT?

Answer 10:

q2 does not require you to touch the keyboard channel - do you mean the screen one?

You can cast a BYTE to an INT ... but you don't want to do that for this question. You need to be able to output an (ASCII) character representation of an INT to the screen channel - but that's OK since that will be a sequence of BYTEs (which are the only things you can output to the screen). And that's done for you by the tabulate.int process, given to you in your q2.occ starter file.

If you really want to know about casting in occam, see Question 7 (2000).

Keywords: cast

Question 11:

I get the following error when running my q4 on raptor, I have got up to part three, please could you give me some idea what this error means and what caused it.

  KROC: Range error / STOP executed (signal 4)
  KROC: Fatal error code 1, core dumped
  Abort (core dumped)

Answer 11:

Please see the answer to Question 70 (2000).

Keywords: range-error , stop

Question 12:

For the final modification to q4, when my program is running, I press q and the screen outut stops, and then if I press any key a deadlock message comes up and the terminal shows the raptor prompt again.

Answer 12:

Presumably, you react to the q by sending a suitable signal to the same process implementing the suspend mechanism? What we were suggesting was for that process to terminate (i.e. exit its loop and finish) when it gets that quit signal. That leaves no route for the streams of numbers to get to the screen and most of your q4 system is deadlocked.

However, your keyboard monitoring process is still alive, waiting for more keystrokes. If you type anything but the ones it wants (e.g. anything bar 'n', 'i', 'p', 's', 'q'), it swallows it and loops around and stays alive. If you type an 'n' (for example), it tries to output a reset signal to a deadlocked component. That doesn't succeed and the keyboard process is stuck trying to output. There are now no processes left to run - and, now, the run-time system can announce deadlock and terminate. This solution is fine, but the model answer does something slightly different ...

Keywords: q4 , output

Referrers: Question 14 (2002)

Question 13:

This is the error i keep getting and I don't understand why, max.chans is still set at 3, can you help, I can't seem to get passed this to get on with the rest!?

  raptor$ kroc q4.occ

      :    delta(a,b,e)
      :    integrate(b,c)
      :    delta(c,d,f)
      :    pairs(d,g)
   315:    layout.max.chans(e,f,g,screen)
  Error-oc-q4.occ(315)- Too many actual parameters in call of layout.max.chans

Answer 13:

You have too many parameters! layout.max.chans takes just two parameters - an array of input channels and an output channel. You are supplying four parameters, :-(.

Your channels e, f and g should be elements of an array - e.g. c[0], c[1] and c[2]. Then, your instantiation would be:

           layout.max.chans (c, screen)

An alternative solution is to keep your channels, e, f and g, as they were and construct the array required by layout.max.chans on-the-fly:

           layout.max.chans ([e, f, g], screen)

Keywords: q4 , compiling

Question 14:

In q4 you say 'q' should be dealt with by putting the system into deadlock. Can't we use the command STOP instead?

Answer 14:

Well ... you can, but it's not very nice. Any process executing a STOP - in the current versions of KRoC - causes the whole system to stop in a rather ungraceful way. On the Solaris version, it even causes a core dump! Later versions of KRoC will offer an option so that only the process executing a STOP will stop (i.e. freeze, which is subtly different from terminate) - leaving the rest of the system running. This is what is supposed to heppen.

So, getting your process to respond to 'q' with a STOP is allowed - you will not lose marks for this solution. For a better solution see Question 12 (2002).

Keywords: q4 , deadlock

Question 15:

I have just completed the 'p' operation. It un-does the last operation but the numbers are one out each time:

          43902      963714753          43903
          43903      963758656          43904
          43904      963802560          43905
          43905      963846465          43906

Is this still correct or should I be getting the same in the last colunm as in the first colunm?

Answer 15:

No - that's fine! The model answer (answers/a4) does the same thing.

Keywords: q4

Question 16:

I have a problem with the folding in GVIM. Before this, I could open and close a folder containing a section of code for a PROC or a whole section of comments based on the curly bracket notation --{{{ and --}}} you provide in your .occ files. Once the block of code is closed, it displays a line of text highlighted in blue with a '+' sign on the left with the code indented and encapsulated under this folder and it also has fold column on the far left.

But now my GVIM program running under Exceed seems to have been saved under different settings and is incapable of displaying this anymore where it was OK before, and now it just displays plain text. I find it much easier if I have the folding capabilities as it is much easier to hide lines of comments and PROC bodies - particularly for occam when there are large amounts of code.

How can I change back to the original settings before and is always displayed every time you open any .occ file without having to add folders manually??

Answer 16:

This problem is caused because /usr/local/work was renamed to /usr/local/courses on raptor. /usr/local/work doesn't exist any longer, i.e. some students' Vim resource files now point to the wrong (non-existing) directory, that's why the folding scripts are not loaded. To solve this, try to run the vim script again. Run:


and chose option 1 ("Replace old files").

Keywords: vim , gvim , folding

Referrers: Question 23 (2002)

Question 17:

Is it me or for the second modification do you have to change not only numbers to accommodate a reset command but prefix as well? The same goes for changes that have to be made to integrate and its internal code. Is there an easier way to do this or not?

Answer 17:

I'm afraid it's you. You have to change the numbers process because it's functionality has changed - it's got a reset line! To make this change, however, you don't have to change any of its old sub-components - i.e. prefix, delta and successor - but you do have to insert one extra sub-component into its circuit. The same observations apply for the needed change to integrate.

Keywords: q4

Question 18:

For part two of q4, where it states "clearly numbers and integrate will have to be reimplemented", do we declare a new process (such as numbersOne) within q4 and modify this or can we edit the version in demo.nets?

Answer 18:

You need to declare a new process (such as numbersOne) before q4 in your file q4.occ. Cut and paste the numbers code from demo.nets and modify that. You can't, of course, edit the file demo.nets - you don't have write permission ...

Keywords: q4

Question 19:

For the second modification task, I have created my own processors numbers.reset and integrate.reset which respond to the inputs 'n' and 'i' respectively, however when I assign the replace processor to be used within each of these processors, it displays an invalid process error:-

     :    reset ? ch
     :    IF
     :      (ch = 'n')
     :        PAR
  318:          replace (a, 0, b)
     :          delta (b, out, c)
     :          succ (c, d)
     :          prefix (0, d, a)
     :      TRUE
  Error-oc-q4.occ(304)- Invalid process
  type tree not caught by case (switch) is CHAN

Why does this occur?

Answer 19:

Well ... replace takes 3 channel parameters and you supply an INT (0) as one of them! The Solaris kroc compiler does give a poor error message, but nobody at INMOS ever thought someone would write code like that! The Linux kroc handles this better.

Your code is very wrong though. You are misunderstanding something fundamental. See your seminar leader. [If you get an 'n' in the above, you start up a PAR construct that never ends ...?]

Keywords: q4 , channels

Question 20:

Sir, could you explain the process below. Have been trying to figure it.

  PROC pause (CHAN OF BYTE in, interrupt, out)
      BYTE x :
      PRI ALT
        interrupt ? x
            x = 'Q'
              black.hole (interrupt)
              interrupt ? x
        in ? x
          out ! x

From my understanding, if data is pending in the interrupt channel, then it checks if it is the 'Q' char. If it is, it goes into a black.hole - otherwise it waits for data to enter though interrupt. So, when does it ever check the second guard?? Thanks.

Answer 20:

(This process is part of the model answer to Q3 on the exercise sheet.)

As you say, if data is pending in the interrupt channel, it inputs it and checks for 'Q'. If it got a 'Q', it goes into an infinite loop that just swallows anything else sent down that interrupt channel - and will never check that second guard (i.e. data will never flow through this device again from in to out, which is what we want).

If the value input from interrupt was not 'Q', it waits for a second character to arrive on interrupt - during which wait it never checks that second guard (i.e. data will not flow from in to out, which is also what we want). If and when it gets that second character on interrupt, it loops around and starts listening again on the in and interrupt channels - now data arriving on in will flow thorugh to out, which is what we want.

Keywords: pause-process , alternation

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.