Bluetooth: controller: Be fair when pre-empting a ticker
When force scheduling a ticker use the number of times the tickers have already skipped their intervals to decide if the forced ticker can pre-empt the colliding ticker. This introduces a fairness amongst tickers contesting for the overlapping time slice. Flashing in co-operation with Radio needs to be fair in order to avoid connection supervision timeouts. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
95d55a2bfc
commit
4ba2bb0d1c
1 changed files with 23 additions and 2 deletions
|
@ -776,20 +776,41 @@ static inline u32_t ticker_job_insert(struct ticker_instance *instance,
|
||||||
{
|
{
|
||||||
struct ticker_node *node = &instance->node[0];
|
struct ticker_node *node = &instance->node[0];
|
||||||
u8_t id_collide;
|
u8_t id_collide;
|
||||||
|
u16_t skip;
|
||||||
|
|
||||||
/* Prepare to insert */
|
/* Prepare to insert */
|
||||||
ticker->next = TICKER_NULL;
|
ticker->next = TICKER_NULL;
|
||||||
|
|
||||||
|
/* No. of times ticker has skipped its interval */
|
||||||
|
if (ticker->lazy_current > ticker->lazy_periodic) {
|
||||||
|
skip = ticker->lazy_current -
|
||||||
|
ticker->lazy_periodic;
|
||||||
|
} else {
|
||||||
|
skip = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* If insert collides, remove colliding or advance to next interval */
|
/* If insert collides, remove colliding or advance to next interval */
|
||||||
while (id_insert !=
|
while (id_insert !=
|
||||||
(id_collide = ticker_enqueue(instance, id_insert))) {
|
(id_collide = ticker_enqueue(instance, id_insert))) {
|
||||||
/* check for collision */
|
/* check for collision */
|
||||||
if (id_collide != TICKER_NULL) {
|
if (id_collide != TICKER_NULL) {
|
||||||
struct ticker_node *ticker_collide;
|
struct ticker_node *ticker_collide = &node[id_collide];
|
||||||
|
u16_t skip_collide;
|
||||||
|
|
||||||
|
/* No. of times ticker colliding has skipped its
|
||||||
|
* interval.
|
||||||
|
*/
|
||||||
|
if (ticker_collide->lazy_current >
|
||||||
|
ticker_collide->lazy_periodic) {
|
||||||
|
skip_collide = ticker_collide->lazy_current -
|
||||||
|
ticker_collide->lazy_periodic;
|
||||||
|
} else {
|
||||||
|
skip_collide = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ticker_collide = &node[id_collide];
|
|
||||||
if (ticker_collide->ticks_periodic &&
|
if (ticker_collide->ticks_periodic &&
|
||||||
ticker_collide->ticks_periodic &&
|
ticker_collide->ticks_periodic &&
|
||||||
|
skip_collide <= skip &&
|
||||||
ticker_collide->force < ticker->force) {
|
ticker_collide->force < ticker->force) {
|
||||||
/* dequeue and get the reminder of ticks
|
/* dequeue and get the reminder of ticks
|
||||||
* to expire.
|
* to expire.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue