/*
 * Given an element, remove it from the btree if it's already
 * there and re-insert it based on its current key.
 */
void
schedule_add_modify (struct schedule *s, struct schedule_entry *e)
{
#ifdef ENABLE_DEBUG
  if (check_debug_level (D_SCHEDULER))
    schedule_entry_debug_info ("schedule_add_modify", e);
#endif

  /* already in tree, remove */
  if (IN_TREE (e))
    schedule_remove_node (s, e);

  /* set random priority */
  schedule_set_pri (e);

  if (s->root)
    schedule_insert (s, e);      /* trivial insert into tree */
  else
    s->root = e; /* tree was empty, we are the first element */

  /* This is the magic of the randomized treap algorithm which
     keeps the tree balanced.  Move the node up the tree until
     its own priority is greater than that of its parent */
  while (e->parent && e->parent->pri > e->pri)
    schedule_rotate_up (s, e);
}
void
schedule_remove_entry (struct schedule *s, struct schedule_entry *e)
{
  mutex_lock (&s->mutex);
  s->earliest_wakeup = NULL; /* invalidate cache */
  schedule_remove_node (s, e);
  mutex_unlock (&s->mutex);
}
示例#3
0
void
schedule_remove_entry (struct schedule *s, struct schedule_entry *e)
{
  s->earliest_wakeup = NULL; /* invalidate cache */
  schedule_remove_node (s, e);
}