Spawning Processes From Ada Using The Ada Spawn Manager

The codelabs.ch project is steadily growing their collection of nice Ada projects, the latest being the Ada Spawn Manager:

The Ada spawn manager implements the concept described in the GNAT GPL package System.OS_Lib. It is used to solve the problem of spawning processes at arbitrary times from multitasking Ada programs:

If the parent is using tasking, and needs to spawn subprocesses at arbitrary times, one technique is for the parent to spawn (very early) a particular spawn-manager subprocess whose job is to spawn other processes. The spawn-manager avoids tasking. The parent sends messages to the spawn-manager requesting it to spawn processes, using whatever inter-process communication mechanism you like, such as sockets.

SYSTEM.OS_LIB specification
— GNAT COMPILER COMPONENTS

The Ada spawn manager uses UNIX domain sockets provided by the Anet library to implement fast and simple IPC.

Fun!

Currently there’s no official release version, but you can git clone the development version:

git clone http://git.codelabs.ch/git/spawn-manager.git

I wonder how this compares to spawning processes using the Florist POSIX package found at libre.adacore.com?

2 thoughts on “Spawning Processes From Ada Using The Ada Spawn Manager”

  1. Hi Thomas,

    Nice to see that there is some interest in the Ada Spawn Manager project.

    Using florist directly would not solve the problem: If you have a multitasking Ada application you need to factor out the spawning of new child processes into a different process (if you spawn child processes at arbitrary times). The result is that you need some RPC mechanism between the actual client code and the process which does the spawning.

    The spawn manager does all that by using Anet’s UNIX domain sockets + in-memory record marshaling/unmarshaling for simple and fast RPC. Internally, GNAT.Expect is used to spawn the childs. Of course you could also use florist for this task but I think it is better to use a high level API if possible.

    – reto

Leave a Reply