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 mobiles
2012 |
Submission reference: IN2363
Is the following code correct?
PROC monitor.2 ([]CHAN INT in?, ...) [SIZE in?]BOOL ok: ... :
Good question! Sadly, the answer is (currently) no.
Classical occam, being targetted originally at embedded applications (which have finite non-expandable memory resources), was designed to enable the amount of memory needed by an application to be decided before the code was embedded in the target machine (i.e. at compile-time). This was to ensure that the application could not run out of memory at run-time (which would mean, possibly literally, a crash). A design constraint, therefore, was that arrays could only be declared with sizes known at compile time.
Your code is trying to declare an array with the (unspecified) size of an array parameter. Any sized array may be passed, so the compiler cannot determine a specific size and the declaration is, therefore, rejected.
occam-pi does support arrays whose size in not known at compile-time but, we're afraid, the syntax for this is different (and more complex) than the syntax for classical array declarations. This is because run-time sized arrays are supported only for mobile arrays (see slide 14 of "Mobiles etc."). Your declaration needs to be:
PROC monitor.2 ([]CHAN INT in?, ...) INITIAL MOBILE []BOOL ok IS MOBILE [SIZE in?]BOOL: ... :
See the print.streams process declared in your starter files for exercises 3 and 4 (i.e. q3.occ and q4.occ) for a similar example of this.
Once declared as above, the mobile array is used with the same syntax for accessing its elements as the classical pre-sized arrays. It is our intention to rationalise the design of occam-pi (soon) so that mobile arrays and classical arrays are merged into one concept – so that the (very natural) declaration you tried is correct and the complex one above is abolished!
Note: mobility, as presented in the "Mobiles" slides, is not an examinable part of this module. Only some of its slides on barriers (154-161 and 165) are part of the presented material that is examinable (as noted in the Week 11 box of the Moodle page for this course).
2011 |
Submission reference: IN2041
Hello, I am trying to implement what is on Slide 51 of Mobiles. I don't know how to actually send the mobile record of my recursive channel down my custom channel.
Editor: rest of question omitted.
Sorry – you are asking questions about mobile channels that are not in the examinable material for this module!
Now, we do welcome such questions ... but you haven't given enough information for us to understand your particular problem. Please contact me <phw@kent.ac.uk> or Fred <frmb@kent.ac.uk> and fix a time to see one of us. Thanks.
Keywords: mobiles
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |