Skip to content

Many Connected Tasks

20090414 (2009 April 14 Tuesday)


The Problem

You can put all the functionality in a single process but this may not be easy. You may be limited to one language. A bug in one part can affect another. You have to debug it all at the same time. If it has a GUI as its interface it will be difficult to do automated tests.


To help to separate concerns, break the program in to multiple processes and connect them with inter-process pipes.

A single process task

A Task is usually single stand alone process. It is protected from other tasks. Each process can be written in a different language, by different people, at different times. A Task can talk to the outside world via files, and std in, out and error. A Task has one Std in, out and error.

A Task Here is a task just showing the standard in,out and error. All Tasks Have these input/outputs. Any additional I/O must be created by the Task.

Task PipeLine

A PipeLine of Tasks A PipeLine is probably the most common way to connect processes. It is easy to do this using a shell. You just type the following (Where A,B,C are the names of the programs): A | B | C . This can be done interactively of from a shell script. As you can see the new Task is made of 3 processes, but it still has one std in, out, and error. Processes A,B,C do not need to know about each other, they just talk via std in, out, and error. The shell does not know How A,B,or C works, it just connects them up.

Task Harness

A Task Harness In a Task Harness task A Starts Task B and connects to it via B’s std in/out, and additional FILE descriptors on A. As you can see the new Task is made of 2 processes, but it still has one std in, out, and error. B does not Know about A. But A knows about B and must do the connecting. A does not know HOW B works. The shell only knows about A. A could open many others processes in the same way.


So tasks don’t have to be single processes. In the diagrams above the tasks may be multi process tasks (Pipeline, Task-Harness, or another pattern). No matter how you connect tasks you will have many processes but you can think of the result as a task and then connect this to produce a still more complex task.

Next: Creating Inter process pipes

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: