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.
Where can I find the demo_cycles.occ library as mentioned in the q2.occ file?
Under the "setup information" link from the Co516 web page, there is the encouragement to:
... browse around the directories off /usr/local/work/co516 ... ... in particular, read all the README files ...
If you do that, you will find the directory /usr/local/work/co516/libsrc, which contains the source codes for everything on the course library supporting this unit. As the README file in that directory says, it contains the files demo_cycles.occ and demo_nets.occ and these contain, respectively, the legoland catalogue studied in the course (slides 5-3 through 5-6) and some sample networks built from that catalogue (slides 5-8 through 5-13).
Note: you can also access these files from a web browser:
file:///raptor/files/courses/co516/
or directly from Windows under \\raptor\files\courses\co516\. To make this easy, a link to these files ("occam course files") has been added to the course web page.
Note: to use any of the PROCs or FUNCTIONSs in the libsrc directory, you do not need to copy over any of the files. So long as your program source files contain the line:
#USE "course.lib"
you can invoke them freely. For some exercises (e.g. question 4), you will need to make some modifications to some of these library PROCs - in which case, you will need to take your own copies and start editing.
Keywords: files
Referrers: Question 3 (2001)
Hi, I have completed the first assesed exercies question 2. However, the minus I made to do it is a little weird. It has two input channels and two output channels - is this a problem? Does it matter what it looks like or is it fine as long as it works?
Your minus sounds weird indeed! "As long as it works ..." is never good enough though. Solutions must work and it must be easy to see how they work. So, as long as you document clearly what your two-output minus does and how this helps solve the question, that will be fine.
Keywords: q2
Could we get solutions to bugs.occ and q1.occ?
OK. I've put a corrected version of bugs.occ in the answers directory in the course files area (see Question 1 (2001)). Some people are still working on q1.occ - I'll put the model answer in the same place later this week (under the name a1.occ).
Keywords: model-answers
When is our first assignment (q2.occ) due?
A hard-copy listing of your source code should be handed in to the CAS office by close of service (around 4pm) on Thursday, 8th. November, 2001. Cover sheets will be made available next week.
Note: remember that your differentiate process should be implemented in the same style as the implementation of integrate -- i.e. as a network of simple components of the level of those in the demo_cycles.occ library (see slides 5-3 and 5-8). This requirement is made in the comments in your q2.occ starter file. A solution for differentiate in the form of a single serial process will get a maximum of 6 out of 10. [See also the Hint: given in those comments.]
Note: you must include network diagrams of your differentiate and q2 processes (the latter contains your test rig). These can be hand-drawn neatly on your hard-copy listing or machine-drawn on other paper and stapled to your listing. The diagrams should be annotated with process/channel names that correspond to those used in your code. Channels should be arrowed to show the direction of data-flow. Also, think carefully about the icon you choose to represent the minus component. Unlike plus, minus is not symmetric over its input channels and your icon must reflect this. When looking at its use in a network diagram, we must be able to tell which channel numbers are being subtracted from which.
Note: your source code must be adequately (but not over-) commented, should use meaningful variable names and be well laid out. Of course, you have no choice in indentation layout (;-), but spacing within lines and between them (e.g. between PROC declarations) helps readability (and marking!).
Note: comments in occam source code are introduced by two dashes, --, and include everything following this symbol to the end of the line. [This works like // in Java.]
Keywords: q2 , diagrams , comments
Referrers: Question 6 (2001) , Question 6 (2001) , Question 12 (2001)
I get the following error when I am trying to compile q2.occ:
raptor$ kroc q2.occ Warning-oc-q2.occ(97)- Parameter error is not used Warning-oc-q2.occ(97)- Parameter keyboard is not used KROC octran Version 1.0 for sparc-sun-solaris2.5.1 /usr/local/bin/kroc: as: not found kroc: as failed to assemble q2.s to q2.o
I don't understand where the mistake is. Any ideas?
First, forget about the two Warning messages. These are not compiler Error messages - just warnings. You get them because your PROC q2 declares two parameters (keyboard and error) which it then doesn't use. However, declaration of the three parameters (the keyboard, screen and error channels) is compulsory for the top-level process (i.e. the process you run from the Unix command prompt).
Serious, though, are the messages:
/usr/local/bin/kroc: as: not found kroc: as failed to assemble q2.s to q2.o
This means that Unix couldn't find the as program (which is the standard assembler that generates object code). This is either because of a temorary glitch on raptor or you have changed your path environment variable! By default, the latter is set up automatically for you by /etc/profile and, so, should always be there. If you have redefined path, it must include:
`/usr/local/bin/localpath -sh`
which pulls in all the standard programs. To get as otherwise, you must include (for raptor) /usr/ccs/bin in your path.
If you have changed your path environment variable, you will understand the above and how to make it right again. If not and your problem persists, mail me directly!
Keywords: compiling
Please define "adequately commented". Surely in a program this simple (q2) there is no need for comments - as you can see what the program does by reading the code?
Also, is this a suitable network diagram?
|------------| |---------------| -->| Intergrate |-->| Differentiate |--> |------------| |---------------|
The third Note in the answer to Question 4 (2001) says: "adequately (but not over-) commented". This is a general note about comments that applies to any code you write. For this question, however, no comments are probably needed - unless you have designed something a bit obscure for your differentiate! The definition of "a bit obscure" is anything that is not immediately obvious to whoever is marking your script. Please note the other remarks in that third Note - which are always relevant to your answers, including this one.
Your diagram above is a network diagram ... but it is not suitable as an answer to this q2 assignment. The second Note in the answer to Question 4 (2001) says that you must include network diagrams of "your differentiate and q2 processes". The above does neither of those. [Also, please spell "Intergrate" correctly.]
Keywords: comments
Referrers: Question 12 (2001)
When I run my q2 solution, the numbers scroll past so fast I can't see whether it starts with a zero (like it should!). How can I check if my program is working correctly?
Please refer to Question 13 (2000).
Keywords: output
Referrers: Question 8 (2001)
Is the following ok to allow me to see the output clearly in my answer to q2?
PROC tabulate.int (CHAN OF INT in, CHAN OF BYTE out) INT t: TIMER tim: WHILE TRUE INT n: SEQ in ? n out.int (n, 15, out) out.string ("*c*n", 0, out) tim ? t tim ? AFTER t PLUS 1000000 :
Yes - but that waits a whole second between each line (which may be a bit long). Also, it's nicer to localise the declarations of the TIMER and its associated variable t (these declarations cost nothing at run-time - so it doesn't matter if they're inside a loop). Follow the link in the answer to Question 7 (2001).
Keywords: output
I am attempting to install KRoC on my own Linux machine. I have downloaded it and installed it as per the instructions on the Kroc webpage, but I get these errors when compiling the demo.occ you supplied in the examples directory:
[aejm1@localhost examples]$ kroc demo.occ Warning-oc-demo.occ(20)- Parameter error is not used Warning-oc-demo.occ(20)- Parameter in is not used demo.o: In function `_occam_start': demo.o(.text+0x50): undefined reference to `O_fibonacci' demo.o(.text+0x5c): undefined reference to `O_squares' ... etc.
What am I doing wrong?
You have missed one other instruction. To pick up the course library that these examples use, the compile command on the Linux KRoC must be:
kroc demo.occ -lcourse
On raptor, we have specially modified the kroc command to find the course library automatically. For general release KRoC, where applications need not use our special course library, it would be wrong to make that automatic provision - so you have to use the general mechanism provided by kroc for accessing pre-compiled libraries. This mechanism is the same as that used by the standard gcc compiler and is explained in the essentially-kroc documentation provided in the release (and which the KRoC build script strongly encourages users to read).
Keywords: linux
Is there a way of saying:
IF a = 1 control ? a a = 0 -- DO nothing
If I leave it blank the compiler complains ... ?
That's an easy one :) ... for those spots where the language insists on a process but you have nothing to do, use SKIP (which means do nothing):
IF a = 1 control ? a a = 0 SKIP
Keywords: skip
In Question 4, for the monitor process we are asked to implement the following: `any other character is an error and is processed by bleeping the screen'. I've looked at last years Q+A's on the web but I can't find help on this. Could you give some kind of clue as to how we can produce a bleep from the PC squeaker in occam?
You missed it! See the answer to Question 18 (2000).
Do we have to comment our code - or will the diagrams be enough to explain things?
You need to draw diagrams for any changes needed in the diagrams already given in your q4.occ starter file. This will be for the network diagram of your top-level q4.occ process. You also need to draw - separately - diagrams for your revised numbers, integrate and pairs processes. Please note the standards for diagrams given in the second note to the answer to Question 4 (2001). As for commenting, please refer back to the answer to Question 6 (2001).
Keywords: comments
Referrers: Question 30 (2001)
From Question 31 (2000), it says:
Getting the monitor to trigger a deadlock (in response to a `q') is easy and will earn full marks (for this part).
Would we get full marks if we implement a livelock ... or do we have to trigger a deadlock?
Forcing a livelock is a bad idea - your program keeps on running! Forcing a deadlock will terminate your program.
I have created the `pause' process to respond to `s' as step 4 of Q4 asks. But where does it go? Does it take input direct from the keyboard and then outputs to the monitor or does the monitor output to the pause process??
It can't take input direct from the keyboard (as happened for question 3), since the keyboard is already connected to the monitor process. Channels may only connect to one process (at each end). So, I guess that monitor must output to the pause process!
Oh - I see what you were wondering: connect keyboard to the pause process along with the input/output channels whose traffic it's going to freeze ... and pass on keyboard input other than `s' to the monitor. Well, you could try that but I would advise against. There is a nasty deadlock lurking if you do this ... can you see it?
Keywords: pause-process , q4
Can you give me a hint on how to implement the `PAUSE' method for part 4? I know how to do the quit function but need to be able to put this deadlock within the pause function.
Implement a `PAUSE' in the same way as you did for question 3 (as discussed in your seminar groups). To cause deadlock as the response to a QUIT, the simplest way is to arrange for the process that manages the PAUSE effect to terminate - that leaves its upstream processes blocked all trying to output. Your keyboard monitor is still active - so your system is not yet deadlocked. But as soon as you type one of the characters to which it responds by outputting to the rest of your (now blocked) system, that output won't be taken and your keyboard monitor will block. Everything is now stuck and the run-time system will detect deadlock and quit.
Keywords: pause-process , q4
I'm trying to install Kroc on my newly installed Linux system at home. I've unzipped and tarred it, run the script called 'build', but get the error message Script 'build' line29: unknown command unset.
In the read-me file, there is also the sentence: You will need the standard linux kernel headers in order to compile the sources. As a newby, I do not understand a word of this! Is there any chance of an 'idiots' installation guide?
The shell should really understand unset. What Linux distribution are you using? It sounds like you have something old or non-bash ...
More information is needed to diagnose your problem properly. Please mail Fred Barnes, frmb2@ukc.ac.uk, the typescript file generated during the 'build' operation. This (anonymous) medium is not the place to sort this out.
Keywords: linux
Is it alright for the output from my q6.occ to list the names in a different order to those listed by your model a6 answer?
Yes. The order of the names does not matter. Of course, each name should only appear once and the total marks for that name should be alongside it. As an additional exercise, it would be nice to list the names in alphabetical order ... but there are no extra marks for that!
Keywords: q6
I keep getting the error:
Simple input is not allowed on a channel with a tagged protocol ...
when I just try to connect the collate process between the read.data and display in Q6. What do you think I should do?
You should not try to do simple input on a channel with a tagged protocol! Tagged (or CASE) protocols are explained in Section 7 of The occam Checklist and in slides 10-18 through 10-22 (which have been talked though in lectures). See also the code in the display process given in your q6.occ started file.
Referrers: Question 53 (2003)
For Q6, if I have two strings called a and b and I want to use the compare.string function on them, how do I do it? Is it something like:
compare.string (a, b)
Also, if I get back string.less or string.more, which of the two strings is being referred to as smaller or bigger than the other?
Yes to your first question. Make sure you have read the documentation in libsrc/string.occ, which is part of the course library and which contains the string handling routines. Most important is that functions like compare.string (etc.) do not work unless the BYTE arrays on which they operate have first been processed by make.string.
To your second question, if compare.string (a, b) returns string.less, then a is less than b. That was meant to be obvious ... if you were at all unsure, a glance at the source code would have confirmed this ...
Note: if others have further questions about this assignment, please first refer to last year's Question 51 (2000) onwards.
Keywords: q6 , string-handling
Referrers: Question 50 (2003) , Question 54 (2003)
What does this error mean?
Type mismatch for parameter 1 in call of equal.string ...
It means what it says: you have supplied, as the first argument to a call of equal.string, something whose type does not match the type declared for its first parameter! Now, equal.string takes two []BYTE (i.e. BYTE array) parameters. So, that's what you must supply ...
Keywords: type-mismatch
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |