XML

kent logo

CO631 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 channels

2004

Question 98 (2004):

Can I check that "!" is an input and "?" is an output ?

Answer 98:

In fact it's the other way around, but finding this out for yourself should be easy! Look at the occam-2 checklist (in the course-notes and on raptor in "/usr/local/courses/co516/etc/").

Keywords: channels

2002

Question 19 (2002):

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

2000

Question 64 (2000):

I am looking at some of the past papers and have a couple of questions about one of the questions. It asks you to explain the synchronisation of a channel? But all it has in the notes about synchronising is:

              input synchronising  =  input ? x

and the same for output. Is this all it means or is there more? Thanks.

Answer 64:

This is a pretty fundamental issue. If you don't know the answer, then you cannot have been following the course and will not be able to appreciate how any of the exercises or examples work. More likely, you have just been thrown by terminology and really do understand the concepts.

The basic facts of channel synchronisation are given in slides 4-27 through 4-31. This is repeated in sections 3.2 and 3.3 of the "occam2 Checklist" paper in your notes. The idea is assumed by almost everything else in the course.

Keywords: channels , synchronisation


Question 22 (2000):

How can I check the value of an input channel? That is, if I have:

  PROC check (CHAN OF BOOL bool, bool2)
    SEQ
      IF
        bool = TRUE
          bool2 ! TRUE
        ...  other tests
  :

how do I check the value of bool?

Answer 22:

This shows the same misunderstanding as Question 21 (2000). Channels do not have values.

Maybe you mean to input a value from your bool channel and, then, check that. If so, this is what you need:

  PROC check (CHAN OF BOOL bool, bool2)
    BOOL b:
    SEQ
      bool ? b
      IF
        b
          bool2 ! TRUE
        ...  other tests
  :

Or maybe you want to check if there is input available on the channel and, if so, take it - but if no data is available, do something else. This is known as polling - see slide 5-37 for how to do it in general. For the above, you could have:

  PROC check (CHAN OF BOOL bool, bool2)
    SEQ
      BOOL b:
      PRI ALT
        bool ? b
          IF
            b
              bool2 ! TRUE
            ...  other tests
        TRUE & SKIP
          ...  do something else
      ...  this happens after execution of one of the PRI ALTernatives
  :

Keywords: channels


Question 21 (2000):

Can I assign a value to a channel? For example:

  PROC foo (CHAN OF BOOL a)
    SEQ
      a := TRUE
      ...

Answer 21:

No. You can only assign values to variables, not channels.

In your code fragment, a is a channel. Channels are only used to communicate values computed in the outputting process to variables in the inputting process. Channels do not hold data values themselves. Therefore, your above assignment makes no sense and will be rejected by the compiler.

The only symbol you can have to the right of a line that starts with a channel variable is either a ? (followed by a variable that is the target of the input) or a ! (followed by an expression that yields the value to be output).

Keywords: channels

Referrers: Question 22 (2000)

Valid CSS!

Valid XHTML 1.0!

Last modified Mon May 15 17:39:44 2006
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.