Exemplo n.º 1
0
void send_at_command_sci1(char* str){
  long i;
  status = 'c';
  for (i = 0; str[i] != '\0'; i++) outchar1(str[i]);
  outchar1('\n');

  at_timeout = 10 * 100; // set at_timeout to ~10 sec  
  while(at_timeout){
    while(qempty() && at_timeout);
    c = getq();
    if (c == 'O'){
      while(qempty() && at_timeout);
      c = getq();
      if (c == 'K')
        break;
      else
        continue;
    }
  }
  
  
  // XXX: maybe clearing out nXXXXXXXXXX? 
  //empty_queue(); // clear the queue of any part of the message we may have ignored.
  
  if (at_timeout)
    status = 'i';
  else{
    status = 'e';
    set_lcd_addr(0);
    type_lcd("writing timed");
    set_lcd_addr(0x40);
    type_lcd("out.");
  }
}
Exemplo n.º 2
0
Arquivo: select.c Projeto: ArcEye/RTAI
static void xnselector_destroy_loop(void *cookie)
{
	struct xnselector *selector;
	xnholder_t *holder;
	int resched;
	spl_t s;

	xnlock_get_irqsave(&nklock, s);
	while ((holder = getq(&xnselectors))) {
		selector = container_of(holder, struct xnselector, destroy_link);
		while ((holder = getq(&selector->bindings))) {
			struct xnselect_binding *binding;
			struct xnselect *fd;

			binding = link2binding(holder, slink);
			fd = binding->fd;
			removeq(&fd->bindings, &binding->link);
			xnlock_put_irqrestore(&nklock, s);

			xnfree(binding);

			xnlock_get_irqsave(&nklock, s);
		}
		resched =
			xnsynch_destroy(&selector->synchbase) == XNSYNCH_RESCHED;
		xnlock_put_irqrestore(&nklock, s);

		xnfree(selector);
		if (resched)
			xnpod_schedule();

		xnlock_get_irqsave(&nklock, s);
	}
	xnlock_put_irqrestore(&nklock, s);
}
Exemplo n.º 3
0
static void size_conv_process(MSFilter *f){
	SizeConvState *s=(SizeConvState*)f->data;
	YuvBuf inbuf;
	mblk_t *im;
	int cur_frame;

	ms_filter_lock(f);

	if (s->frame_count==-1){
		s->start_time=(float)f->ticker->time;
		s->frame_count=0;
	}
	while((im=ms_queue_get(f->inputs[0]))!=NULL ){
		putq(&s->rq, im);
	}

	cur_frame=(int)((f->ticker->time-s->start_time)*s->fps/1000.0);
	if (cur_frame<=s->frame_count && s->fps>=0) {
		/* too much frame */
		while(s->rq.q_mcount>1){
			ms_message("MSSizeConv: extra frame removed.");
			im=getq(&s->rq);
			freemsg(im);
		}
		ms_filter_unlock(f);
		return;
	}

	if (cur_frame>s->frame_count && s->fps>=0) {
		/*keep the most recent frame if several frames have been captured */
		while(s->rq.q_mcount>1){
			ms_message("MSSizeConv: extra frame removed.");
			im=getq(&s->rq);
			freemsg(im);
		}
	}
	while((im=getq(&s->rq))!=NULL ){
		if (ms_yuv_buf_init_from_mblk(&inbuf,im)==0){
			if (inbuf.w==s->target_vsize.width &&
				inbuf.h==s->target_vsize.height){
				ms_queue_put(f->outputs[0],im);
			}else{
				struct ms_SwsContext *sws_ctx=get_resampler(s,inbuf.w,inbuf.h);
				mblk_t *om=size_conv_alloc_mblk(s);
				if (ms_sws_scale(sws_ctx,inbuf.planes,inbuf.strides, 0,
					inbuf.h, s->outbuf.planes, s->outbuf.strides)<0){
					ms_error("MSSizeConv: error in ms_sws_scale().");
				}
				ms_queue_put(f->outputs[0],om);
				freemsg(im);
			}
			s->frame_count++;
		}else freemsg(im);
	}

	ms_filter_unlock(f);
}
Exemplo n.º 4
0
static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *input){
	OrtpNetworkSimulatorCtx *sim=session->net_sim_ctx;
	struct timeval current;
	int64_t elapsed;
	int bits;
	int budget_increase;
	mblk_t *output=NULL;
	int overhead=(session->rtp.gs.sockfamily==AF_INET6) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;

	ortp_gettimeofday(&current,NULL);

	if (sim->last_check.tv_sec==0){
		sim->last_check=current;
		sim->bit_budget=0;
	}
	/*update the budget */
	elapsed=elapsed_us(&sim->last_check,&current);
	budget_increase=(elapsed*(int64_t)sim->params.max_bandwidth)/1000000LL;
	sim->bit_budget+=budget_increase;
	sim->bit_budget+=simulate_jitter_by_bit_budget_reduction(sim,budget_increase);
	sim->last_check=current;
	/* queue the packet for sending*/
	if (input){
		putq(&sim->q,input);
		bits=(msgdsize(input)+overhead)*8;
		sim->qsize+=bits;
	}
	/*flow control*/
	while (sim->qsize>=sim->params.max_buffer_size){
		// ortp_message("rtp_session_network_simulate(): discarding packets.");
		output=getq(&sim->q);
		if (output){
			bits=(msgdsize(output)+overhead)*8;
			sim->qsize-=bits;
			sim->drop_by_congestion++;
			freemsg(output);
		}
	}

	output=NULL;

	/*see if we can output a packet*/
	if (sim->bit_budget>=0){
		output=getq(&sim->q);
		if (output){
			bits=(msgdsize(output)+overhead)*8;
			sim->bit_budget-=bits;
			sim->qsize-=bits;
		}
	}
	if (output==NULL && input==NULL && sim->bit_budget>=0){
		/* unused budget is lost...*/
		sim->last_check.tv_sec=0;
	}
	return output;
}
Exemplo n.º 5
0
/*
 * dm2s_rsrv - Streams read side service procedure.
 *
 * All messages are received in the service procedure
 * only. This is done to simplify the streams synchronization.
 */
int
dm2s_rsrv(queue_t *rq)
{
	mblk_t *mp;
	dm2s_t *dm2sp = (dm2s_t *)rq->q_ptr;

	DPRINTF(DBG_DRV, ("dm2s_rsrv: called\n"));
	ASSERT(dm2sp != NULL);
	mutex_enter(&dm2sp->ms_lock);

	/* Receive if there are any messages waiting in the mailbox. */
	dm2s_receive(dm2sp);
	mutex_exit(&dm2sp->ms_lock);

	/* Send the received messages up the stream. */
	while ((mp = getq(rq)) != NULL) {
		if (canputnext(rq)) {
			putnext(rq, mp);
		} else {
			putbq(rq, mp);
			break;
		}
	}
	DPRINTF(DBG_DRV, ("dm2s_rsrv: return\n"));
	return (0);
}
Exemplo n.º 6
0
int Processer::svc(void)
{
	char ch[SIZE] = { };
	while(loop)
	{
		try
		{
			msg_ = 0;
			getq(msg_);

			//change to mongo::BSONObj
			//handle it
			if(msg_)
			{
				memset(ch,0,SIZE);
				memcpy(ch,msg_->rd_ptr(),SIZE);
				if(!(*ch))
					throw "EMPTY BSONOBJ";
				mongo::BSONObj bson(ch);
				std::cout << bson << std::endl;

				Handle(bson);

				delete [] msg_->rd_ptr();
				msg_ ->release();
			}
		}
		catch(const char* ch)
		{
			LOG4CXX_ERROR(log_,ch);
		}
	}

	return 0;
}
Exemplo n.º 7
0
Arquivo: select.c Projeto: ArcEye/RTAI
/**
 * Destroy the @a xnselect structure associated with a file descriptor.
 *
 * Any binding with a @a xnselector block is destroyed.
 *
 * @param select_block pointer to the @a xnselect structure associated with a file descriptor
 */
void xnselect_destroy(struct xnselect *select_block)
{
	xnholder_t *holder;
	int resched = 0;
	spl_t s;

	xnlock_get_irqsave(&nklock, s);
	while ((holder = getq(&select_block->bindings))) {
		struct xnselect_binding *binding;
		struct xnselector *selector;

		binding = link2binding(holder, link);
		selector = binding->selector;

		__FD_CLR__(binding->bit_index,
			 &selector->fds[binding->type].expected);
		if (!__FD_ISSET__(binding->bit_index,
				&selector->fds[binding->type].pending)) {
			__FD_SET__(binding->bit_index,
				 &selector->fds[binding->type].pending);
			if (xnselect_wakeup(selector))
				resched = 1;
		}
		removeq(&selector->bindings, &binding->slink);
		xnlock_put_irqrestore(&nklock, s);

		xnfree(binding);

		xnlock_get_irqsave(&nklock, s);
	}
	if (resched)
		xnpod_schedule();
	xnlock_put_irqrestore(&nklock, s);
}
Exemplo n.º 8
0
static bool_t queue_packet(queue_t *q, int maxrqsz, mblk_t *mp, rtp_header_t *rtp, int *discarded, int *duplicate)
{
	mblk_t *tmp;
	int header_size;
	*discarded=0;
	*duplicate=0;
	header_size=RTP_FIXED_HEADER_SIZE+ (4*rtp->cc);
	if ((mp->b_wptr - mp->b_rptr)==header_size){
		ortp_debug("Rtp packet contains no data.");
		(*discarded)++;
		freemsg(mp);
		return FALSE;
	}

	/* and then add the packet to the queue */
	if (rtp_putq(q,mp) < 0) {
		/* It was a duplicate packet */
		(*duplicate)++;
	}

	/* make some checks: q size must not exceed RtpStream::max_rq_size */
	while (q->q_mcount > maxrqsz)
	{
		/* remove the oldest mblk_t */
		tmp=getq(q);
		if (mp!=NULL)
		{
			ortp_warning("rtp_putq: Queue is full. Discarding message with ts=%u",((rtp_header_t*)mp->b_rptr)->timestamp);
			freemsg(tmp);
			(*discarded)++;
		}
	}
	return TRUE;
}
Exemplo n.º 9
0
/**
        \brief Called from ACEReactor when there are events in our queue()
*/
int AuthLink::handle_output( ACE_HANDLE /*= ACE_INVALID_HANDLE*/ )
{
    SEGSEvent *ev;
    ACE_Time_Value nowait (ACE_OS::gettimeofday ());
    while (-1 != getq(ev, &nowait))
    {
        if(ev->type()==SEGS_EventTypes::evFinish)
        {
            ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("(%P|%t) Error sent, closing connection\n")));
            return -1;
        }
        if(ev->type()==evContinue) // we have asked ourselves to send leftovers
        {
            assert(m_unsent_bytes_storage.GetReadableDataSize() > 0); // be sure we have some
        }
        else
        {
            size_t start_offset=m_unsent_bytes_storage.GetReadableDataSize();
            encode_buffer(static_cast<AuthLinkEvent *>(ev),start_offset);
        }
        if(!send_buffer()) // trying to send the contents of the buffer
        {
            ev->release(); // we have failed somehow
            break;
        }
        ev->release();
    }
    if (msg_queue()->is_empty ()) // we don't want to be woken up
        reactor()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK);
    else // unless there is something to send still
        reactor()->schedule_wakeup(this, ACE_Event_Handler::WRITE_MASK);
    return 0;
}
Exemplo n.º 10
0
int net32_get_msgqueue(point_info *p)
// ----------------------------------------------------------------------------
// DATA GET NET32_MESSAGE_QUEUE
// Description : net32_message_queue에서 data를 꺼내온다.
// Arguments   : p					Is a point-value pointer.
// Returns     : n_ret				Is a queue status type.
{
	int n_ret;
	STATUS_QUEUE_T *p_net32msg_q = (STATUS_QUEUE_T *) &gp_status->st_net32msg;

	memset( p, 0, sizeof(point_info) );

	pthread_mutex_lock( &net32MessageQ_mutex );
	n_ret = getq( &net32_message_queue, p );

	// status change
	if ( n_ret == QUEUE_FULL ) {
		p_net32msg_q->n_full++;
	}
	else if ( n_ret == QUEUE_EMPTY ) {
		p_net32msg_q->n_empty++;
	}
	else if ( n_ret == SUCCESS ) {
		p_net32msg_q->n_outdata++;
	}

	pthread_mutex_unlock( &net32MessageQ_mutex );
	
	return n_ret;
}
Exemplo n.º 11
0
static void v4l_process(MSFilter * obj){
	V4lState *s=(V4lState*)obj->data;
	uint32_t timestamp;
	int cur_frame;
	if (s->frame_count==-1){
		s->start_time=obj->ticker->time;
		s->frame_count=0;
	}
	cur_frame=((obj->ticker->time-s->start_time)*s->fps/1000.0);
	if (cur_frame>=s->frame_count){
		mblk_t *om=NULL;
		ms_mutex_lock(&s->mutex);
		/*keep the most recent frame if several frames have been captured */
		if (s->fd!=-1){
			om=getq(&s->rq);
		}else{
			if (s->usemire){
				om=dupmsg(v4l_make_mire(s));
			}else {
				mblk_t *tmpm=v4l_make_nowebcam(s);
				if (tmpm) om=dupmsg(tmpm);
			}
		}
		ms_mutex_unlock(&s->mutex);
		if (om!=NULL){
			timestamp=obj->ticker->time*90;/* rtp uses a 90000 Hz clockrate for video*/
			mblk_set_timestamp_info(om,timestamp);
			mblk_set_marker_info(om,TRUE);
			ms_queue_put(obj->outputs[0],om);
			/*ms_message("picture sent");*/
			s->frame_count++;
		}
	}else flushq(&s->rq,0);
}
Exemplo n.º 12
0
static mblk_t *ca_get(CAData *d){
	mblk_t *m;
	ms_mutex_lock(&d->mutex);
	m=getq(&d->rq);
	ms_mutex_unlock(&d->mutex);
	return m;
}
Exemplo n.º 13
0
int Sub_Thread::handle_input(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */)
{
     printf("Sub_Thread::handle_input  thread_id[%d]\n", GetCurrentThreadId() );

     while(1) 
     {
         //if (msg_queue_.is_empty()) 
         //{
         //    break;
         //}
         ACE_Message_Block* message = NULL;
         
         if (getq(message, NULL) == -1) 
         {
             ACE_DEBUG((LM_ERROR, "%T (%t)getq(message,NULL) == -1\n"));
             return 0;
         }      

         //分发数据包
         this->collect_msg(message);

         ACE_Message_Block::release(message);
         message = NULL;
     }
     return 0;
}
Exemplo n.º 14
0
void split_and_queue(queue_t *q, int maxrqsz, mblk_t *mp, rtp_header_t *rtp, int *discarded)
{
	mblk_t *mdata,*tmp;
	int header_size;
	*discarded=0;
	header_size=RTP_FIXED_HEADER_SIZE+ (4*rtp->cc);
	if ((mp->b_wptr - mp->b_rptr)==header_size){
		ortp_debug("Rtp packet contains no data.");
		(*discarded)++;
		freemsg(mp);
		return;
	}
	/* creates a new mblk_t to be linked with the rtp header*/
	mdata=dupb(mp);
	
	mp->b_wptr=mp->b_rptr+header_size;
	mdata->b_rptr+=header_size;
	/* link proto with data */
	mp->b_cont=mdata;
	/* and then add the packet to the queue */
	
	rtp_putq(q,mp);
	/* make some checks: q size must not exceed RtpStream::max_rq_size */
	while (q->q_mcount > maxrqsz)
	{
		/* remove the oldest mblk_t */
		tmp=getq(q);
		if (mp!=NULL)
		{
			ortp_debug("rtp_putq: Queue is full. Discarding message with ts=%i",((rtp_header_t*)mp->b_rptr)->timestamp);
			freemsg(tmp);
			(*discarded)++;
		}
	}
}
Exemplo n.º 15
0
static mblk_t * simulate_latency(RtpSession *session, mblk_t *input){
	OrtpNetworkSimulatorCtx *sim=session->net_sim_ctx;
	struct timeval current;
	mblk_t *output=NULL;
	uint32_t current_ts;
	ortp_gettimeofday(&current,NULL);
	/*since we must store expiration date in reserved2(32bits) only(reserved1
	already used), we need to reduce time stamp to milliseconds only*/
	current_ts = 1000*current.tv_sec + current.tv_usec/1000;

	/*queue the packet - store expiration timestamps in reserved fields*/
	if (input){
		input->reserved2 = current_ts + sim->params.latency;
		putq(&sim->latency_q,input);
	}

	if ((output=peekq(&sim->latency_q))!=NULL){
		if (TIME_IS_NEWER_THAN(current_ts, output->reserved2)){
			output->reserved2=0;
			getq(&sim->latency_q);
			/*return the first dequeued packet*/
			return output;
		}
	}

	return NULL;
}
Exemplo n.º 16
0
void xntslave_adjust(xntslave_t *slave, xnsticks_t delta)
{
	int nr_cpus, cpu, n;
	xnqueue_t adjq;

	initq(&adjq);
	for (cpu = 0, nr_cpus = xnarch_num_online_cpus(); cpu < nr_cpus; cpu++) {
		struct percpu_cascade *pc = &slave->cascade[cpu];
		xnholder_t *adjholder;

		for (n = 0; n < XNTIMER_WHEELSIZE; n++) {
			xnqueue_t *q = &pc->wheel[n];
			xntlholder_t *holder;

			for (holder = xntlist_head(q); holder;
			     holder = xntlist_next(q, holder)) {
				xntimer_t *timer = plink2timer(holder);
				if (testbits(timer->status, XNTIMER_REALTIME)) {
					inith(&timer->adjlink);
					appendq(&adjq, &timer->adjlink);
				}
			}
		}

		while ((adjholder = getq(&adjq))) {
			xntimer_t *timer = adjlink2timer(adjholder);
			xntimer_dequeue_periodic(timer);
			xntimer_adjust_periodic(timer, delta);
		}
	}
}
Exemplo n.º 17
0
void
rfsim_timer()
{
   ip_addr     hop;
   struct ip * pip;
   PACKET      pkt;

   /* send al packets which have timed out */
   while(((PACKET)(simq.q_head))->nb_tstamp < cticks)
   {
      pkt = (PACKET)getq(&simq); /* get pkt to send */
      hop = pkt->fhost;          /* get hop from host field */
      pip = ip_head(pkt);        /* get real host address */
      pkt->fhost = pip->ip_dest; /* restore host field */
      simpkts++;

      /* see if it's time to drop a packet */
      if((lossrate) && 
         ((simpkts - simlastloss) > lossrate) && 
         ((cticks & deviation) == 1))
      {
         LOCK_NET_RESOURCE(FREEQ_RESID);
         pk_free(pkt);           /* drop instead of send */
         UNLOCK_NET_RESOURCE(FREEQ_RESID);
         simlastloss = simpkts;  /* reset drop timer */
         simdrops++;             /* count drops */
      }
      else
         ip2mac(pkt, hop);          /* send pkt to hardware */
   }
   return;
}
Exemplo n.º 18
0
void xntimer_adjust_all_aperiodic(xnsticks_t delta)
{
	unsigned cpu, nr_cpus;
	xnqueue_t adjq;

	initq(&adjq);
	delta = xnarch_ns_to_tsc(delta);
	for (cpu = 0, nr_cpus = xnarch_num_online_cpus(); cpu < nr_cpus; cpu++) {
		xnsched_t *sched = xnpod_sched_slot(cpu);
		xntimerq_t *q = &sched->timerqueue;
		xnholder_t *adjholder;
		xntimerh_t *holder;
		xntimerq_it_t it;

		for (holder = xntimerq_it_begin(q, &it); holder;
		     holder = xntimerq_it_next(q, &it, holder)) {
			xntimer_t *timer = aplink2timer(holder);
			if (testbits(timer->status, XNTIMER_REALTIME)) {
				inith(&timer->adjlink);
				appendq(&adjq, &timer->adjlink);
			}
		}

		while ((adjholder = getq(&adjq))) {
			xntimer_t *timer = adjlink2timer(adjholder);
			xntimer_dequeue_aperiodic(timer);
			xntimer_adjust_aperiodic(timer, delta);
		}

		if (sched != xnpod_current_sched())
			xntimer_next_remote_shot(sched);
		else
			xntimer_next_local_shot(sched);
	}
}
Exemplo n.º 19
0
static mblk_t *au_read_get(AURead *d) {
    mblk_t *m;
    ms_mutex_lock(&d->common.mutex);
    m=getq(&d->rq);
    ms_mutex_unlock(&d->common.mutex);
    return m;
}
Exemplo n.º 20
0
int
simquit(void * pio)
{
   PACKET   pkt;
   ip_addr  hop;
   struct ip * pip;
   
   if(simtimer)
   {
      in_timerkill(simtimer);
      simtimer = 0;
   }

   /* send all queued packets */
   while(simq.q_head)
   {
      pkt = (PACKET)getq(&simq); /* get pkt to send */
      hop = pkt->fhost;          /* get hop from host field */
      pip = ip_head(pkt);        /* get real host address */
      pkt->fhost = pip->ip_dest; /* restore host field */
      ip2mac(pkt, hop);          /* send pkt to hardware */
   }
   rfsim_routing = FALSE;
   ns_printf(pio, "rfsim stopped\n");
   return 0;
}
Exemplo n.º 21
0
static void vfw_process(MSFilter * obj){
	VfwState *s=(VfwState*)obj->data;
	mblk_t *m;
	uint32_t timestamp;
	int cur_frame;

	if (s->frame_count==-1){
		s->start_time=(float)obj->ticker->time;
		s->frame_count=0;
	}

	cur_frame=(int)((obj->ticker->time-s->start_time)*s->fps/1000.0);
	if (cur_frame>s->frame_count){
		mblk_t *om=NULL;
		/*keep the most recent frame if several frames have been captured */
		if (s->eng!=NULL){
			ms_mutex_lock(&s->mutex);
			while((m=getq(&s->rq))!=NULL){
				ms_mutex_unlock(&s->mutex);
				if (om!=NULL) freemsg(om);
				om=m;
				ms_mutex_lock(&s->mutex);
			}
			ms_mutex_unlock(&s->mutex);
		}
		if (om!=NULL){
			timestamp=(uint32_t)(obj->ticker->time*90);/* rtp uses a 90000 Hz clockrate for video*/
			mblk_set_timestamp_info(om,timestamp);
			ms_queue_put(obj->outputs[0],om);
		}
		s->frame_count++;
	}
}
Exemplo n.º 22
0
OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q){
	OrtpEvent *ev;
	ortp_mutex_lock(&q->mutex);
	ev=getq(&q->q);
	ortp_mutex_unlock(&q->mutex);
	return ev;
}
Exemplo n.º 23
0
static int
log_rsrv(queue_t *q)
{
	mblk_t *mp;
	char *msg, *msgid_start, *msgid_end;
	size_t idlen;

	while (canputnext(q) && (mp = getq(q)) != NULL) {
		if (log_msgid == 0) {
			/*
			 * Strip out the message ID.  If it's a kernel
			 * SL_CONSOLE message, replace msgid with "unix: ".
			 */
			msg = (char *)mp->b_cont->b_rptr;
			if ((msgid_start = strstr(msg, "[ID ")) != NULL &&
			    (msgid_end = strstr(msgid_start, "] ")) != NULL) {
				log_ctl_t *lc = (log_ctl_t *)mp->b_rptr;
				if ((lc->flags & SL_CONSOLE) &&
				    (lc->pri & LOG_FACMASK) == LOG_KERN)
					msgid_start = msg + snprintf(msg,
					    7, "unix: ");
				idlen = msgid_end + 2 - msgid_start;
				ovbcopy(msg, msg + idlen, msgid_start - msg);
				mp->b_cont->b_rptr += idlen;
			}
		}
		mp->b_band = 0;
		putnext(q, mp);
	}
	return (0);
}
Exemplo n.º 24
0
/* Must be called nklock locked, irq off. */
static void pse51_shm_destroy(pse51_shm_t * shm, int force)
{
	spl_t ignored;

	removeq(&pse51_shmq, &shm->link);
	xnlock_clear_irqon(&nklock);

	down(&shm->maplock);

	if (shm->addr) {
		xnheap_free(&shm->heapbase, shm->addr);

		xnheap_destroy_mapped(&shm->heapbase, NULL, NULL);

		shm->addr = NULL;
		shm->size = 0;
	}

	if (force) {
		xnholder_t *holder;

		while ((holder = getq(&shm->mappings))) {
			up(&shm->maplock);
			xnfree(link2map(holder));
			down(&shm->maplock);
		}
	}

	up(&shm->maplock);
	xnlock_get_irqsave(&nklock, ignored);
}
Exemplo n.º 25
0
static mblk_t *winsnd_get(MSSndCard *card){
	WinSndData *d=(WinSndData*)card->data;
	mblk_t *m;
	ms_mutex_lock(&d->mutex);
	m=getq(&d->rq);
	ms_mutex_unlock(&d->mutex);
	return m;
}
Exemplo n.º 26
0
static mblk_t *oss_get(MSSndCard *card){
	OssData *d=(OssData*)card->data;
	mblk_t *m;
	ms_mutex_lock(&d->mutex);
	m=getq(&d->rq);
	ms_mutex_unlock(&d->mutex);
	return m;
}
Exemplo n.º 27
0
static int
intcmp (const char *s1, const char *s2)
{
	intmax_t q1, q2;


	q1 = getq(s1);
	q2 = getq(s2);

	if (q1 > q2)
		return 1;

	if (q1 < q2)
		return -1;

	return 0;
}
Exemplo n.º 28
0
static void
q_drain(struct queue * qsrc, struct queue * qdest)
{
   while(qsrc->q_len)
   {
      putq(qdest, getq(qsrc));
   }
}
Exemplo n.º 29
0
static int __wind_wd_wait(struct task_struct *curr, struct pt_regs *regs)
{
	xnholder_t *holder;
	wind_rholder_t *rh;
	WIND_TCB *pTcb;
	wind_wd_t *wd;
	int err = 0;
	spl_t s;

	if (!__xn_access_ok
	    (curr, VERIFY_WRITE, __xn_reg_arg1(regs), sizeof(wd->wdt)))
		return -EFAULT;

	rh = wind_get_rholder();

	xnlock_get_irqsave(&nklock, s);

	pTcb = __wind_task_current(curr);

	if (xnthread_base_priority(&pTcb->threadbase) != XNCORE_IRQ_PRIO)
		/* Renice the waiter above all regular tasks if needed. */
		xnpod_renice_thread(&pTcb->threadbase, XNCORE_IRQ_PRIO);

	if (!emptyq_p(&rh->wdpending))
		goto pull_event;

	xnsynch_sleep_on(&rh->wdsynch, XN_INFINITE, XN_RELATIVE);

	if (xnthread_test_info(&pTcb->threadbase, XNBREAK)) {
		err = -EINTR;	/* Unblocked. */
		goto unlock_and_exit;
	}
	
	if (xnthread_test_info(&pTcb->threadbase, XNRMID)) {
		err = -EIDRM;	/* Watchdog deleted while pending. */
		goto unlock_and_exit;
	}

 pull_event:

	holder = getq(&rh->wdpending);

	if (holder) {
		wd = link2wind_wd(holder);
		/* We need the following to mark the watchdog as unqueued. */
		inith(holder);
		xnlock_put_irqrestore(&nklock, s);
		__xn_copy_to_user(curr, (void __user *)__xn_reg_arg1(regs),
				  &wd->wdt, sizeof(wd->wdt));
		return 0;
	}

 unlock_and_exit:

	xnlock_put_irqrestore(&nklock, s);

	return err;
}
Exemplo n.º 30
0
/* remove and free all messages in the q */
void flushq(queue_t *q, int how)
{
	mblk_t *mp;
	
	while ((mp=getq(q))!=NULL)
	{
		freemsg(mp);
	}
}