当前位置: 首页>>代码示例>>C++>>正文


C++ rt_mutex_release函数代码示例

本文整理汇总了C++中rt_mutex_release函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_mutex_release函数的具体用法?C++ rt_mutex_release怎么用?C++ rt_mutex_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rt_mutex_release函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sensor_fusion

void sensor_fusion(void *arg)
{
	RTIME now;
	int i,sum, print,k, count;
        /*
         * Arguments: &task (NULL=self), start time, period 
         */
        rt_task_set_periodic(NULL, TM_NOW, 16666666);
	count =0;
	while (isRunning) {
		count++;
                rt_task_wait_period(NULL);
		rt_mutex_acquire(&mutex_acc,TM_INFINITE);
		rt_mutex_acquire(&mutex_gyro,TM_INFINITE);
		k=gyroIndex;
		sum=0; print = 0;
   		for (i=0; i<5; i++){
	 		sum = sum + gyro_sample[k];
			k--;
		}

		print = ((sum/5) + acc_sample)/2;

		rt_mutex_release(&mutex_gyro);
		rt_mutex_release(&mutex_acc);
		
		printlog[logIndex] = print;
		logIndex++;

		if(count == 50)
			isRunning = 0;
	}
}
开发者ID:AndrewDeCHamplain,项目名称:SYSC3303,代码行数:33,代码来源:partB.c

示例2: addPong

void addPong(){
    if (nPongs < MAX_PONGS){
        pongs[nPongs].leftCorner.point_x = ((resolution_w-resolution_x)/2 - (pongLength/2));
        pongs[nPongs].leftCorner.point_y = resolution_y;
        oppoentPointLocationX = ((resolution_w-resolution_x)/2 - (pongLength/2));

        rt_mutex_acquire(&txMutex[E_ADD], TM_INFINITE);
	memset(pongData[0], 0, sizeof(pongData[0]));
        sprintf(pongData[0], "pong;%d;",pongs[nPongs].leftCorner.point_x);
        sprintf(pongData[0] + strlen(pongData[0]), 
		"%d;%d;%d;", pongs[nPongs].leftCorner.point_y,pongLength,pongs[nPongs].height);
	padString(pongData[0]);
        rt_mutex_release(&txMutex[E_ADD]);
        
        pongs[nPongs].length = pongLength;
        nPongs++;
        pongs[nPongs].leftCorner.point_x =((resolution_w-resolution_x)/2 - (pongLength/2));
        pongs[nPongs].leftCorner.point_y = DEFAULT_HEIGHT;
        locationPointOfX = ((resolution_w-resolution_x)/2 - (pongLength/2)); 

	rt_mutex_acquire(&txMutex[E_ADD], TM_INFINITE);
	memset(pongData[1], 0, sizeof(pongData[1]));
        sprintf(pongData[1], "pong;%d;",pongs[nPongs].leftCorner.point_x);
        sprintf(pongData[1] + strlen(pongData[1]), 
		"%d;%d;%d;", pongs[nPongs].leftCorner.point_y,pongLength,pongs[nPongs].height);
	padString(pongData[1]);
	rt_mutex_release(&txMutex[E_ADD]);
        nPongs++;
    }
}
开发者ID:iasoule,项目名称:SYSC3303-Pong,代码行数:30,代码来源:Model.c

示例3: I2C_AcknowledgePolling

/*TODO: If your device need more time to initialize I2C bus or waiting memory write, you can use I2C_AcknowledgePolling avoid I2C bus lose.*/
Status I2C_AcknowledgePolling(I2C_TypeDef* I2Cx ,uint8_t Addr)
{
    uint32_t timeout = 0xFFFF, ret;
    uint16_t tmp;
	ret = rt_mutex_take(i2c_mux, RT_WAITING_FOREVER );
	
	if( ret == RT_EOK )
	{
	    do{
	        if( timeout-- <= 0 )
	        {
	            I2C_ClearFlag(I2Cx,I2C_FLAG_AF);
	            I2Cx->CR1 |= CR1_STOP_Set;
				rt_mutex_release(i2c_mux);
	            return Error;
	        }
	
	        I2Cx->CR1 |= CR1_START_Set;
	        tmp = I2Cx->SR1;//²M°£SB¦ì
	        I2Cx->DR = Addr;
	        
	    }while((I2Cx->SR1&0x0002) != 0x0002);
	  
	    I2C_ClearFlag(I2Cx,I2C_FLAG_AF);
	    I2Cx->CR1 |= CR1_STOP_Set;
	    while ((I2Cx->CR1&0x200) == 0x200);
		rt_kprintf( "AcknowledgePolling OK\n");
		rt_mutex_release(i2c_mux);
		return Success; 
	}
	else
		return Error;
} 
开发者ID:bright-pan,项目名称:smart-lock,代码行数:34,代码来源:i2c.c

示例4: thread1_entry

static void thread1_entry(void* parameter)
{
    rt_err_t result;

    
    result = rt_mutex_take(mutex, RT_WAITING_FOREVER);
    result = rt_mutex_take(mutex, RT_WAITING_FOREVER);
    rt_kprintf("thread1: got mutex\n");

    if (result != RT_EOK)
    {
        return;
    }
        
    for(t1_count = 0; t1_count < 5;t1_count ++)
    {
        rt_kprintf("thread1:count: %d\n", t1_count);
    }
    if (t2->current_priority != t1->current_priority)
    {
        rt_kprintf("thread1: released mutex\n");
        rt_mutex_release(mutex);
        rt_mutex_release(mutex);
    }
        
}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:26,代码来源:demo.c

示例5: dfs_jffs2_close

static int dfs_jffs2_close(struct dfs_fd* file)
{
	int result;
	cyg_file * jffs2_file;
	
	RT_ASSERT(file->data != NULL);
	jffs2_file = (cyg_file *)(file->data);
	
	if (file->flags & DFS_O_DIRECTORY) /* operations about dir */
	{
		rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
		result = jffs2_dir_colse(jffs2_file);
		rt_mutex_release(&jffs2_lock);
		if (result)
			return jffs2_result_to_dfs(result);	

		rt_free(jffs2_file);
		return 0;
	}
	/* regular file operations */
	rt_mutex_take(&jffs2_lock, RT_WAITING_FOREVER);
	result = jffs2_file_colse(jffs2_file);
	rt_mutex_release(&jffs2_lock);
	if (result)
		return jffs2_result_to_dfs(result);	
	
	/* release memory */
	rt_free(jffs2_file);
	return 0;
}
开发者ID:QiuGong,项目名称:Terminal,代码行数:30,代码来源:dfs_jffs2.c

示例6: computationTask

void computationTask(long arg)
{
	usleep(1);
	while(1){
		int i = 0;
		rt_mutex_acquire(&mutex_donnee,TM_INFINITE);	

		while(tabDonnePris==1){
			rt_mutex_release(&mutex_donnee);
			rt_sem_p(&sem_donnee,TM_INFINITE);
			rt_mutex_acquire(&mutex_donnee,TM_INFINITE);
		}
		tabDonnePris = 1;
		
		rt_mutex_acquire(&mutex_obs,TM_INFINITE);	
		while(tabObstaclePris==1){
		  rt_mutex_release(&mutex_obs);
		  rt_sem_p(&sem_obs,TM_INFINITE);
		  rt_mutex_acquire(&mutex_obs,TM_INFINITE);
		}
		tabObstaclePris = 1;
		printf("***************** COMPUTATION TASK ******************\n");
		
		for(i = 0; i<SENSOR_SIZE; i++){
			//If the obstacle is farther than 7meters
			if(sensorArray[i] > 7){
				
				obstacle* newObstacle = malloc(sizeof(obstacle));
				newObstacle->distance = sensorArray[i];
				
				//Add the new obstacle at the end of the list
				newObstacle->nxt = NULL;
				
				if(obstacleList == NULL) obstacleList = newObstacle;
				else{
					obstacle* temp = obstacleList;
					if(temp->distance==0)temp->distance=newObstacle->distance;
					else{
						while(temp->nxt != NULL)temp = temp->nxt;
						temp->nxt = newObstacle;
					}
				}
			}			
		}
		tabDonnePris = 0;
		tabObstaclePris = 0;
		
		rt_mutex_release(&mutex_obs);
		rt_mutex_release(&mutex_donnee);
		rt_sem_v(&sem_obs);		
		

		usleep(200000);
		printf("fin compute\n");
	}
}
开发者ID:mikotodesign,项目名称:University-Projects,代码行数:56,代码来源:main.c

示例7: batterie

void batterie(void *arg) {
    rt_printf("tconnect : Attente du sémarphore semConnectedRobotbatterie\n");
    rt_sem_p(&semConnectedRobot, TM_INFINITE);
    
    int status=1;
    int niveau_batterie=0;
    DBattery *bat= d_new_battery();
    DMessage *message;
    

    rt_printf("tbatterie : Debut de l'éxecution de periodique à 250ms\n");
    rt_task_set_periodic(NULL, TM_NOW, 250000000);
    
     while (1) {
        rt_task_wait_period(NULL);
        rt_printf("tbatterie : Activation périodique\n");
         
        rt_mutex_acquire(&mutexEtat, TM_INFINITE);
        status = etatCommMoniteur;
        rt_mutex_release(&mutexEtat);
        
         if (status == STATUS_OK) {
             rt_mutex_acquire(&mutexRobot, TM_INFINITE);
             status=d_robot_get_vbat(robot, &niveau_batterie);
             rt_mutex_release(&mutexRobot);
             
             rt_mutex_acquire(&mutexEtat, TM_INFINITE);
             etatCommRobot=status;
             rt_mutex_release(&mutexEtat);
             
             rt_printf("Niveau de la batterie : %d\n", niveau_batterie);
             rt_printf("Status : %d\n", status);
             
             if(status == STATUS_OK) {
                 message=d_new_message();
                 d_battery_set_level(bat,niveau_batterie);
                 d_message_put_battery_level(message, bat);
                 rt_mutex_acquire(&mutexCom, TM_INFINITE);
                 if (write_in_queue(&queueMsgGUI, message, sizeof (DMessage)) < 0) {
                        message->free(message);
                }
                 rt_mutex_release(&mutexCom);
                 
             }
             
 
         }
     }
    
}
开发者ID:killtrust,项目名称:temps,代码行数:50,代码来源:fonctions.c

示例8: deplacer

void deplacer(void *arg) {
    int status;

    rt_printf("tmove : Attente du sémaphore semDeplacer\n");
    rt_sem_p(&semDeplacer, TM_INFINITE);
    rt_printf("tmove : Debut de l'éxecution periodique à 200ms\n");
    rt_task_set_periodic(NULL, TM_NOW, 200000000);

    while (1) {
        while (cptCommErr < MAX_ECHECS) {
            /* Attente de l'activation périodique */
            rt_task_wait_period(NULL);
            //rt_printf("tmove : Activation périodique\n");

            rt_mutex_acquire(&mutexEtat, TM_INFINITE);
            status = etatCommRobot;
            rt_mutex_release(&mutexEtat);
            if (status == STATUS_OK) {
                rt_mutex_acquire(&mutexMove, TM_INFINITE);
                switch (move->get_direction(move)) {
                case DIRECTION_FORWARD:
                    status = robot->set_motors(robot, MOTEUR_ARRIERE_LENT, MOTEUR_ARRIERE_LENT);
                    break;
                case DIRECTION_LEFT:
                    status = robot->set_motors(robot, MOTEUR_ARRIERE_LENT, MOTEUR_AVANT_LENT);
                    break;
                case DIRECTION_RIGHT:
                    status = robot->set_motors(robot, MOTEUR_AVANT_LENT, MOTEUR_ARRIERE_LENT);
                    break;
                case DIRECTION_STOP:
                    status = robot->set_motors(robot, MOTEUR_STOP, MOTEUR_STOP);
                    break;
                case DIRECTION_STRAIGHT:
                    status = robot->set_motors(robot, MOTEUR_AVANT_LENT, MOTEUR_AVANT_LENT);
                    break;
                }
                rt_mutex_release(&mutexMove);

                if (status == STATUS_OK) {
                    cptCommErr = 0;
                } else {
                    cptCommErr++;
                    rt_printf("tmove : Erreur de communication avec le robot (%d)\n", cptCommErr);
                }
            }
        }
        comm_err_handler(status);
        rt_sem_p(&semDeplacer, TM_INFINITE);
    }
}
开发者ID:herbert-de-vaucanson,项目名称:TR,代码行数:50,代码来源:fonctions.c

示例9: timerloop_task_proc

/**
 * Timer Task
 */
void timerloop_task_proc(void *arg)
{
	int ret = 0;

	getElapsedTime();
	last_timeout_set = 0;
	last_occured_alarm = last_time_read;

	/* trigger first alarm */
	SetAlarm(callback_od, 0, init_callback, 0, 0);
	RTIME current_time;
	RTIME real_alarm;
	do{

		rt_mutex_acquire(&condition_mutex, TM_INFINITE);
		if(last_timeout_set == TIMEVAL_MAX)
		{
			ret = rt_cond_wait(
				&timer_set,
				&condition_mutex,
				TM_INFINITE
				);		/* Then sleep until next message*/
			rt_mutex_release(&condition_mutex);
		}else{
			current_time = rt_timer_read();
			real_alarm = last_time_read + last_timeout_set;
			ret = rt_cond_wait( /* sleep until next deadline */
				&timer_set,
				&condition_mutex,
				(real_alarm - current_time)); /* else alarm consider expired */
			if(ret == -ETIMEDOUT){
				last_occured_alarm = real_alarm;
				rt_mutex_release(&condition_mutex);
				EnterMutex();
				TimeDispatch();
				LeaveMutex();
			}else{
				rt_mutex_release(&condition_mutex);
			}
		}
	}while ((ret == 0 || ret == -EINTR || ret == -ETIMEDOUT) && !stop_timer);

	if(exitall){
		EnterMutex();
		exitall(callback_od, 0);
		LeaveMutex();
	}
}
开发者ID:githubhjz,项目名称:CanFestival,代码行数:51,代码来源:timers_kernel_xeno.c

示例10: opponentMovement

void opponentMovement(char strOpponent){
    int err;

    if(strOpponent == 'R'){
          if (!(err=illegal_move_check(oppoentPointLocationX, standardPongSpeed))){
              oppoentPointLocationX = oppoentPointLocationX + standardPongSpeed;
              pongs[opponent].leftCorner.point_x = oppoentPointLocationX;
              pongs[opponent].leftCorner.point_y = resolution_y;
          }
	   else {
	        oppoentPointLocationX = oppoentPointLocationX - (err * standardPongSpeed);
	        pongs[opponent].leftCorner.point_x = oppoentPointLocationX;
          }
    }

    else if (strOpponent == 'L'){
        if (!(err=illegal_move_check(oppoentPointLocationX, standardPongSpeed))){
              oppoentPointLocationX = oppoentPointLocationX - standardPongSpeed;
              pongs[opponent].leftCorner.point_x = oppoentPointLocationX;
              pongs[opponent].leftCorner.point_y = resolution_y;
          }
	else {

	      oppoentPointLocationX = oppoentPointLocationX + (-err * standardPongSpeed);
	      pongs[opponent].leftCorner.point_x = oppoentPointLocationX;
	  }
    }

     rt_mutex_acquire(&txMutex[E_MOVE], TM_INFINITE);
     memset(moveData[1], 0, sizeof(moveData[1]));
     sprintf(moveData[1], "player2;%d;%d;%d;%d;",
         pongs[opponent].leftCorner.point_x, pongs[opponent].leftCorner.point_y,pongLength, pongs[opponent].height);
     padString(moveData[1]);
     rt_mutex_release(&txMutex[E_MOVE]);
}
开发者ID:iasoule,项目名称:SYSC3303-Pong,代码行数:35,代码来源:Model.c

示例11: move

void move(char str){
     
    int err;
    if(str == 'R'){
          if ((err=illegal_move_check(locationPointOfX, standardPongSpeed)) == 0){
              locationPointOfX = locationPointOfX + standardPongSpeed;
              pongs[player].leftCorner.point_x = locationPointOfX;
              pongs[player].leftCorner.point_y = DEFAULT_HEIGHT;
	  }
          else {
	        locationPointOfX = locationPointOfX - (err * standardPongSpeed);
	        pongs[player].leftCorner.point_x = locationPointOfX;
          }
    }

    else if (str == 'L'){
        if ((err=illegal_move_check(locationPointOfX, standardPongSpeed)) == 0){
              locationPointOfX = locationPointOfX - standardPongSpeed;
              pongs[player].leftCorner.point_x = locationPointOfX;
              pongs[player].leftCorner.point_y = DEFAULT_HEIGHT;
          }
	else {
	      locationPointOfX = locationPointOfX + (-err * standardPongSpeed);
	      pongs[player].leftCorner.point_x = locationPointOfX;
	  }
    }

       rt_mutex_acquire(&txMutex[E_MOVE], TM_INFINITE);
       memset(moveData[0], 0, sizeof(moveData[0]));
       sprintf(moveData[0], "player1;%d;%d;%d;%d;",
               pongs[player].leftCorner.point_x, pongs[player].leftCorner.point_y,pongLength, 
               pongs[player].height);
       padString(moveData[0]);
       rt_mutex_release(&txMutex[E_MOVE]);
}
开发者ID:iasoule,项目名称:SYSC3303-Pong,代码行数:35,代码来源:Model.c

示例12: addBall

void addBall(){

    if(!ball.created){ //singleton pattern
        ball.centre.point_x = (resolution_w-resolution_x)/2;
        ball.centre.point_y = (resolution_h-resolution_y)/2;
        defaultBalllocationX = (resolution_w-resolution_x)/2;
        defaultBalllocationY =  (resolution_h-resolution_y)/2;

	currentBallOfX = ball.centre.point_x;
        currentBallOfY = ball.centre.point_y;

        // pPanel notify for created pPanel
        balldirectionX = DEFAULT_BALLSPEEDX;
        balldirectionY = DEFAULT_BALLSPEEDY;
        
	rt_mutex_acquire(&txMutex[E_GAME], TM_INFINITE);
	memset(gameData, 0, sizeof(gameData));
	sprintf(gameData, "score;%d;%d;",player_score,opponent_score);
	padString(gameData);
	rt_mutex_release(&txMutex[E_GAME]);
      	
	 memset(ballData, 0, sizeof(ballData));
         sprintf(ballData, "ball;%d;%d;%d;",defaultBalllocationX, defaultBalllocationY, ball.radius);
         padString(ballData);
	 ball.created = true;
    }
}
开发者ID:iasoule,项目名称:SYSC3303-Pong,代码行数:27,代码来源:Model.c

示例13: ecx_outframe_red

/** Transmit buffer over socket (non blocking).
 * @param[in] port        = port context struct
 * @param[in] idx = index in tx buffer array
 * @return socket send result
 */
int ecx_outframe_red(ecx_portt *port, int idx)
{
   ec_comt *datagramP;
   ec_etherheadert *ehp;
   int rval;
   
   ehp = (ec_etherheadert *)&(port->txbuf[idx]);
   /* rewrite MAC source address 1 to primary */
   ehp->sa1 = htons(priMAC[1]);
   /* transmit over primary socket*/
   rval = ecx_outframe(port, idx, 0);
   if (port->redstate != ECT_RED_NONE)
   {   
      //pthread_mutex_lock( &(port->tx_mutex) );
      rt_mutex_acquire(&port->tx_mutex, TM_INFINITE);
      ehp = (ec_etherheadert *)&(port->txbuf2);
      /* use dummy frame for secondary socket transmit (BRD) */
      datagramP = (ec_comt*)&(port->txbuf2[ETH_HEADERSIZE]);
      /* write index to frame */
      datagramP->index = idx;
      /* rewrite MAC source address 1 to secondary */
      ehp->sa1 = htons(secMAC[1]);
      /* transmit over secondary socket */
      SEND(port->redport->sockhandle, &(port->txbuf2), port->txbuflength2 , 0);
      //pthread_mutex_unlock( &(port->tx_mutex) );
      rt_mutex_release(&port->tx_mutex);
      port->redport->rxbufstat[idx] = EC_BUF_TX;
   }   
   
   return rval;
}
开发者ID:nswdc,项目名称:soem-rosbuild,代码行数:36,代码来源:nicdrv.c

示例14: connecter

void connecter(void *arg) {
    DMessage *message = d_new_message();
    int status;

    rt_printf("tconnect : Debut de l'exécution de tconnect\n");

    while (1) {
        rt_printf("tconnect : Attente du sémaphore semConnecterRobot\n");
        rt_sem_p(&semConnecterRobot, TM_INFINITE);
        rt_printf("tconnect : Ouverture de la communication avec le robot\n");
        status = robot->open_device(robot);
        rt_mutex_acquire(&mutexEtat, TM_INFINITE);
        etatCommRobot = status;

        if (status == STATUS_OK) {
            cptCommErr = 0;
            //robot->start_insecurely(robot);
            status = robot->start(robot);
            if (status == STATUS_OK) { /* Demarrage du robot */
                rt_printf("tconnect : Robot démarrer\n");
                rt_sem_v(&semDeplacer);
                rt_sem_v(&semRechargerWatchdog);
                rt_sem_v(&semVerifierBatterie);
            } else { /* Impossible de demarrer le robot, tentative de reinitialisation */
                robot->stop(robot);
                robot->close_com(robot);
            }
        }
        
        rt_mutex_release(&mutexEtat);
        message->put_state(message, status);
        serveur->send(serveur, message);
    }
}
开发者ID:herbert-de-vaucanson,项目名称:TR,代码行数:34,代码来源:fonctions.c

示例15: ptgui_dc_hw_fini

static rt_bool_t ptgui_dc_hw_fini(struct ptgui_dc *dc)
{
	struct ptgui_dc_hw *hw = (struct ptgui_dc_hw *)dc;
	if (dc == RT_NULL || hw->parent.type != PTGUI_DC_HW) {
		return RT_FALSE;
	}

#ifdef __WIN32__
#ifdef PTGUI_USING_MOUSE_CURSOR
	rt_mutex_release(&cursor_mutex);
	/* show cursor */
	ptgui_mouse_show_cursor();
	rt_kprintf("show cursor\n");
#endif
	/* update screen */
	hw->device->screen_update(&(hw->owner->extent));
#else
#ifdef PTGUI_USING_MOUSE_CURSOR
	/* show cursor */
	ptgui_mouse_show_cursor();
#endif

	/* update screen */
	hw->device->screen_update(&(hw->owner->extent));
#endif

	return RT_TRUE;
}
开发者ID:sharpglasses,项目名称:ServerSkeleton,代码行数:28,代码来源:dc_hw.c


注:本文中的rt_mutex_release函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。