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.
Submission reference: IN1271
What is the bitwise-exclusive-or operator in occam?
It's "><".
Keywords: operators
Submission reference: IN1284
Sorry, I dont remember but did you say that seminars and terminal sessions won't be on this week?
There will be terminal classes this week - no seminars. I've added a note at the top of the Co631 web page.
Submission reference: IN1285
A number of the links on the web page are not working. Any idea when they will be active again? I enjoyed the lecture yesterday btw. Thanks
Which links in particular? — they all work fine for me when I try them!
Keywords: course
Submission reference: IN1287
In regard to exercise 1 final part, modification of print.stream: are you expecting the pause(delay) per line or per number?
Per line. So with a delay of 100000, there should be ten lines per second - no matter how many numbers are tabulated on each line.
Keywords: q1
Submission reference: IN1289
Just out of interest, would it be possible to write an application to convert videos into other formats using occam? Or would using various codecs and such be a pain?
I just mention this as all the apps ive seen that convert a video into dvd format seem to only use two cores at the most (on a quad core machine).
I guess that occam could do this task pretty well if it were possible?
I (Fred) don't know a huge amount about video format conversion, but my understanding of things like MPEG4/AVI/etc. is that you have "key-frames", from which a number of successive frames are derived (as in, difference between individual frames, with the key-frame being a whole new frame). It should be possible to parallelise such things sensibly, either at a fairly high level by picking out N bunches of M frames and encoding those N in parallel, or at a low-level by computing the frame differences in parallel (should be possible to divide up an image fairly easily!).
As for programming in occam, you can call out to C libraries and such to get at the actual codec libraries (well, I have confidence in doing such things in Unix, don't know about Windows!). So it should be plausible to do video conversion in parallel and utilise all your cores.. Carl Ritson (now an RA in the department) did a video processing framework in occam-pi for his final-year project, which covers some relevant things, so you could try asking him :-) (C.G.Ritson@kent.ac.uk). One of the neat things here was playing multiple videos in parallel, or processing several video streams (from USB webcams), picking the stream with the most "interesting" features (motion detection), and dumping that to a viewer or encoded to a file. Unfortunately we haven't gotten around to including it in the KRoC distribution yet!
Keywords: video , application
Submission reference: IN1292
When will submission for the assessment part 1 be open as the deadline isn't all that far off?
Submission directories are open now on raptor:
S:\proj\co631\simplestreams\<your-login-name>\
Please copy your completed q1.occ file to the above. You can do so as often as you like until the directory closes (at midnight, Tuesday, 29th. January, 2008). That's the midnight between Tuesday and Wednesday.
Please only submit one file containing as many stages of the exercise as you have completed. Do not submit separate files for each stage.
Keywords: q1
Submission reference: IN1294
Hi, Are we supposed to check for a column size < 1? There is no mention in the spec and I assume that we are not going to get extra marks (or be marked down) for these kind of checks since this is not the purpose of the exercise. Ciao
Nope – for this exercise, your modified print.stream may assume it will be given a sensible value for the number of columns requested (e.g. more than zero and less than ten).
Your point is a good one though. In general, code should be robust against bad arguments.
Keywords: q1
Submission reference: IN1295
What should the column value be? It is not specified anywhere in the early-exercises.doc so do we hard code it to any value we like? Do we read it in from the keyboard? I have lost marks for silly things like this before. Thanks ciao
Any sensible value (for the number of columns) will do – say 10 ...
Keywords: q1
Submission reference: IN1296
For assessment 1, we need to filter out numbers exactly divisible by 5. What's the modulo operator in occam? Thanks.
Sorry – the integer modulo operator in occam-pi is backstroke, "\". This is mentioned on slide 29 of the "basics" slides, which is in the section on types that I skipped! We will do them in the next lecture.
Of course, in Java and C, modulo is "%".
Submission reference: IN1293
I assume that q2.occ is to be submitted in the "S:\proj\co631\diffcircuit" folder?
Yep.
Submission reference: IN1299
I'm a Unix newbie. How do you specify a USB device on the Unix command line? I have a simple requirement to copy a file from a USB device to a file in my home directory.
I'll assume you're using Linux, and that you have a working USB stack (not generally an issue these days). Before you can access files on a device (such as a hard-disk or USB stick), you have to mount it somewhere. E.g. the root file-system is mounted on "/". Look at the contents of /etc/fstab to see where other things are mounted. USB sticks will typically appear as SCSI devices when plugged in, such as "sda" or "sdb" (or whatever, depending on how many SCSI devices are already there). When you plug the stick in, the kernel will utter something useful at you. Run "dmesg" to see the kernel log, and check the last couple of lines, which should be USB related. In particular, you should see something like "sda" or "sdb". Then mount it, e.g. "mount /dev/sda1 /media/usb -t vfat" (you may need to be root to do this). Once there, you can copy out the files from "/media/usb". Note that you mount "sda1", not "sda"; the former refers to a particular partition on the device. Once you're done copying files, don't forget to unmount: "umount /media/usb".
The above doesn't sound terribly nice, but that's Unix for you -- however, the possibilities of what you can do with it are pretty endless. Some Unixes are nicer... On my Debian system, for instance, when I plug in a USB stick it automatically mounts it and pops up a file-explorer type window.
Keywords: unix
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
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
Submission reference: IN1318
I'm trying to do the increment/decrement of the print.stream's delay part of question 4 and can't seem to see why the following is happening, it seems fairly basic:
PRI ALT rate ? r print.streams (10, r!, chans?, screen!) SKIP print.streams (10, r!, chans?, screen!)
I can't ever get passed the first guard even though I know that I have read input from rate. Removing the skip guard and adding a stop below the first guard shows me that I can actually trigger this guard. Shown in the following:
PRI ALT rate ? r STOP
However it seems that when the skip guard is added the first guard is never correctly evaluated and the second one evaluates to true. Whats going wrong?
Guards are either ready or not ready – they don't evaluate to anything.
There are two problems with your first code fragment.
The first is that you input something from rate
into a variable r
possibly an integer?
But then you pass r!
to print.streams
where r!
is the writing
end of some channel!
Now, while occam-pi does enable channel-ends to be sent through channels,
I don't think that's what you are trying to do here – sending
channels through channels is how occam-pi can set up networks at run-time
(and is part of next year's Advanced Concurreny and Practice
module).
So, what is your r
– it can't be both an integer and a channel?
Your main problem, though, is not understanding the nature of
the print.streams
process.
This process runs forever – its main loop is WHILE
TRUE
.
So, when your code fragment runs, the rate
guard probably won't be
ready ... but the SKIP
guard will and so your second print.streams
(which is the same as the first!) starts executing ... and never
terminates.
So your code fragment never terminates!
If it is embedded inside a loop, that loop will never loop and your
code fragment will never be executed again.
Hope that helps!
Keywords: q4
Submission reference: IN1320
Are we required to submit q3.occ
as part of the latest assessment, or do we
just submit q4.occ
as this covers the stuff in q3
?
Just submit your q4.occ
source file. Thanks.
Keywords: q4
Submission reference: IN1321
I'm working on q4, and was wondering about the last part (the speed control).
I assume I should use the pause
given to us in q4 for this, but when the
timeout given to pause is '0' it returns extremely fast (as expected),
however when the timeout given is 1 or more, it seems to be a lot slower.
(I am expecting to wait 1ms where it seems to be more like 1 second.
Well – you can use pause
somewhere within whatever process
you write for the speed control.
It's OK ... but when the delay is long, like a second, it will wait that whole second
before processing anything else ... which could be a signal to speed up!
There is a way to do this so that speed response to '+' and '-' is always fast,
no matter what the current delay period.
When you set zero as a delay period - e.g.
TIMER tim: INT t: SEQ tim ? t tim ? AFTER t PLUS 0
we are saying wait until the time on the timer is AFTER
what was just read
– i.e. that the timer has advanced at least one microsecond.
With the Transterpreter, that will probably be true, so there will be no delay imposed
... and the output is fast.
But if we set:
TIMER tim: INT t: SEQ tim ? t tim ? AFTER t PLUS 1
we mean wait until at least two microseconds have passed. The Transterpreter is fast enough that that probably won't have happened, so a delay is imposed. Because no other processes can progress (they are blocked by the above delaying speed control process), the occam run-time goes to sleep ... first asking the operating system to wake it up in a microsecond or two. Unfortunately, most operating system have a granularity at around 10 milliseconds in operating its timers ... so your system has to wait that long to get reinstated. [Note: that won't be the case when the operating system is written in occam-pi – check out RMoX.]
Consequently, there won't be much difference between a delay(1)
and
delay(10000)
(10 milliseconds) ... but you will notice delay(100000)
(100 millseconds, or 1/10 second) is a lot slower!
So, that should explain the effects of giving small delay values to the pause
period.
If we pass 1, we hope for 1 (2 actually) microseconds, but get around 10000 – same for
all delays up to 10000. [You should not have been expecting 1ms and should be getting
1 second delay!]
Keywords: q4
Referrers: Question 18 (2007) , Question 20 (2007) , Question 22 (2007) , Question 28 (2007)
Submission reference: IN1322
Hello,
I have some issues with deadlocking when I type with some fury at 'n' and 'i' when I implement them. My relevant code looks like:
... code deleted
Everything that I think could be done in parallel is done in parallel and I don't understand why if I start pressing the two buttons rapidly I would get in a dead lock situation. Thanks.
Sorry – see the third paragraph of the preamble at the top of this page. We can't answer such questions here.
Keying in 'n' and 'i' fast should absolutely not provoke in deadlock, so something
is wrong.
Your resettable integrate is not the parallel version required – you're supposed
to be working from the parallel integrate
process ... but this isn't why
your system is deadlocking.
[From a quick scan of your code, I can't see any obvious reason - sorry. You'll have to keep thinking about it ...]
Keywords: q4
Submission reference: IN1323
For the '+', '-', which are the maximum number and minimum rates? Because in the q4.occ doc you are saying 1-128, but in the pdf file you are saying 1-1024 lines/second.
Sorry – either maximum rate is OK. For most terminal emulators though, 128 lines per second is about as fast as they can go!
Keywords: q4
Referrers: Question 28 (2007)
Submission reference: IN1324
A question on freezing:
When we freeze obviously the timer keeps on going (for the speed control). Now, when we resume, the timer might have gone through many cycles therefore letting a whole load of result pour out all at once before resuming the normal speed.
Do we want that to happen or not? Thanks.
It's time, rather than the timer, that keeps on going. The timer ain't doing nothing!
But yes, depending how you do it, your scenario will happen.
It is quite easy to avoid (e.g. if you implement speed
control with a pause
procedure – though this has
its own problem, see the first paragraph of the asnwer to Question 15 (2007)).
There will only be a small loss of marks for suffering
this effect when a freeze is unfrozen.
Keywords: q4
Submission reference: IN1326
In the assessment it says: "BYTEs output on the error channel do not need flushing - they are delivered to the user's terminal (window) without delay." Is this true with the transterpreter also? As I found that the error channel needed flushing after a bell signal.
On Unix systems, the standard error channel does not need flushing
and that's how occam-pi's error!
channel behaves there
(and is supposed to behave).
Under the Transterpreter, it should behave the same ... but, as you found,
it does not.
This will be fixed in the next revision – thanks.
Meanwhile, please send a FLUSH
to the error!
channel if you want previous output to be forced out!
Keywords: q4
Submission reference: IN1325
For the '+' and '-',of the q4.occ: each time the user types '-' on the keyboard, I divide by 2 the 1000*milliseconds of the delay that is passed to the print.stream. But this works only until (1000*milliseconds)/64 and then the (1000*milliseconds)/128 is the same as the (1000*milliseconds)/64. Do I do miss anything important here?
You should not be doing anything to the delay value passed to
print.streams
!
As the q4.occ starter file suggests, set that delay to -1 so
that print.streams
imposes no delays at all.
Leave print.streams
alone.
Implement speed control in a brand new process – as
the question (and starter file) suggest.
I guess you're modifying print.streams
to take
a speed control channel and starting at minimum speed
(1 line/sec => a period of 1000*milliseconds per cycle).
When a '-' is keyed in, the line rate should slow down
– i.e. the period should be doubled, not halved.
When a '+' is keyed in, the line rate should speed up
– i.e. the period should be halved.
Assuming that's what you meant ... why is (1000*milliseconds)/128
is the same as (1000*milliseconds)/64?
I'm assuming that milliseconds has the value 1000, since time
is measured in microsecond units.
Then, (1000*milliseconds)/128 is 7812, which is rather different
from (1000*milliseconds)/64 which is 15625.
[Note: the question (in the PDF file) says set the print.streams
delay to zero, but the starter file says minus one.
Setting a delay of zero asks for a delay of one time unit
(microsecond on most current platforms) – see the answer to Question 15 (2007).
This is because the AFTER
operator really means after!
Setting a delay of minus one asks for no delay at all –
because time is always AFTER
one time unit in the past.]
Keywords: q4
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |