Spawning an appropriate number of processes