Exemple #1
0
static void xnsched_watchdog_handler(struct xntimer *timer)
{
	struct xnsched *sched = xnpod_current_sched();
	struct xnthread *thread = sched->curr;

	if (likely(xnthread_test_state(thread, XNROOT))) {
		xnsched_reset_watchdog(sched);
		return;
	}

	if (likely(++sched->wdcount < wd_timeout_arg))
		return;

#ifdef CONFIG_XENO_OPT_PERVASIVE
	if (xnthread_test_state(thread, XNSHADOW) &&
	    !xnthread_amok_p(thread)) {
		trace_mark(xn_nucleus, watchdog_signal,
			   "thread %p thread_name %s",
			   thread, xnthread_name(thread));
		xnprintf("watchdog triggered -- signaling runaway thread "
			 "'%s'\n", xnthread_name(thread));
		xnthread_set_info(thread, XNAMOK | XNKICKED);
		xnshadow_send_sig(thread, SIGDEBUG, SIGDEBUG_WATCHDOG, 1);
	} else
#endif /* CONFIG_XENO_OPT_PERVASIVE */
	{
		trace_mark(xn_nucleus, watchdog, "thread %p thread_name %s",
			   thread, xnthread_name(thread));
		xnprintf("watchdog triggered -- killing runaway thread '%s'\n",
			 xnthread_name(thread));
		xnpod_delete_thread(thread);
	}
	xnsched_reset_watchdog(sched);
}
Exemple #2
0
void pse51_semq_cleanup(pse51_kqueues_t *q)
{
	xnholder_t *holder;
	spl_t s;

	xnlock_get_irqsave(&nklock, s);

	while ((holder = getheadq(&q->semq)) != NULL) {
		pse51_sem_t *sem = link2sem(holder);
		pse51_node_t *node;
		xnlock_put_irqrestore(&nklock, s);
#if XENO_DEBUG(POSIX)
		if (sem->is_named)
			xnprintf("Posix: unlinking semaphore \"%s\".\n",
				 sem2named_sem(sem)->nodebase.name);
		else
			xnprintf("Posix: destroying semaphore %p.\n", sem);
#endif /* XENO_DEBUG(POSIX) */
		xnlock_get_irqsave(&nklock, s);
		if (sem->is_named)
			pse51_node_remove(&node,
					  sem2named_sem(sem)->nodebase.name,
					  PSE51_NAMED_SEM_MAGIC);
		xnlock_put_irqrestore(&nklock, s);
		sem_destroy_inner(sem, q);
		xnlock_get_irqsave(&nklock, s);
	}

	xnlock_put_irqrestore(&nklock, s);
}
Exemple #3
0
int root_thread_init (void)

{
    u_long err, args[4];

    err = q_create("CNSQ",16,Q_LIMIT|Q_FIFO,&message_qid);
    args[0] = message_qid;

    if (err != SUCCESS)
	{
	xnprintf("q_create() failed, errno %lu",err);
	return err;
	}

    err = t_create("CONS",
		   CONSUMER_TASK_PRI,
		   CONSUMER_SSTACK_SIZE,
		   CONSUMER_USTACK_SIZE,
		   0,
		   &consumer_tid);

    if (err != SUCCESS)
	{
	xnprintf("t_create() failed, errno %lu",err);
	return err;
	}

    err = t_start(consumer_tid,0,consumer_task,args);

    if (err != SUCCESS)
	{
	xnprintf("t_start() failed, errno %lu",err);
	return err;
	}

    err = t_create("PROD",
		   PRODUCER_TASK_PRI,
		   PRODUCER_SSTACK_SIZE,
		   PRODUCER_USTACK_SIZE,
		   0,
		   &producer_tid);

    if (err != SUCCESS)
	{
	xnprintf("t_create() failed, errno %lu",err);
	return err;
	}

    err = t_start(producer_tid,0,producer_task,args);

    if (err != SUCCESS)
	{
	xnprintf("t_start() failed, errno %lu",err);
	return err;
	}

    return 0;
}
Exemple #4
0
static void umap_cleanup(pse51_assoc_t *assoc)
{
	pse51_umap_t *umap = assoc2umap(assoc);
#if XENO_DEBUG(POSIX)
	xnprintf("Posix: unmapping shared memory 0x%08lx.\n",
		 pse51_assoc_key(assoc));
#endif /* XENO_DEBUG(POSIX) */
	munmap(umap->kaddr, umap->len);
	xnfree(umap);
}
Exemple #5
0
static void ufd_cleanup(pse51_assoc_t *assoc)
{
	pse51_ufd_t *ufd = assoc2ufd(assoc);
#if XENO_DEBUG(POSIX)
	xnprintf("Posix: closing shared memory descriptor %lu.\n",
		 pse51_assoc_key(assoc));
#endif /* XENO_DEBUG(POSIX) */
	pse51_shm_close(ufd->kfd);
	xnfree(ufd);
}
Exemple #6
0
static void usem_cleanup(pse51_assoc_t *assoc)
{
	struct pse51_sem *sem = (struct pse51_sem *) pse51_assoc_key(assoc);
	pse51_usem_t *usem = assoc2usem(assoc);
	nsem_t *nsem = sem2named_sem(sem);

#if XENO_DEBUG(POSIX)
	xnprintf("Posix: closing semaphore \"%s\".\n", nsem->nodebase.name);
#endif /* XENO_DEBUG(POSIX) */
	sem_close(&nsem->descriptor.native_sem);
	xnfree(usem);
}
Exemple #7
0
void SKIN_EXIT(vxworks)
{
	xnprintf("stopping VxWorks services.\n");
	wind_task_cleanup();
	wind_sysclk_cleanup();
	wind_msgq_cleanup();
	wind_sem_cleanup();
	wind_wd_cleanup();
	wind_task_hooks_cleanup();
#ifdef CONFIG_XENO_OPT_PERVASIVE
	wind_syscall_cleanup();
#endif /* CONFIG_XENO_OPT_PERVASIVE */
	xnpod_shutdown(XNPOD_NORMAL_EXIT);
}
Exemple #8
0
void SKIN_EXIT(uitron)
{
	xnprintf("stopping uITRON services.\n");
	uimbx_cleanup();
	uiflag_cleanup();
	uisem_cleanup();
	uitask_cleanup();

#ifdef CONFIG_XENO_OPT_PERVASIVE
	ui_syscall_cleanup();
#endif /* CONFIG_XENO_OPT_PERVASIVE */
	xntbase_free(ui_tbase);
	xnpod_shutdown(XNPOD_NORMAL_EXIT);
}
Exemple #9
0
void consumer_task (u_long a0, u_long a1, u_long a2, u_long a3)

{
    u_long err, qid = a0, msg[4];

    for (;;)
	{
	tm_wkafter(CONSUMER_WAIT);

	while ((err = q_receive(qid,Q_NOWAIT,0,msg)) == SUCCESS)
	    xnprintf("Now playing %s...\n",(const char *)msg[0]);

	if (err != ERR_NOMSG)
	    xnpod_fatal("q_receive() failed, errno %lu",err);
	}
}
Exemple #10
0
void SKIN_EXIT(psos)
{
	xnprintf("stopping pSOS+ services.\n");

	psostask_cleanup();
	psostm_cleanup();
	psosasr_cleanup();
	psospt_cleanup();
	psosqueue_cleanup();
	psossem_cleanup();
	psosrn_cleanup();
#ifdef CONFIG_XENO_OPT_PERVASIVE
	psos_syscall_cleanup();
#endif /* CONFIG_XENO_OPT_PERVASIVE */
	xntbase_free(psos_tbase);
	xnpod_shutdown(XNPOD_NORMAL_EXIT);
}
Exemple #11
0
int SKIN_INIT(psos)
{
	int err;

	initq(&__psos_global_rholder.smq);
	initq(&__psos_global_rholder.qq);
	initq(&__psos_global_rholder.ptq);
	initq(&__psos_global_rholder.rnq);

	err = xnpod_init();

	if (err != 0)
		return err;

	err = xntbase_alloc("psos", tick_arg * 1000, sync_time ? 0 : XNTBISO,
			    &psos_tbase);

	if (err != 0)
		goto fail;

	xntbase_start(psos_tbase);

	err = psosrn_init(module_param_value(rn0_size_arg));

	if (err != 0) {
	fail:
		xnpod_shutdown(err);
		xnlogerr("pSOS skin init failed, code %d.\n", err);
		return err;
	}

	psossem_init();
	psosqueue_init();
	psospt_init();
	psosasr_init();
	psostm_init();
	psostask_init(module_param_value(time_slice_arg));
#ifdef CONFIG_XENO_OPT_PERVASIVE
	psos_syscall_init();
#endif /* CONFIG_XENO_OPT_PERVASIVE */

	xnprintf("starting pSOS+ services.\n");

	return err;
}
Exemple #12
0
int SKIN_INIT(vxworks)
{
	int err;

	initq(&__wind_global_rholder.wdq);
	initq(&__wind_global_rholder.msgQq);
	initq(&__wind_global_rholder.semq);

	/* The following fields are unused in the global holder;
	   still, we initialize them not to leave such data in an
	   invalid state. */
	xnsynch_init(&__wind_global_rholder.wdsynch, XNSYNCH_FIFO, NULL);
	initq(&__wind_global_rholder.wdpending);
	__wind_global_rholder.wdcount = 0;

	err = xnpod_init();

	if (err != 0)
		goto fail_core;

	err = wind_sysclk_init(tick_arg * 1000);

	if (err != 0) {
		xnpod_shutdown(err);

	fail_core:
		xnlogerr("VxWorks skin init failed, code %d.\n", err);
		return err;
	}

	wind_wd_init();
	wind_task_hooks_init();
	wind_sem_init();
	wind_msgq_init();
	wind_task_init();
#ifdef CONFIG_XENO_OPT_PERVASIVE
	wind_syscall_init();
#endif /* CONFIG_XENO_OPT_PERVASIVE */

	xnprintf("starting VxWorks services.\n");

	return 0;
}
Exemple #13
0
void SKIN_EXIT(native)
{
	xnprintf("stopping native API services.\n");

	__native_intr_pkg_cleanup();
	__native_alarm_pkg_cleanup();
	__native_heap_pkg_cleanup();
	__native_queue_pkg_cleanup();
	__native_pipe_pkg_cleanup();
	__native_cond_pkg_cleanup();
	__native_mutex_pkg_cleanup();
	__native_event_pkg_cleanup();
	__native_sem_pkg_cleanup();
	__native_task_pkg_cleanup();
	__native_misc_pkg_cleanup();
	__native_syscall_cleanup();

	xntbase_free(__native_tbase);

	xnpod_shutdown(XNPOD_NORMAL_EXIT);
}
Exemple #14
0
void pse51_shm_pkg_cleanup(void)
{
	xnholder_t *holder;
	spl_t s;

	xnlock_get_irqsave(&nklock, s);

	while ((holder = getheadq(&pse51_shmq))) {
		pse51_shm_t *shm = link2shm(holder);
		pse51_node_t *node;

		pse51_node_remove(&node, shm->nodebase.name, PSE51_SHM_MAGIC);
		xnlock_put_irqrestore(&nklock, s);
#if XENO_DEBUG(POSIX)
		xnprintf("Posix: unlinking shared memory \"%s\".\n",
			 shm->nodebase.name);
#endif /* XENO_DEBUG(POSIX) */
		xnlock_get_irqsave(&nklock, s);
		pse51_shm_destroy(shm, 1);
	}

	xnlock_put_irqrestore(&nklock, s);
}
Exemple #15
0
int SKIN_INIT(native)
{
	int err;

	initq(&__native_global_rholder.alarmq);
	initq(&__native_global_rholder.condq);
	initq(&__native_global_rholder.eventq);
	initq(&__native_global_rholder.heapq);
	initq(&__native_global_rholder.intrq);
	initq(&__native_global_rholder.mutexq);
	initq(&__native_global_rholder.pipeq);
	initq(&__native_global_rholder.queueq);
	initq(&__native_global_rholder.semq);
	initq(&__native_global_rholder.ioregionq);
	initq(&__native_global_rholder.bufferq);

	err = xnpod_init();
	if (err)
		goto fail;

	err = xntbase_alloc("native", tick_arg * 1000, 0, &__native_tbase);

	if (err)
		goto fail;

	xntbase_start(__native_tbase);

	err = __native_misc_pkg_init();

	if (err)
		goto cleanup_pod;

	err = __native_task_pkg_init();

	if (err)
		goto cleanup_misc;

	err = __native_sem_pkg_init();

	if (err)
		goto cleanup_task;

	err = __native_event_pkg_init();

	if (err)
		goto cleanup_sem;

	err = __native_mutex_pkg_init();

	if (err)
		goto cleanup_event;

	err = __native_cond_pkg_init();

	if (err)
		goto cleanup_mutex;

	err = __native_pipe_pkg_init();

	if (err)
		goto cleanup_cond;

	err = __native_queue_pkg_init();

	if (err)
		goto cleanup_pipe;

	err = __native_heap_pkg_init();

	if (err)
		goto cleanup_queue;

	err = __native_alarm_pkg_init();

	if (err)
		goto cleanup_heap;

	err = __native_intr_pkg_init();

	if (err)
		goto cleanup_alarm;

	err = __native_syscall_init();

	if (err)
		goto cleanup_intr;

	xnprintf("starting native API services.\n");

	return 0;		/* SUCCESS. */

      cleanup_intr:

	__native_intr_pkg_cleanup();

      cleanup_alarm:

	__native_alarm_pkg_cleanup();

      cleanup_heap:

	__native_heap_pkg_cleanup();

      cleanup_queue:

	__native_queue_pkg_cleanup();

      cleanup_pipe:

	__native_pipe_pkg_cleanup();

      cleanup_cond:

	__native_cond_pkg_cleanup();

      cleanup_mutex:

	__native_mutex_pkg_cleanup();

      cleanup_event:

	__native_event_pkg_cleanup();

      cleanup_sem:

	__native_sem_pkg_cleanup();

      cleanup_task:

	__native_task_pkg_cleanup();

      cleanup_misc:

	__native_misc_pkg_cleanup();

      cleanup_pod:

	xntbase_free(__native_tbase);

	xnpod_shutdown(err);

      fail:

	xnlogerr("native skin init failed, code %d.\n", err);
	return err;
}
Exemple #16
0
int SKIN_INIT(uitron)
{
	int err;

	initq(&__ui_global_rholder.flgq);
	initq(&__ui_global_rholder.mbxq);
	initq(&__ui_global_rholder.semq);

	err = xnpod_init();

	if (err)
		goto fail;

	err = xntbase_alloc("uitron", tick_arg * 1000,
			    sync_time ? 0 : XNTBISO, &ui_tbase);

	if (err)
		goto cleanup_pod;

	xntbase_start(ui_tbase);

	err = uitask_init();

	if (err)
		goto cleanup_tbase;

	err = uisem_init();

	if (err)
		goto cleanup_task;

	err = uiflag_init();

	if (err)
		goto cleanup_sem;

	err = uimbx_init();

	if (err)
		goto cleanup_flag;

#ifdef CONFIG_XENO_OPT_PERVASIVE
	ui_syscall_init();
#endif /* CONFIG_XENO_OPT_PERVASIVE */

	xnprintf("starting uITRON services.\n");

	return 0;

cleanup_flag:

	uiflag_cleanup();

cleanup_sem:

	uisem_cleanup();

cleanup_task:

	uitask_cleanup();

cleanup_tbase:

	xntbase_free(ui_tbase);

cleanup_pod:

	xnpod_shutdown(err);

fail:

	xnlogerr("uITRON skin init failed, code %d.\n", err);

	return err;
}