Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.


When starting a job, Upstart does not currently take the state of the system into account, and will start all jobs simultaneously. This specification proposes a method of adding resource locks, that prevent contending jobs from starting together and instead starts them in serial.


Jobs frequently consume a large amount of a particular resource, the most common example being the CPU. It is often faster to start these jobs in serial than run them in parallel, especially where the resource is something with a seek penalty, for example a disk.

Use cases


This scope of this specification is limited to the implementation of resource locks within the existing process state machine.




The JobConfig structure will gain a new array of resource names that it consumes and the amount it will consume; likewise the Job structure will gain an array of resource names that it is actually going to consume.

A global Resources list will exist holding the current level of resource available for each known.

On creating a new job, the resource names will be expanded and stored in the new instance structure.

Before changing the state, all of these resources will be checked to ensure that they do not exist or if the amount required is subtracted, they do not become less than zero. If true, any missing resources are added with 1.0, then the global resource amount of all is subtracted and the job state is changed.

If false (insufficient resource exists), the job will remain in the waiting state.

When a job reaches the waiting state again, the resources consumed will be added back to the global resource amount. The jobs stuck in the waiting state will be iterated, and if the required resource is now free, will have their state changed.

This will likely require a function to determine whether a job can state change, *sigh*

Data preservation and migration

These changes are backwards compatible with the previous behaviour.

Unresolved issues

Resources (last edited 2008-03-08 15:03:43 by scott)