start_section : to_run : integer; i : integer; laxity : array (tasks_range) of integer; low_laxity : integer; high_laxity : integer; low_index : integer; high_index : integer; high_priority : integer; low_priority : integer; end section; priority_section : low_laxity:=integer'last; low_priority:=0; high_laxity:=integer'last; high_priority:=0; laxity := tasks.start_time + ((tasks.activation_number-1)*tasks.period) + tasks.deadline-tasks.rest_of_capacity; for i in tasks_range loop if (tasks.ready(i)=true) then if (tasks.criticity(i)="low") then if ( (low_laxity=laxity(i)) and (low_prioritylaxity(i)) then low_index:=i; low_laxity:=laxity(i); low_priority:=tasks.priority(i); end if; else if ( (high_laxity=laxity(i)) and (high_prioritylaxity(i)) then high_index:=i; high_laxity:=laxity(i); high_priority:=tasks.priority(i); end if; end if; end if; end loop; if (high_laxity=integer'last) then to_run:=low_index; else to_run:=high_index; end if; end section; election_section : return to_run; end section;