예제 #1
0
파일: semtest.c 프로젝트: ArcEye/RTAI
void cleanup_module(void)
{
	rtdm_task_destroy(&stask1);
	rtdm_task_destroy(&stask2);
	rtdm_sem_destroy(&sem1);    
	rtdm_sem_destroy(&sem2);    
	stop_rt_timer();
}
예제 #2
0
void cleanup_timer_handler(void)
{
  rtdm_task_destroy(&tx_handler_task);
  rtdm_task_destroy(&rx_handler_task);

  rtdm_sem_destroy(&rx_sem);
  rtdm_sem_destroy(&tx_sem);
}
예제 #3
0
파일: socket.c 프로젝트: hiddeate2m/rtnet
/***
 *  rt_socket_cleanup - releases resources allocated for the socket
 */
int rt_socket_cleanup(struct rtdm_dev_context *sockctx)
{
    struct rtsocket *sock  = (struct rtsocket *)&sockctx->dev_private;
    int ret = 0;


    rtdm_sem_destroy(&sock->pending_sem);

    mutex_lock(&sock->pool_nrt_lock);

    set_bit(SKB_POOL_CLOSED, &sockctx->context_flags);

    if (sock->pool_size > 0) {
        sock->pool_size -= rtskb_pool_shrink(&sock->skb_pool, sock->pool_size);

        if (sock->pool_size > 0)
            ret = -EAGAIN;
        else
            rtskb_pool_release(&sock->skb_pool);
    }

    mutex_unlock(&sock->pool_nrt_lock);

    return ret;
}
예제 #4
0
void rtcan_dev_free (struct rtcan_device *dev)
{
    if (dev != NULL) {
        rtdm_sem_destroy(&dev->tx_sem);
        kfree(dev);
    }
}
예제 #5
0
static int rtdmtest_close(struct rtdm_dev_context *context,
			     rtdm_user_info_t *user_info)
{
	struct rtdmtest_context *ctx;

	ctx = (struct rtdmtest_context *)context->dev_private;
	printk("%s state=%#lx\n", __FUNCTION__, ctx->event.state);
	down(&ctx->nrt_mutex);
	rtdm_event_destroy(&ctx->event);
	rtdm_sem_destroy(&ctx->sem);
	rtdm_mutex_destroy(&ctx->mutex);
	up(&ctx->nrt_mutex);

	return 0;
}
예제 #6
0
static void __exit rtnetproxy_cleanup_module(void)
{

    /* Unregister the fallback at rtnet */
    rt_ip_register_fallback(0);

    /* free the rtai srq */
    rtdm_nrtsig_destroy(&rtnetproxy_signal);

    rtdm_task_destroy(&rtnetproxy_thread);
    rtdm_sem_destroy(&rtnetproxy_sem);

    /* Free the ringbuffers... */
    {
        struct sk_buff *del_skb;  /* standard skb */
        while ((del_skb = read_from_ringbuffer(&ring_skb_rtnet_kernel)) != 0)
        {
            dev_kfree_skb(del_skb);
        }
        while ((del_skb = read_from_ringbuffer(&ring_skb_kernel_rtnet)) != 0)
        {
            dev_kfree_skb(del_skb);
        }
    }
    {
        struct rtskb *del; /* rtnet skb */
        while ((del=read_from_ringbuffer(&ring_rtskb_kernel_rtnet))!=0)
        {
            kfree_rtskb(del); // Although this is kernel mode, freeing should work...
        }
        while ((del=read_from_ringbuffer(&ring_rtskb_rtnet_kernel))!=0)
        {
            kfree_rtskb(del); // Although this is kernel mode, freeing should work...
        }
    }

    /* Unregister the net device: */
    unregister_netdev(&dev_rtnetproxy);
    kfree(dev_rtnetproxy.priv);

    memset(&dev_rtnetproxy, 0, sizeof(dev_rtnetproxy));
    dev_rtnetproxy.init = rtnetproxy_init;

    rtskb_pool_release(&rtskb_pool);
}
예제 #7
0
파일: socket.c 프로젝트: rcn-ee/xenomai-3
/***
 *  rt_socket_cleanup - releases resources allocated for the socket
 */
void rt_socket_cleanup(struct rtdm_fd *fd)
{
    struct rtsocket *sock  = rtdm_fd_to_private(fd);


    rtdm_sem_destroy(&sock->pending_sem);

    mutex_lock(&sock->pool_nrt_lock);

    set_bit(SKB_POOL_CLOSED, &sock->flags);

    if (sock->pool_size > 0)
	rtskb_pool_release(&sock->skb_pool);

    mutex_unlock(&sock->pool_nrt_lock);

    module_put(sock->owner);
}
예제 #8
0
void rtcan_socket_cleanup(struct rtdm_fd *fd)
{
    struct rtcan_socket *sock = rtdm_fd_to_private(fd);
    struct tx_wait_queue *tx_waiting;
    rtdm_lockctx_t lock_ctx;
    int tx_list_empty;


    /* Wake up sleeping senders. This is re-entrant-safe. */
    do {
	cobalt_atomic_enter(lock_ctx);
	/* Is someone there? */
	if (list_empty(&sock->tx_wait_head))
		tx_list_empty = 1;
	else {
		tx_list_empty = 0;

		/* Get next entry pointing to a waiting task */
		tx_waiting = list_entry(sock->tx_wait_head.next,
					struct tx_wait_queue, tx_wait_list);

		/* Remove it from list */
		list_del(&tx_waiting->tx_wait_list);

		/* Wake task up (atomic section is left implicitly) */
		rtdm_task_unblock(tx_waiting->rt_task);
	}
	cobalt_atomic_leave(lock_ctx);
    } while (!tx_list_empty);

    rtdm_sem_destroy(&sock->recv_sem);

    rtdm_lock_get_irqsave(&rtcan_recv_list_lock, lock_ctx);
    if (sock->socket_list.next) {
	list_del(&sock->socket_list);
	sock->socket_list.next = NULL;
    }
    rtdm_lock_put_irqrestore(&rtcan_recv_list_lock, lock_ctx);
}
예제 #9
0
static int rtdmtest_ioctl(struct rtdm_dev_context *context,
			  rtdm_user_info_t *user_info,
			  unsigned int request,
			  void *arg)
{
	struct rtdmtest_context *ctx;
	struct rttst_rtdmtest_config config_buf, *config;
	rtdm_toseq_t toseq_local, *toseq = NULL;
	int i, err = 0;

	ctx = (struct rtdmtest_context *)context->dev_private;

	switch (request) {
	case RTTST_RTIOC_RTDMTEST_SEM_TIMEDDOWN:
	case RTTST_RTIOC_RTDMTEST_EVENT_TIMEDWAIT:
        case RTTST_RTIOC_RTDMTEST_MUTEX_TIMEDTEST:
        case RTTST_RTIOC_RTDMTEST_MUTEX_TEST:
		config = arg;
		if (user_info) {
			if (rtdm_safe_copy_from_user
			    (user_info, &config_buf, arg,
			     sizeof(struct rttst_rtdmtest_config)) < 0)
				return -EFAULT;

			config = &config_buf;
		}
		if (!config->seqcount)
			config->seqcount = 1;
		if (config->timeout && config->seqcount > 1) {
			toseq = &toseq_local;
			rtdm_toseq_init(toseq, config->timeout);
		}
		switch(request) {
		case RTTST_RTIOC_RTDMTEST_SEM_TIMEDDOWN:
			for (i = 0; i < config->seqcount; i++) {
				err = rtdm_sem_timeddown(&ctx->sem,
							 config->timeout,
							 toseq);
				if (err)
					break;
			}
			break;
		case RTTST_RTIOC_RTDMTEST_EVENT_TIMEDWAIT:
			for (i = 0; i < config->seqcount; i++) {
				err = rtdm_event_timedwait(&ctx->event,
							   config->timeout,
							   toseq);
				if (err)
					break;
			}
			break;
		case RTTST_RTIOC_RTDMTEST_MUTEX_TIMEDTEST:
			for (i = 0; i < config->seqcount; i++) {
				err = rtdm_mutex_timedlock(&ctx->mutex,
							   config->timeout,
							   toseq);
				if (err)
					break;
				if (config->delay_jiffies) {
					__set_current_state(TASK_INTERRUPTIBLE);
					schedule_timeout(config->delay_jiffies);
				}
				rtdm_lock_count++;
				rtdm_mutex_unlock(&ctx->mutex);
			}
			break;
		case RTTST_RTIOC_RTDMTEST_MUTEX_TEST:
			for (i = 0; i < config->seqcount; i++) {
				if ((err = rtdm_mutex_lock(&ctx->mutex)))
					break;
				rtdm_lock_count++;
				rtdm_mutex_unlock(&ctx->mutex);
			}
			break;
		}
		break;

	case RTTST_RTIOC_RTDMTEST_SEM_DOWN:
		err = rtdm_sem_down(&ctx->sem);
		break;

	case RTTST_RTIOC_RTDMTEST_SEM_UP:
		rtdm_sem_up(&ctx->sem);
		break;

        case RTTST_RTIOC_RTDMTEST_SEM_DESTROY:
                rtdm_sem_destroy(&ctx->sem);
                break;

	case RTTST_RTIOC_RTDMTEST_EVENT_WAIT:
		err = rtdm_event_wait(&ctx->event);
		break;

	case RTTST_RTIOC_RTDMTEST_EVENT_SIGNAL:
		rtdm_event_signal(&ctx->event);
		break;

        case RTTST_RTIOC_RTDMTEST_EVENT_DESTROY:
                rtdm_event_destroy(&ctx->event);
                break;

        case RTTST_RTIOC_RTDMTEST_MUTEX_DESTROY:
                rtdm_mutex_destroy(&ctx->mutex);
                break;

        case RTTST_RTIOC_RTDMTEST_MUTEX_GETSTAT:
		printk("RTTST_RTIOC_RTDMTEST_MUTEX_GETSTAT\n");
		if (user_info)
			config = &config_buf;
		else
			config = arg;
		config->seqcount = rtdm_lock_count;
		if (user_info) {
			if (rtdm_safe_copy_to_user
			    (user_info, arg, &config_buf,
			     sizeof(struct rttst_rtdmtest_config)) < 0)
				return -EFAULT;
		}
                break;

        case RTTST_RTIOC_RTDMTEST_NRTSIG_PEND:
		rtdm_nrtsig_pend(&ctx->nrtsig);
                break;

        case RTTST_RTIOC_RTDMTEST_TASK_CREATE:
        case RTTST_RTIOC_RTDMTEST_TASK_SET_PRIO:
                config = arg;
                if (user_info) {
                        if (rtdm_safe_copy_from_user
                            (user_info, &config_buf, arg,
                             sizeof(struct rttst_rtdmtest_config)) < 0)
                                return -EFAULT;

                        config = &config_buf;
                }
		if (request == RTTST_RTIOC_RTDMTEST_TASK_CREATE) {
			task_period = config->timeout;
			rtdm_task_init(&task, "RTDMTEST",
				       rtdmtest_task, (void *)config,
				       config->priority, 0);
		} else {
			rtdm_task_set_priority(&task, config->priority);
		}
		break;

        case RTTST_RTIOC_RTDMTEST_TASK_DESTROY:
		rtdm_task_destroy(&task);
		rtdm_task_join_nrt(&task, 100);
                break;

	default:
		printk("request=%d\n", request);
		err = -ENOTTY;
	}

	return err;
}