Ejemplo n.º 1
0
int destroy_cache(cache_t *c)
{
	printk(1, "[cache]: Destroying cache '%s'...\n", c->name);
	rwlock_acquire(c->rwl, RWL_WRITER);
	chash_t *h = c->hash;
	c->hash = 0;
	sync_cache(c);
	/* Destroy the tree */
	chash_destroy(h);
	
	struct llistnode *curnode, *next;
	struct ce_t *obj;
	ll_for_each_entry_safe(&c->primary_ll, curnode, next, struct ce_t *, obj)
	{
		ll_maybe_reset_loop(&c->primary_ll, curnode, next);
		remove_element(c, obj, 1);
	}
	ll_destroy(&c->dirty_ll);
	ll_destroy(&c->primary_ll);
	ll_remove_entry(cache_list, c);
	rwlock_release(c->rwl, RWL_WRITER);
	rwlock_destroy(c->rwl);
	printk(1, "[cache]: Cache '%s' destroyed\n", c->name);
	return 1;
}
Ejemplo n.º 2
0
/**
 * remove a specific pointer
 */
void pl_remove_pointer(pointer_list_t *pl, const void *data)
{
  pointer_list_entry_t *e;

  e = (pointer_list_entry_t *) ll_view_head(pl);
  while (e && (e->data != data))
    e = (pointer_list_entry_t *) e->e.p.next;
  if (e)
    ll_remove_entry(pl, (linked_list_entry_t *)e);
}
Ejemplo n.º 3
0
void release_fsvol(ext2_fs_t *fs)
{
	if(!fs) return;
	ll_remove_entry(fslist, fs);
	kfree(fs->sb);
	fs->m_node->pid=-1;
	fs->m_block->pid=-1;
	mutex_destroy(fs->m_node);
	mutex_destroy(fs->m_block);
	mutex_destroy(&fs->ac_lock);
	mutex_destroy(&fs->bg_lock);
	mutex_destroy(&fs->fs_lock);
	destroy_cache(fs->cache);
	kfree(fs);
}
Ejemplo n.º 4
0
// remove the timer associated with the thread
inline static void sleepq_remove_thread(thread_t *t)
{
  linked_list_entry_t *e;

  assert(t->sleep >= 0);  // the thread must be in the sleep queue
  sleepq_sanity_check();
  
  // let's find the thread in the queue
  e = ll_view_head(sleepq);
  while (e) {
    thread_t *tt = (thread_t *)pl_get_pointer(e);
    if (tt == t) {
      linked_list_entry_t *nexte = ll_view_next(sleepq, e);
      if (nexte) {
	// e is not the last thread in the queue
	// we need to lengthen the time the next thread will sleep
	thread_t *nextt = (thread_t *)pl_get_pointer(nexte);
	nextt->sleep += t->sleep;
      } else {
	// e is the last thread, so we need to adjust max_sleep_time
	max_sleep_time -= t->sleep;
      }
      // remove t
      ll_remove_entry(sleepq, e);
      ll_free_entry(sleepq, e);
      t->sleep = -1;
      assert (!t->timeout);    // if this fails, someone must has 
                               // forgot to reset timeout some time ago
      break;
    }
    e = ll_view_next(sleepq, e);
  }

  assert( t->sleep == -1);
  assert (e != NULL);   // we must find t in sleep queue
  sleepq_sanity_check();
}