EE445M RTOS
Taken at the University of Texas Spring 2015
edf.h File Reference
Include dependency graph for edf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SCHEDULER_MAX_THREADS   16
 

Functions

void edf_init ()
 
void edf_insert (sched_task *)
 
tcb_tedf_pop ()
 

Macro Definition Documentation

#define SCHEDULER_MAX_THREADS   16

Definition at line 16 of file edf.h.

Function Documentation

void edf_init ( )

Initialize the Earliest Deadline First task queue

Precondition
ensure at least one task has been scheduled prior to invoking this function

Definition at line 475 of file os.c.

References DL_EDF_INSERT, edf_insert(), sched_task_pool::next, sched_task_pool::queue, and SCHEDULER_QUEUES.

Referenced by os_launch().

475  {
476 
478  sched_task_pool *next = start->next;
479 
480  /* avoid the NULL EDF_QUEUE to allow optimized form of `edf_insert' */
481  DL_EDF_INSERT(EDF_QUEUE, start->queue);
482 
483  /* Create the rest of the EDF */
484  while(next && next != start) {
485  /* DL_EDF_INSERT(EDF_QUEUE, next->queue); */
486  edf_insert(next->queue);
487  next = next->next;
488  }
489 }
#define DL_EDF_INSERT(head, add)
Definition: utlist.h:538
void edf_insert(sched_task *task)
Definition: os.c:491
volatile sched_task * EDF_QUEUE
Definition: os.c:27
struct sched_task_pool * next
sched_task * queue
static volatile sched_task_pool * SCHEDULER_QUEUES
Definition: schedule.h:38

Here is the call graph for this function:

Here is the caller graph for this function:

void edf_insert ( sched_task )

Add by insertion sort the specified task into the EDF queue

Definition at line 491 of file os.c.

References sched_task::absolute_deadline, DL_EDF_INSERT, DL_EDF_PREPEND, EDF_QUEUE, and sched_task::pri_next.

Referenced by edf_init(), edf_pop(), and scheduler_reschedule().

491  {
492 
493  sched_task *elt = EDF_QUEUE;
494 
495  while(elt && task->absolute_deadline > elt->absolute_deadline) {
496  elt = elt->pri_next;
497  }
498  /* inject task at point -- if elt is null, this is the new end*/
499  if (elt) {
500  if (elt == EDF_QUEUE) {
501  DL_EDF_PREPEND(elt, task);
502  EDF_QUEUE = elt;
503  } else {
504  DL_EDF_PREPEND(elt, task);
505  }
506  } else {
507  /* TODO: this incurs the O(n) again, optimize */
508  DL_EDF_INSERT(EDF_QUEUE, task);
509  }
510 }
#define DL_EDF_INSERT(head, add)
Definition: utlist.h:538
volatile sched_task * EDF_QUEUE
Definition: os.c:27
#define DL_EDF_PREPEND(head, add)
Definition: utlist.h:513
struct sched_task * pri_next
tick_t absolute_deadline

Here is the caller graph for this function:

tcb_t* edf_pop ( )

Definition at line 512 of file os.c.

References sched_task::absolute_deadline, sched_task_pool::deadline, edf_insert(), EDF_QUEUE, sched_task::next, sched_task_pool::next, sched_task::pri_next, sched_task_pool::queue, SCHEDULER_QUEUES, SYSTICKS_PER_HZ, and sched_task::tcb.

512  {
513 
514  volatile sched_task *executing = EDF_QUEUE;
516 
517  /* DL_EDF_DELETE(EDF_QUEUE, elt); */
518  /* TODO: CHECKME: should we use pri_next or pri_prev?? */
520 
521  /* KLUDGE: fix this for production */
522  while (pool->queue != executing) {
523  pool = pool->next;
524  }
525  /* will drop out with pool->queue = executing */
526 
527  executing->absolute_deadline = pool->deadline * SYSTICKS_PER_HZ;
528 
529  /* do the recycling, change the pool's head */
530  /* TODO: CHECKME: should we use next or prev?? */
531  pool->queue = executing->next;
532  edf_insert(pool->queue);
533 
534  /* TODO: after use, put the command back in the appropriate pool */
535  return executing->tcb;
536 }
#define SYSTICKS_PER_HZ
Definition: schedule.h:20
volatile sched_task_pool * pool
Definition: os.c:18
volatile sched_task * executing
Definition: os.c:17
void edf_insert(sched_task *task)
Definition: os.c:491
volatile sched_task * EDF_QUEUE
Definition: os.c:27
frequency_t deadline
struct sched_task * pri_next
struct sched_task_pool * next
sched_task * queue
struct sched_task * next
tick_t absolute_deadline
static volatile sched_task_pool * SCHEDULER_QUEUES
Definition: schedule.h:38

Here is the call graph for this function: