This program has a typical master-worker structure:
if (i_am_the_master) { <initialise the problem>; <initialise workers>; <send initial batch of the tasks to the workers>; REPEAT { <receive an answer from a worker>; <send another task to the worker if the job is not finished>; or <send a termination signal to the worker if the job is done>; } UNTIL <all workers are dead>; } else { <receive initialisation from the master>; REPEAT { <receive a task from the master>; <work on the task>; <send the answer to the master>; } UNTIL <terminated by the master>; }