The topic of this article may not meet Wikipedia's general notability guideline .(November 2014) |
JCSP is an implementation of communicating sequential processes (CSP) for the programming language Java. [1]
Although CSP is a mathematical system, JCSP does not require in-depth mathematical skill, allowing instead that programmers can achieve well-behaved software by following simple rules.
There are four ways in which multi-threaded programs can fail untestably: [1]
Generally, it is not possible to prove the absence of these four hazards merely by rigorous testing. Although rigorous testing is necessary, it is not sufficient. Instead it is necessary to have a design that can demonstrate these four hazards don't exist. CSP allows this to be done using mathematics and JCSP allows it to be done pragmatically in Java programs.
The benefit of the basis in mathematics is that stronger guarantees of correct behaviour can be produced than would be possible with conventional ad hoc development. Fortunately, JCSP does not force its users to adopt a mathematical approach themselves, but allows them to benefit from the mathematics that underpins the library.
Note that the CSP term process is used essentially as a synonym for thread in Java parlance; a process in CSP is a lightweight unit of execution that interacts with the outside world via events and is an active component that encapsulates the data structures on which it operates.
Because the encapsulation of data is per-thread (per process in CSP parlance), there is typically no reliance on sharing data between threads. Instead, the coupling between threads happens via well-defined communication points and rendezvous. The benefit is that each thread can broadly be considered to be a "single-threaded" entity during its design, sparing the developer from the uncertainties of whether and where to use Java's synchronized keyword, and at the same time guaranteeing freedom from race conditions. JCSP provides for clear principles for designing the inter-thread communication in a way that is provably free from deadlock.
There is a clear similarity between some classes in the standard Java API (java.util.concurrent) and some in JCSP. JCSP's channel classes are similar to the BlockingQueue. There is one important difference: JCSP also provides an Alternative class to allow selection between inputs; this capability is absent from the standard Java API. Alternation is one of the core concepts that CSP uses to model events in the real world.
Alternative was proven to operate correctly by exhaustive mathematical analysis of its state space, guaranteeing it can never in itself cause a deadlock. [2] As such, it epitomises the dependability of JCSP from its mathematical basis.
Because Transmission Control Protocol (TCP) sockets can be constructed to behave as blocking channels in the CSP sense, it is possible to distribute JCSP processes across multiple computers. This is achieved using the JCSP Net extension that provides channels with CSP semantics using TCP. Because CSP is compositional, it does not matter in behaviour terms whether processes are co-located or distributed. The only difference is in the relative performance. So it is possible, for example, to develop an application on a single server then compare multi-processor version of the same application with the aim of optimising the performance.
JCSP re is a highly reduced version of the JCSP packages developed around 2008 at the Napier University Edinburgh by Professor Jon Kerridge, Alex Panayotopoulos and Patrick Lismore. Research into JCSP for robotics environments and JCSP for mobile environments is an active area of research at Napier University Edinburgh. The working implementation of 'JCSP re' allows the development of the same concurrent software for robots. Specifically, the robots targeted for this research were the Lego Mindstorms NXTs because they can run the popular LeJOS NXJ virtual machine that executes Java source code. [3]
JCSP is essentially a pure-Java API (although a research alternative exists that uses the C-CSP extension to the JVM). As such, it is in principle eminently suitable for concurrency in Scala and Groovy applications as well as Java ones.
JCSP can therefore provide an alternative to Scala's actor model. JCSP uses synchronised communication and actors use buffered (asynchronous) communication, each of which have their advantages in certain circumstances. JCSP allows its channels to be buffered so can easily emulate the actor model; the converse is not true.
In computer science, mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions. It is the requirement that one thread of execution never enters a critical section while a concurrent thread of execution is already accessing said critical section, which refers to an interval of time during which a thread of execution accesses a shared resource or shared memory.
In computing, a process is the instance of a computer program that is being executed by one or many threads. There are many different process models, some of which are light weight, but almost all processes are rooted in an operating system (OS) process which comprises the program code, assigned system resources, physical and logical access permissions, and data structures to initiate, control and coordinate execution activity. Depending on the OS, a process may be made up of multiple threads of execution that execute instructions concurrently.
In multi-threaded computer programming, a function is thread-safe when it can be invoked or accessed concurrently by multiple threads without causing unexpected behavior, race conditions, or data corruption. As in the multi-threaded context where a program executes several threads simultaneously in a shared address space and each of those threads has access to all every other thread's memory, thread-safe functions need to ensures all those threads behave properly and fulfill their design specifications without unintended interaction.
In computer science, a lock or mutex is a synchronization primitive that prevents state from being modified or accessed by multiple threads of execution at once. Locks enforce mutual exclusion concurrency control policies, and with a variety of possible methods there exist multiple unique implementations for different applications.
In computer science, communicating sequential processes (CSP) is a formal language for describing patterns of interaction in concurrent systems. It is a member of the family of mathematical theories of concurrency known as process algebras, or process calculi, based on message passing via channels. CSP was highly influential in the design of the occam programming language and also influenced the design of programming languages such as Limbo, RaftLib, Erlang, Go, Crystal, and Clojure's core.async.
The calculus of communicating systems (CCS) is a process calculus introduced by Robin Milner around 1980 and the title of a book describing the calculus. Its actions model indivisible communications between exactly two participants. The formal language includes primitives for describing parallel composition, choice between actions and scope restriction. CCS is useful for evaluating the qualitative correctness of properties of a system such as deadlock or livelock.
In computer science, message queues and mailboxes are software-engineering components typically used for inter-process communication (IPC), or for inter-thread communication within the same process. They use a queue for messaging – the passing of control or of content. Group communication systems provide similar kinds of functionality.
A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events, leading to unexpected or inconsistent results. It becomes a bug when one or more of the possible behaviors is undesirable.
In computing, a memory barrier, also known as a membar, memory fence or fence instruction, is a type of barrier instruction that causes a central processing unit (CPU) or compiler to enforce an ordering constraint on memory operations issued before and after the barrier instruction. This typically means that operations issued prior to the barrier are guaranteed to be performed before operations issued after the barrier.
In computer science, concurrency is the ability of different parts or units of a program, algorithm, or problem to be executed out-of-order or in partial order, without affecting the outcome. This allows for parallel execution of the concurrent units, which can significantly improve overall speed of the execution in multi-processor and multi-core systems. In more technical terms, concurrency refers to the decomposability of a program, algorithm, or problem into order-independent or partially-ordered components or units of computation.
In Unix-like computer operating systems, a pipeline is a mechanism for inter-process communication using message passing. A pipeline is a set of processes chained together by their standard streams, so that the output text of each process (stdout) is passed directly as input (stdin) to the next one. The second process is started as the first process is still executing, and they are executed concurrently.
The actor model in computer science is a mathematical model of concurrent computation that treats an actor as the basic building block of concurrent computation. In response to a message it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to the next message received. Actors may modify their own private state, but can only affect each other indirectly through messaging.
In computer science, the Actor model and process calculi are two closely related approaches to the modelling of concurrent digital computation. See Actor model and process calculi history.
Concurrent computing is a form of computing in which several computations are executed concurrently—during overlapping time periods—instead of sequentially—with one completing before the next starts.
The actor model and process calculi share an interesting history and co-evolution.
In computer science and engineering, transactional memory attempts to simplify concurrent programming by allowing a group of load and store instructions to execute in an atomic way. It is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing. Transactional memory systems provide high-level abstraction as an alternative to low-level thread synchronization. This abstraction allows for coordination between concurrent reads and writes of shared data in parallel systems.
A network socket is a software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. The structure and properties of a socket are defined by an application programming interface (API) for the networking architecture. Sockets are created only during the lifetime of a process of an application running in the node.
The Java programming language and the Java virtual machine (JVM) is designed to support concurrent programming. All execution takes place in the context of threads. Objects and resources can be accessed by many separate threads. Each thread has its own path of execution, but can potentially access any object in the program. The programmer must ensure read and write access to objects is properly coordinated between threads. Thread synchronization ensures that objects are modified by only one thread at a time and prevents threads from accessing partially updated objects during modification by another thread. The Java language has built-in constructs to support this coordination.
Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.
Join-patterns provides a way to write concurrent, parallel and distributed computer programs by message passing. Compared to the use of threads and locks, this is a high level programming model using communication constructs model to abstract the complexity of concurrent environment and to allow scalability. Its focus is on the execution of a chord between messages atomically consumed from a group of channels.
{{cite journal}}
: CS1 maint: bot: original URL status unknown (link)