CPU scheduling policy
Of the results that are runnable, which ones to execute? BOINC will generally execute NCPUS results at once, where NCPUS is the minimum of the physical number of CPUs (counting hyperthreading) and the user's 'max_cpus' general preference.
Work-fetch policy
When should the core client ask a project for more work, which project should it ask, and how much work should it ask for?

The goals of the CPU scheduler and work-fetch policies are (in descending priority):

The policies are designed to accommodate all scenarios, including those with computers that are slow or are attached to a large number of projects.

In previous versions of BOINC, the core client attempted to maintain at least one result for each attached project, and would do weighted round-robin CPU scheduling among all projects. In some scenarios (any combination of slow computer, lots of projects, and tight deadlines) a computer could miss the deadlines of all its results. The new policies solve this problem as follows:

Concepts and terms

Wall CPU time

A result's wall CPU time is the amount of wall-clock time its process has been runnable at the OS level. The actual CPU time may be less than this, e.g. if the process does a lot of paging, or if other (non-BOINC) processing jobs run at the same time.

BOINC uses wall CPU time as the measure of how much resource has been given to each project. Why not use actual CPU time instead?

Result states

A result is runnable if A result is runnable soon if

Project states

A project is runnable if A project is downloading if A project is contactable if A project is potentially runnable if

Debt

Intuitively, a project's 'debt' is how much work is owed to it, relative to other projects. BOINC uses two types of debt; each is defined for a set S of projects. In each case, the debt is recalculated periodically as follows: Short-term debt is used by the CPU scheduler. It is adjusted over the set of runnable projects. It is normalized so that minimum short-term debt is zero, and maximum short-term debt is no greater than 86400 (i.e. one day).

Long-term debt is used by the work-fetch policy. It is defined for all projects, and adjusted over the set of potentially runnable projects. It is normalized so that average long-term debt is zero.

The CPU scheduling policy

The CPU scheduler uses an earliest-deadline-first (EDF) policy for results that are in danger of missing their deadline, and round-robin among other projects if additional CPUs exist. This allows the client to meet deadlines that would otherwise be missed, while honoring resource shares over the long term. The scheduler uses the following data, which are obtained by a simulation of round-robin scheduling applied to the current work queue:

The scheduling policy is:
  1. Find the project P for which deadlines_missed(P)>0, and whose earliest deadline is earliest.
  2. Schedule deadline_missed(P) results of P in order of increasing deadline, with preference to those already running.
  3. If there are more CPUs, and other projects for which deadlines_missed(P)>0, go to 1.
  4. If all CPUs are scheduled, stop; otherwise continue to the next step, considering only projects with deadlines_missed==0.
  5. Set the 'anticipated debt' of each project to its short-term debt
  6. Find the project P with the greatest anticipated debt, select one of P's runnable results (picking one that is already running, if possible) and schedule that result.
  7. Decrement P's anticipated debt by the 'expected payoff' (the total wall CPU in the last period divided by NCPUS).
  8. Repeat steps 6 and 7 for additional CPUs

The CPU scheduler runs when a result is completed, when the end of the user-specified scheduling period is reached, when new results become runnable, or when the user performs a UI interaction (e.g. suspending or resuming a project or result).

Work-fetch policy

The work-fetch policy uses the functions

prrs(project P)
P's fractional resource share among potentially runnable projects.
min_results(project P)
The minimum number of runnable results needed to maintain P's resource share on this machine: namely,
ceil(ncpus*prrs(P))
time_until_work_done(project P)
The estimated wall time until the number of uncompleted results for this project will reach min_results(P)-1, assuming round-robin scheduling among the current potentially runnable projects.

The work-fetch policy function is called every 5 seconds (or as needed) by the scheduler RPC polling function. It sets the following variable for each project P:

work_request_size(P): the number of seconds of work to request if we do a scheduler RPC to P. This is

The scheduler RPC mechanism may select a project to contact because of a user request, an outstanding trickle-up message, or a result that is overdue for reporting. If it does so, it will also request work from that project. Otherwise, the RPC mechanism chooses the project P for which

P.work_request_size>0 and
P.long_term_debt - time_until_work_done(P) is greatest
and gets work from that project.
Scheduler request must include: whether sporadic network connection (period); whether in EDF mode. Resource fractions?

Scheduler reply should include (it no work sent) if reason is because we're overloaded.

If last response was 'no work', don't accumulate LTD. "; page_tail(); ?>