A tutorial introduction to Occam programming
Dick Pountain
Including language definition by David May
March 1987
INMOS document number: 72-OCC-046-00
114 Pages
Introduction
The aim of this tutorial is to introduce the reader to concurrent programming using the occam language. It will provide examples of occam programs, and discuss the novel concepts which occam employs. It is not however the definitive guide to the syntax of occam; that you will find in the Formal Definition by David May which forms the second half of this book.
Occam is rapidly being recognised as a solution to the problem of programming concurrent systems of all kinds, and as a powerful and expressive calculus for describing concurrent algorithms.
Occam bears a special relationship with the INMOS Transputer, a high performance single chip computer whose architecture facilitates the construction of parallel processing systems. The Transputer executes occam programs more or less directly (ie. occam is the "assembly language of the Transputer").
Parallel computer systems can be designed in occam, and then implemented using Transputers as "hardware occam processes". This intimate relation between the software and hardware will be novel to most system designers, who are perhaps used to a more rigid division of labour.
The approach taken in this manual is therefore governed by the realisation that some of its potential readers will not be professional programmers, but rather professional engineers and system designers who wish to use occam to design hardware systems.
For this reason we do not assume extensive knowledge of any other high-level computer language, nor of machine level programming, on the part of the reader. We do however assume a familiarity with the general concepts of computing and computer programming; it is not a manual for the novice to computing.
The tutorial is concerned purely with the language occam and will only briefly address the issues of installing occam programs onto Transputer systems. It is intended as a general introduction to the language, equally suitable for those readers who intend to use occam on conventional computers.
We shall not insist that any particular computer/compiler combination (or indeed any hardware at all) be available to the reader; hardware dependent aspects of occam are concentrated into a single chapter at the end of the course.
For the same reasons, there will be no instruction in the detailed workings of particular occam compilers. Error reporting will not be covered except in a general way. Details of this kind are to be found in the Programmer's Manual which accompanies an occam compiler.
Acknowledgements: Many thanks to the Inmos staff who took time out from writing the compiler to check this text and to improve the examples. In particular to David May and Ron Laborde. Any mistakes that have crept back in are the responsibility of the author.
Occam Tutorial
INMOS document number: 72-OCC-043-07
1 Introduction 2 Signposts 3 The Concepts 4 Fundamentals of occam programming 5 Arrays in occam 6 Channel communication 7 Characters and Strings 8 Replicators 9 Real-Time Programming in occam 10 Configuration 11 Terminating Concurrent Programs 12 Occam Programming Style
Occam 2 language definition
INMOS document number: 72-OCC-044-02
A Introduction B Notation C Process D Replicator E Case F Multiple assignment G Types H Scope I Protocol J Procedure K Variable, Channel and Timer L Literal M Expression N Function O Timer input P Character set Q Configuration R Invalid processes S Retyping T External input and output