CSP for Java
(JCSP) 1.0-rc4

Package jcsp.lang

This provides classes and interfaces corresponding to the fundamental primitives of CSP.

See:
          Description

Interface Summary
Channel This defines the interface for reading and writing object channels.
ChannelAccept This defines the interface for accepting CALL channels.
ChannelInput This defines the interface for reading from object channels.
ChannelInputInt This defines the interface for reading from integer channels.
ChannelInt This defines the interface for reading and writing integer channels.
ChannelOutput This defines the interface for writing to object channels.
ChannelOutputInt This defines the interface for writing to integer channels.
CSProcess This is the JCSP interface for a process - an active component that encapsulates the data structures on which it operates.
 

Class Summary
Alternative This enables a process to wait passively for and choose between a number of Guard events.
AltingChannel This defines the interface to object channels for reading, writing and choosing between multiple inputs (and other events).
AltingChannelAccept This extends Guard and ChannelAccept to enable a process to choose between many CALL channel (and other) events.
AltingChannelInput This extends Guard and ChannelInput to enable a process to choose between many object input (and other) events.
AltingChannelInputInt This extends Guard and ChannelInputInt to enable a process to choose between many integer input (and other) events.
AltingChannelInt This defines the interface to integer channels for reading, writing and choosing between multiple inputs (and other events).
Any2AnyCallChannel This is the super-class for any-to-any interface-specific CALL channels, safe for use by many clients and many servers.
Any2AnyChannel This implements a any-to-any object channel, safe for use by many writers and many readers.
Any2AnyChannelInt This implements a any-to-any integer channel, safe for use by many writers and many readers.
Any2OneCallChannel This is the super-class for any-to-one interface-specific CALL channels, safe for use by many clients and one server.
Any2OneChannel This implements a any-to-one object channel, safe for use by many writers and one reader.
Any2OneChannelInt This implements a any-to-one integer channel, safe for use by many writers and one reader.
Barrier This enables barrier synchronisation between a set of processes.
BlackHoleChannel This implements ChannelOutput with black hole semantics.
BlackHoleChannelInt This implements ChannelOutputInt with black hole semantics.
Bucket This enables bucket synchronisation between a set of processes.
Crew This provides a Concurrent Read Exclusive Write (CREW) lock for synchronising fair and secure access to a shared resource.
CSTimer This is a Guard for setting timeouts in an Alternative.
Guard This is the super-class for all Alternative events selectable by a process.
One2AnyCallChannel This is the super-class for one-to-any interface-specific CALL channels, safe for use by one client and many servers.
One2AnyChannel This implements a one-to-any object channel, safe for use by one writer and many readers.
One2AnyChannelInt This implements a one-to-any integer channel, safe for use by one writer and many readers.
One2OneCallChannel This is the super-class for one-to-one interface-specific CALL channels.
One2OneChannel This implements a one-to-one object channel.
One2OneChannelInt This implements a one-to-one integer channel.
Parallel This constructor taks an array of CSProcesses and returns a CSProcess that is the parallel composition of its process arguments.
PriParallel This is an extension of the Parallel class that prioritises the processes given to its control.
ProcessManager This enables a CSProcess to be spawned concurrently with the process doing the spawning.
ProcessNetwork Deprecated. Use ProcessManager.
Sequence This constructor taks an array of CSProcesses and returns a CSProcess that is the sequential composition of its process arguments.
Sequential Deprecated. Use Sequence.
Skip This is a process that immediately terminates and a Guard that is always ready.
Skipper Deprecated. Use Skip.
Stop This is a process that starts, engages in no events, performs no computation but refuses to terminate.
TaggedProtocol TaggedProtocol is the base class for messages carrying an occam2-like tagged (CASE) protocol over JCSP channels.
 

Error Summary
ProcessInterruptedError This is thrown if a process is interrupted whilst blocked during synchronisation - processes should never be interrupted.
 

Package jcsp.lang Description

This provides classes and interfaces corresponding to the fundamental primitives of CSP.

Processes, Networks and Synchronisation

In JCSP, a process is an instance of a class implementing the CSProcess interface - its behaviour being determined by the implementation of its run() method. Processes may be composed in Sequence or Parallel (or PriParallel), the result of this composition being another process. Processes may also be spawned to run concurrently with the spawning process - see ProcessManager. A collection of parallel processes is called a network.

Processes encapsulate both data and algorithms. Parallel processes interact either by synchronised communication along Channels (the cleanest and simplest way) or by synchronised access to shared objects. The latter synchronisation may be achieved through channel signals or by a range of other JCSP primitives (such as Barrier, Bucket or Crew).

Channels

Channels come in two varieties: those that carry Object references and those that carry ints. For completeness, JCSP should provide channels specific to all the Java primitive types. These could trivially be added but, so far, do not seem to be needed in practice.

Channels (from the Point of View of a Process)

Processes should drive their channels through channel interfaces: ChannelInput / ChannelOutput (for Object channels) and ChannelInputInt / ChannelOutputInt (for int channels).

Processes may passively wait for a number of events using Alternative. These events include channel inputs (AltingChannelInput / AltingChannelInputInt), channel accepts (AltingChannelAccept), timeouts (CSTimer) and skips (Skip). If more than one event is ready, an arbitrary, prioritised or fair choice can be made between them. The super-interface for all these ALTable events is Guard.

Channels (from the Point of View of a Network)

Actual channels must be constructed by the Parallel network builder and passed to the processes needing them (usually via their constructors). Four varieties are available for Object channels: One2OneChannel, Any2OneChannel, One2AnyChannel and Any2AnyChannel. Similarly, four varieties are available for int channels: One2OneChannelInt, Any2OneChannelInt, One2AnyChannelInt and Any2AnyChannelInt. Please note that the last two in each set are not broadcasting channels - broadcasting has to be achieved by active processes (e.g. Delta).

Note that the default semantics for all the above channels are zero-buffering and full synchronisation. This means that a writer to a channel will wait for a matching reader and vice-versa - whoever gets to the channel first will wait for its partner. Various forms of buffering can be introduced by splicing active buffer processes into these channels. However, because this is a common need, JCSP provides a range of plug-ins that can be used to create channels with the common varieties of buffering: blocking FIFO, overwriting (oldest) FIFO, overwriting (latest) FIFO and infinite FIFO. That set of plug-ins is for Object channels and comes from the jcsp.util package. A similar set for int channels is provided in jcsp.util.ints.

It is the network builder's responsibility to decide whether to use 1-1, any-1, 1-any or any-any channels and whether to incorporate buffered semantics in them. The process designer is not concerned with these decisions - only with whether the channel is for input or output and what type of information it carries.

Call Channels

Call Channels provide a method interface for client-server communication between active processes, yet their semantics remain those of a synchronising zero-buffered channel. Without them, we would normally have to set up a pair of channels (giving bi-directional communication) and use a sequence of channel write(s) and read (at the client end) matched by a sequence of channel read(s) and write (at the server end).

The client process sees a server-specific method interface and invokes it in the normal way - however, the invocation will block until the server chooses to accept the call. The server sees the ChannelAccept interface - invoking an accept will block until the client makes a call.

The network builder constructs a server-specific actual call channel by sub-classing from one of One2OneCallChannel, Any2OneCallChannel, One2AnyCallChannel and Any2AnyCallChannel. Precise rules for making this extension are given in their documentation.


CSP for Java
(JCSP) 1.0-rc4

Submit a bug or feature to jcsp-team@ukc.ac.uk
Version 1.0-rc4 of the JCSP API Specification (Copyright 1997-2000 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.