Library prosa.analysis.facts.priority.fifo

We first make some trivial observations about the FIFO priority policy to avoid having to re-reason these steps repeatedly in the subsequent proofs.
Section PriorityFacts.

Consider any type of jobs.
  Context `{Job : JobType} {Arrival : JobArrival Job}.

Under FIFO scheduling, ...
  Context {JLFP : JLFP_policy Job}.
  Hypothesis H_policy_is_FIFO : policy_is_FIFO JLFP.

... ~~ hep_job implies a strict inequality on arrival times.
  Fact not_hep_job_arrival_FIFO :
     j j',
      ~~ hep_job j j' = (job_arrival j' < job_arrival j).

Combining the above fact with the definition of FIFO scheduling, we get that, trivially, ~~ hep_job j j' implies hep_job j' j, ...
  Fact not_hep_job_FIFO :
     j j',
      ~~ hep_job j j' hep_job j' j.

... from which we can infer always_higher_priority.
A FIFO policy is reflexive since a job arrives no later than itself.
A FIFO policy is transitive since arrival order is transitive.
Next, we note that FIFO priorities are compatible with sequential task models.
Consider the tasks corresponding to the jobs under consideration.
  Context {Task : TaskType} `{JobTask Job Task}.

FIFO priorities respect sequential tasks because jobs of the same task inherit priority from their arrival order.
We add the following lemmas to the basic facts database
Global Hint Resolve
  FIFO_policy_is_reflexive
  FIFO_policy_is_transitive
  FIFO_policy_respects_sequential_tasks
  : basic_rt_facts.

In this section, we prove some fundamental properties of the FIFO policy.
Section BasicLemmas.

We assume the basic (i.e., Liu & Layland) readiness model under which any pending job is ready.
  #[local] Existing Instance basic_ready_instance.

Consider any type of jobs with arrival times and execution costs.
  Context `{Job : JobType} {Arrival : JobArrival Job} {Cost : JobCost Job}.

Assume FIFO scheduling.
Consider any valid arrival sequence of such jobs ...
... and the resulting uniprocessor schedule.
  Context {PState : ProcessorState Job}.
  Hypothesis H_uniproc : uniprocessor_model PState.
  Variable sched : schedule PState.
We assume that the schedule is valid and work-conserving.
Suppose jobs have preemption points ...
  Context `{JobPreemptable Job}.

...and that the preemption model is valid.
Assume that the schedule respects the FIFO scheduling policy whenever jobs are preemptable.
We observe that there is no priority inversion in a FIFO-compliant schedule.
  Lemma FIFO_implies_no_priority_inversion :
     j t,
      arrives_in arr_seq j
      pending sched j t
      ~~ priority_inversion arr_seq sched j t.

We prove that in a FIFO-compliant schedule, if a job j is scheduled, then all jobs with higher priority than j have been completed.
  Lemma scheduled_implies_higher_priority_completed :
     j t,
      scheduled_at sched j t
       j_hp,
        arrives_in arr_seq j_hp
        ~~ hep_job j j_hp
        completed_by sched j_hp t.

In this section, we prove the cumulative priority inversion for any task is bounded by 0.
Consider any kind of tasks.
    Context `{Task : TaskType} `{JobTask Job Task}.

Consider a task tsk.
    Variable tsk : Task.

Assume the arrival times are consistent.
Assume that the schedule follows the FIFO policy at preemption time.
Assume the schedule is valid.
Assume there are no duplicates in the arrival sequence.
Then we prove that the amount of priority inversion is bounded by 0.
As a corollary, FIFO implies the absence of service inversion.
Finally, let us further assume that there are no needless preemptions among jobs of equal priority.
In the absence of superfluous preemptions and under assumption of the basic readiness model, there are no preemptions at all in a FIFO-compliant schedule.
  Lemma no_preemptions_under_FIFO :
     j t,
      ~~ preempted_at sched j t.
It immediately follows that FIFO schedules are non-preemptive.