Library prosa.model.processor.restricted_supply
The Restricted Supply Model
We define the state of a processor at a given time to be one of
four possible cases:
The processor is idle. We could service a job, so we are
wasting the capacity of the supply.
| Idle
A job is being executed.
A job is scheduled, but the processor is unavailable and yields
no service.
The processor is unavailable, and no job is being scheduled.
Consider any type of jobs.
Next, we define the semantics of the processor state with
restricted supply.
Let j denote any job.
Definition rs_scheduled_on (s : processor_state) : bool :=
match s with
| Idle | Inactive ⇒ false
| Active j' | Unavailable j' ⇒ j' == j
end.
match s with
| Idle | Inactive ⇒ false
| Active j' | Unavailable j' ⇒ j' == j
end.
Processor states Idle and Active _ indicate that the
processor is ready to produce 1 unit of supply. If the
processor is in state Unavailable _ or Inactive, it
produces 0 unit of work.
Definition rs_supply_on (s : @processor_state Job) : work :=
match s with
| Idle | Active _ ⇒ 1
| _ ⇒ 0
end.
match s with
| Idle | Active _ ⇒ 1
| _ ⇒ 0
end.
Definition rs_service_on (s : processor_state) : work :=
if s is Active j'
then if j' == j then 1 else 0
else 0.
End Service.
if s is Active j'
then if j' == j then 1 else 0
else 0.
End Service.
Finally, we connect the above definitions with the generic Prosa
interface for abstract processor states.
Program Definition rs_processor_state : ProcessorState Job :=
{|
State := processor_state;
scheduled_on j s (_ : unit) := rs_scheduled_on j s;
supply_on s (_ : unit) := rs_supply_on s;
service_on j s (_ : unit) := rs_service_on j s
|}.
Next Obligation. by move⇒ j s r; case s, r ⇒ //=; case: (_ == _). Qed.
Next Obligation. by move⇒ j s r; case s, r ⇒ //=; case: (_ == _). Qed.
End State.
{|
State := processor_state;
scheduled_on j s (_ : unit) := rs_scheduled_on j s;
supply_on s (_ : unit) := rs_supply_on s;
service_on j s (_ : unit) := rs_service_on j s
|}.
Next Obligation. by move⇒ j s r; case s, r ⇒ //=; case: (_ == _). Qed.
Next Obligation. by move⇒ j s r; case s, r ⇒ //=; case: (_ == _). Qed.
End State.