deneir/scheduling/scheduling.typ
2024-07-19 18:17:01 -04:00

61 lines
3 KiB
Typst

#import "@preview/acrostiche:0.3.2": *
#init-acronyms((
"EBS": ("Equation-Based Scheduling",),
))
#align(center)[#text(size:2em)[Equation-Based Scheduling]]
The principle of #acr("EBS") is to use a function to determine which task is allowed to communicate at anypoint in time.
This principle provide a mathematically proovable way for each task to determine when to communicate without collision.
*Problem Statement:*
#grid(
columns: (1fr,15fr,1fr),
[],[
Given $n$ tasks $t_i, i in [0,n-1]$,
and a schedule array of $m$ time periods $A = [x_0, dots.h.c, x_(m-1)]$
where each element $x_i in [t_0,dots.h.c, t_(n-1)]$ is the task allowed to communicate at time $tau_i$,
provide a scheduling functions $s$ such that,
for each time period $tau_i$, $s(tau_i) = A[tau_i]$.
],
[]
)
= Polynomials
Contrary to popular beliefs, polynomials are not boring.
Let us consider a problem with four tasks $(t_0,t_1,t_2,t_3)$ and a schedule array of 20 time periods
$
A = [0,1,2,3,0,0,1,2,0,1,2,3,0,3,0,2,3,2,0,1]
$
#figure(
image("images/polyfit.svg", width:100%),
caption: "Scheduling function defined as a polynomial fit of the scheduling array."
)<fig-polyfit>
== Clock Sensitivity
In order for every task to know when they can transmit, they all need to evaluate the scheduling function at the same times.
In the real world, that could be very difficult as the clock of each task can drift over time.
Some people suggested to use atomic clock chips as the RTC of clock so that, after a syncronisation phase, all timings across tasks would remain exact #footnote[Atomic clocks drift is estimated at one second per hunred million year (Wikipedia).].
However, I suspect that the person proposing this solution have atomic clock in their office drawer and don't think of us, mere students, that do not have 6k to invest in a fancy clock.
This raises the question; How sensitive is a scheduling function to clock imprecision?
After all, the function is exact on the start of the period but has no constraint during the period.
We define the clock sensitivity of a scheduling function $"cs"(s)$ as the maximum time delta around any period start without an incorrect task decision.
$
"cs"(s) = max_(delta t)(s(tau_i plus.minus delta t) = A[tau_i]; forall tau_i)
$
Let us consider again the example displayed in @fig-polyfit.
As the degree of the polynomial grows to perfectly fit the schedul, extreme variations appear during the periods.
These extreme variations induce high derivative of the function at the sampling time that makes the clock sensitivity very small.
== Problems with Polynomials
A single polynomial fitted to the schedul does not seem like a good approach as it require a very precise clock to obtain the correct values.
Moreover, storing the polynomial coefficient for the function requires at least as much memory as storing the schedule itself.
Finally, evaluating the function is more computation-intensive than looking up a value in a table.
= Regression, imprefect fit, and flatten scheduling array.