Esempio n. 1
0
File: usbd.c Progetto: Hooman3/minix
/*===========================================================================*
 *    usbd_start                                                             *
 *===========================================================================*/
static int
usbd_start(void)
{
	ddekit_thread_t * usbd_th;

	DEBUG_DUMP;

	/* Driver's "main loop" is within DDEKit server thread */
	usbd_th = ddekit_thread_create(usbd_server_thread, NULL, "ddekit_usb");

	/* After spawning, allow server thread to work */
	if (NULL != usbd_th) {

		/* Allow URB scheduling */
		if (usbd_init_scheduler()) {
			USB_MSG("Failed to start URB scheduler");
		} else {
			/* This will lock current thread until DDEKit exits */
			ddekit_minix_wait_exit();
		}

		/* Disallow URB scheduling */
		usbd_deinit_scheduler();

		/* Cleanup */
		ddekit_thread_terminate(usbd_th);

		return EXIT_SUCCESS;
	} else
		return EXIT_FAILURE;
}
Esempio n. 2
0
/** Our implementation of Linux' kernel_thread() function. Setup a new
 * thread running our __kthread_helper() function.
 */
int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
{
	ddekit_thread_t *t;
	char name[20];
	struct __kthread_data *kt = vmalloc(sizeof(struct __kthread_data));
	ddekit_lock_t lock;

	/* Initialize (and grab) handshake lock */
	ddekit_lock_init(&lock);
	ddekit_lock_lock(&lock);

    int threadnum = atomic_inc_return(&kthread_count);
	kt->fn        = fn;
	kt->arg       = arg;
	kt->lock      = lock; // Copy lock ptr, note that kt is freed by the
	                      // new thread, so we MUST NOT use kt->lock after
	                      // this point!

	snprintf(name, 20, ".kthread%x", threadnum);
	t = ddekit_thread_create(__kthread_helper,
	                         (void *)kt, name, 0);
	Assert(t);

	ddekit_lock_lock(&lock);
	ddekit_lock_deinit(&lock);

	return pid_nr(VPID_P(kt->kthread));
}
Esempio n. 3
0
PRIVATE void ddekit_dispatcher_thread_init()
{

	dispatch_th = ddekit_thread_create(dispatcher_thread, NULL, "dispatch");

	ddekit_thread_schedule();
}
Esempio n. 4
0
/*****************************************************************************
 *    ddekit_init_timers                                                     *
 ****************************************************************************/
void ddekit_init_timers(void)
{
	static int first_time=0;
	
	if (!first_time)
	{
		ddekit_lock_init(&lock);
		jiffies = get_current_clock();
		HZ = sys_hz(); 
		pending_timer_ints = ddekit_sem_init(0);	
		th = ddekit_thread_create(ddekit_timer_thread, 0, "timer");
		first_time=1;
		DDEBUG_MSG_INFO("DDEkit timer subsustem initialized");
	}
}
Esempio n. 5
0
/** Initialize softirq subsystem.
 *
 * Start NUM_SOFTIRQ_THREADS threads executing the \ref l4dde26_softirq_thread
 * function.
 */
void l4dde26_softirq_init(void)
{
	char name[20];

	dde_softirq_sem = ddekit_sem_init(0);

	set_softirq_pending(0);

	ddekit_lock_init_unlocked(&tasklet_vec.lock);
	ddekit_lock_init_unlocked(&tasklet_hi_vec.lock);

	snprintf(name, 20, ".softirqd");
	dde_softirq_thread = ddekit_thread_create(
	                           l4dde26_softirq_thread,
	                           NULL, name, 0);

	open_softirq(TASKLET_SOFTIRQ, tasklet_action);
	open_softirq(HI_SOFTIRQ, tasklet_hi_action);

	INITIALIZE_INITVAR(dde26_softirq);
}