コード例 #1
0
static void tasklet_hi_action(struct softirq_action *a)
{
	struct tasklet_struct *list;

	ddekit_lock_lock(&tasklet_hi_vec.lock);
	list = tasklet_hi_vec.list;
	tasklet_hi_vec.list = NULL;
	ddekit_lock_unlock(&tasklet_hi_vec.lock);

	while (list) {	
		struct tasklet_struct *t = list;

		list = list->next;

		if (tasklet_trylock(t)) {
			if (!atomic_read(&t->count)) {
				if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
					BUG();
				t->func(t->data);
				tasklet_unlock(t);
				continue;
			}
			tasklet_unlock(t);
		}

		ddekit_lock_lock(&tasklet_hi_vec.lock);
		t->next = tasklet_hi_vec.list;
		tasklet_hi_vec.list = t;
		raise_softirq_irqoff_cpu(HI_SOFTIRQ, 0);
		ddekit_lock_unlock(&tasklet_hi_vec.lock);
	}
}
コード例 #2
0
ファイル: dad_disk.c プロジェクト: RajasekharBhumi/L4Re
static void do_buffered_announcements(void) {
	dad_disk_t *dsk;

	buffer_announcements = 0;
	ddekit_lock_lock(&ann_buf_lock);
	while ((dsk=ann_buffer)) {
		ann_buffer = ann_buffer->next;
		ddekit_lock_unlock(&ann_buf_lock);
		if (dbg_this)
			ddekit_printf("announcing %s (%d sects with %d Bytes)\n", dsk->name, dsk->sects, dsk->sectsize);
		disk_announce(dsk);
		ddekit_lock_lock(&ann_buf_lock);
	}
	ddekit_lock_unlock(&ann_buf_lock);
}
コード例 #3
0
/* enqueue tasklet */
static void __tasklet_enqueue(struct tasklet_struct *t, 
                              struct tasklet_head *listhead)
{
	ddekit_lock_lock(&listhead->lock);
	t->next = listhead->list;
	listhead->list = t;
	ddekit_lock_unlock(&listhead->lock);
}
コード例 #4
0
/**
 * kmem_cache_free - Deallocate an object
 * @cachep: The cache the allocation was from.
 * @objp: The previously allocated object.
 *
 * Free an object which was previously allocated from this
 * cache.
 */
void kmem_cache_free(struct kmem_cache *cache, void *objp)
{
	ddekit_log(DEBUG_SLAB_ALLOC, "\"%s\" (%p)", cache->name, objp);

	ddekit_lock_lock(&cache->cache_lock);
	ddekit_slab_free(cache->ddekit_slab_cache, objp);
	ddekit_lock_unlock(&cache->cache_lock);
}
コード例 #5
0
struct task_struct *find_task_by_pid_type(int type, int nr)
{
	struct list_head *h, *p;
	h = &_pid_task_list;

	ddekit_lock_lock(&_pid_task_list_lock);
	list_for_each(p, h) {
		struct pid2task *pt = list_entry(p, struct pid2task, list);
		if (pid_nr(pt->pid) == nr) {
			ddekit_lock_unlock(&_pid_task_list_lock);
			return pt->ts;
		}
	}
	ddekit_lock_unlock(&_pid_task_list_lock);

	return NULL;
}
コード例 #6
0
/** Attach PID to a certain task struct. */
void attach_pid(struct task_struct *task, enum pid_type type
                __attribute__((unused)), struct pid *pid)
{
	/* Initialize a new pid2task mapping */
	struct pid2task *pt = kmalloc(sizeof(struct pid2task), GFP_KERNEL);
	pt->pid = get_pid(pid);
	pt->ts = task;

	/* add to list */
	ddekit_lock_lock(&_pid_task_list_lock);
	list_add(&pt->list, &_pid_task_list);
	ddekit_lock_unlock(&_pid_task_list_lock);
}
コード例 #7
0
/**
 * kmem_cache_alloc - Allocate an object
 * @cachep: The cache to allocate from.
 * @flags: See kmalloc().
 *
 * Allocate an object from this cache.  The flags are only relevant
 * if the cache has no available objects.
 */
void *kmem_cache_alloc(struct kmem_cache *cache, gfp_t flags)
{
	void *ret;


	ddekit_lock_lock(&cache->cache_lock);
	ret = ddekit_slab_alloc(cache->ddekit_slab_cache);
	ddekit_lock_unlock(&cache->cache_lock);

	// XXX: is it valid to run ctor AND memset to zero?
	if (flags & __GFP_ZERO)
		memset(ret, 0, cache->size);
	else if (cache->ctor)
		cache->ctor(ret);

	ddekit_log(DEBUG_SLAB_ALLOC, "\"%s\" flags=%x (%p, %d)", cache->name, flags, ret, cache->size);

	return ret;
}
コード例 #8
0
/** Detach PID from a task struct. */
void detach_pid(struct task_struct *task, enum pid_type type __attribute__((unused)))
{
	struct list_head *p, *n, *h;

	h = &_pid_task_list;
	
	ddekit_lock_lock(&_pid_task_list_lock);
	/* search for mapping with given task struct and free it if necessary */
	list_for_each_safe(p, n, h) {
		struct pid2task *pt = list_entry(p, struct pid2task, list);
		if (pt->ts == task) {
			put_pid(pt->pid);
			list_del(p);
			kfree(pt);
			break;
		}
	}
	ddekit_lock_unlock(&_pid_task_list_lock);
}
コード例 #9
0
ファイル: dad_disk.c プロジェクト: RajasekharBhumi/L4Re
void dad_announce_disk(dad_disk_t *dsk) {
	ddekit_lock_lock(&ann_buf_lock);
	if (buffer_announcements) {
		if (dbg_this)
			ddekit_printf("buffering announcement of %s (%d sects with %d Bytes)\n", dsk->name, dsk->sects, dsk->sectsize);
		dsk->next = NULL;
		if (! ann_buffer)
			ann_buffer = dsk;
		else {
			dad_disk_t *d = ann_buffer;
			while (d->next) d=d->next;
			d->next = dsk;
		}
	} else {
		if (disk_announce) {
			if (dbg_this)
				ddekit_printf("announcing %s (%d sects with %d Bytes)\n", dsk->name, dsk->sects, dsk->sectsize);
			disk_announce(dsk);
		} else
			ddekit_panic("disk found, but no announcing function set yet");
	}
	ddekit_lock_unlock(&ann_buf_lock);
}
コード例 #10
0
/** Entry point for new kernel threads. Make this thread a DDE26
 *  worker and then execute the real thread fn.
 */
static void __kthread_helper(void *arg)
{
	struct __kthread_data *k = (struct __kthread_data *)arg;

	/*
	 * Make a copy of the fn and arg pointers, as the kthread struct is
	 * deleted by our parent after notifying it and this may happen before we
	 * get to execute the function.
	 */
	int (*_fn)(void*)   = k->fn;
	void *_arg          = k->arg;

	l4dde26_process_add_worker();

	/*
	 * Handshake with creator - we store our thread data in the
	 * kthread struct and then unlock the lock to notify our
	 * creator about completing setup
	 */
	k->kthread = (dde26_thread_data *)ddekit_thread_get_my_data();
	ddekit_lock_unlock(&k->lock);
	
	do_exit(_fn(_arg));
}
コード例 #11
0
ファイル: timer.c プロジェクト: AgamAgarwal/minix
/*****************************************************************************
 *    unlock_timer                                                           *
 ****************************************************************************/
static void unlock_timer() 
{
	ddekit_lock_unlock(&lock);
}