您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xSemaphoreGiveRecursive函数代码示例

51自学网 2021-06-03 10:14:24
  C++
这篇教程C++ xSemaphoreGiveRecursive函数代码示例写得很实用,希望能帮到您。

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

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

示例1: UAVObjGetInstanceDataField

/** * Get the data of a specific object instance * /param[in] obj The object handle * /param[in] instId The object instance ID * /param[out] dataOut The object's data structure * /return 0 if success or -1 if failure */int32_t UAVObjGetInstanceDataField(UAVObjHandle obj, uint16_t instId, void* dataOut, uint32_t offset, uint32_t size){	ObjectList* objEntry;	ObjectInstList* instEntry;	// Lock	xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	// Cast to object info	objEntry = (ObjectList*)obj;	// Get instance information	instEntry = getInstance(objEntry, instId);	if ( instEntry == NULL )	{		// Error, unlock and return		xSemaphoreGiveRecursive(mutex);		return -1;	}	// return if we request too much of what we can give	if ( (size + offset) > objEntry->numBytes) 	{		// Error, unlock and return		xSemaphoreGiveRecursive(mutex);		return -1;	}		// Set data	memcpy(dataOut, instEntry->data + offset, size);	// Unlock	xSemaphoreGiveRecursive(mutex);	return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:42,


示例2: UAVObjPack

/** * Pack an object to a byte array * /param[in] obj The object handle * /param[in] instId The instance ID * /param[out] dataOut The byte array * /return 0 if success or -1 if failure */int32_t UAVObjPack(UAVObjHandle obj, uint16_t instId, uint8_t * dataOut){	  ObjectList *objEntry;	  ObjectInstList *instEntry;	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast handle to object	  objEntry = (ObjectList *) obj;	  // Get the instance	  instEntry = getInstance(objEntry, instId);	  if (instEntry == NULL) {		    // Error, unlock and return		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Pack data	  memcpy(dataOut, instEntry->data, objEntry->numBytes);	  // Unlock	  xSemaphoreGiveRecursive(mutex);	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:32,


示例3: UAVObjUnpack

/** * Unpack an object from a byte array * /param[in] obj The object handle * /param[in] instId The instance ID * /param[in] dataIn The byte array * /return 0 if success or -1 if failure */int32_t UAVObjUnpack(UAVObjHandle obj, uint16_t instId,		     const uint8_t * dataIn){	  ObjectList *objEntry;	  ObjectInstList *instEntry;	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast handle to object	  objEntry = (ObjectList *) obj;	  // Get the instance	  instEntry = getInstance(objEntry, instId);	  // If the instance does not exist create it and any other instances before it	  if (instEntry == NULL) {		    instEntry = createInstance(objEntry, instId);		    if (instEntry == NULL) {			      // Error, unlock and return			      xSemaphoreGiveRecursive(mutex);			      return -1;		    }	  }	  // Set the data	  memcpy(instEntry->data, dataIn, objEntry->numBytes);	  // Fire event	  sendEvent(objEntry, instId, EV_UNPACKED);	  // Unlock	  xSemaphoreGiveRecursive(mutex);	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:41,


示例4: hasSeverity

/** * Check if there are any alarms with the given or higher severity * @return 0 if no alarms are found, 1 if at least one alarm is found */static int32_t hasSeverity(SystemAlarmsAlarmOptions severity){	SystemAlarmsData alarms;	uint32_t n;	// Lock    xSemaphoreTakeRecursive(lock, portMAX_DELAY);    // Read alarms    SystemAlarmsGet(&alarms);    // Go through alarms and check if any are of the given severity or higher    for (n = 0; n < SYSTEMALARMS_ALARM_NUMELEM; ++n)    {    	if ( alarms.Alarm[n] >= severity)    	{    		xSemaphoreGiveRecursive(lock);    		return 1;    	}    }    // If this point is reached then no alarms found    xSemaphoreGiveRecursive(lock);    return 0;}
开发者ID:1heinz,项目名称:TauLabs,代码行数:29,


示例5: UAVObjGetInstanceData

/** * Get the data of a specific object instance * /param[in] obj The object handle * /param[in] instId The object instance ID * /param[out] dataOut The object's data structure * /return 0 if success or -1 if failure */int32_t UAVObjGetInstanceData(UAVObjHandle obj, uint16_t instId,			      void *dataOut){	  ObjectList *objEntry;	  ObjectInstList *instEntry;	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast to object info	  objEntry = (ObjectList *) obj;	  // Get instance information	  instEntry = getInstance(objEntry, instId);	  if (instEntry == NULL) {		    // Error, unlock and return		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Set data	  memcpy(dataOut, instEntry->data, objEntry->numBytes);	  // Unlock	  xSemaphoreGiveRecursive(mutex);	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:33,


示例6: UAVObjSave

/** * Save the data of the specified object to the file system (SD card). * If the object contains multiple instances, all of them will be saved. * A new file with the name of the object will be created. * The object data can be restored using the UAVObjLoad function. * @param[in] obj The object handle. * @param[in] instId The instance ID * @param[in] file File to append to * @return 0 if success or -1 if failure */int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId){#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)	  ObjectList *objEntry = (ObjectList *) obj;	  if (objEntry == NULL)		    return -1;	  ObjectInstList *instEntry = getInstance(objEntry, instId);	  if (instEntry == NULL)		    return -1;	  if (instEntry->data == NULL)		    return -1;	  if (PIOS_FLASHFS_ObjSave(obj, instId, instEntry->data) != 0)		    return -1;#endif#if defined(PIOS_INCLUDE_SDCARD)	  FILEINFO file;	  ObjectList *objEntry;	  uint8_t filename[14];	  // Check for file system availability	  if (PIOS_SDCARD_IsMounted() == 0) {		    return -1;	  }	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast to object	  objEntry = (ObjectList *) obj;	  // Get filename	  objectFilename(objEntry, filename);	  // Open file	  if (PIOS_FOPEN_WRITE(filename, file)) {		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Append object	  if (UAVObjSaveToFile(obj, instId, &file) == -1) {		    PIOS_FCLOSE(file);		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Done, close file and unlock	  PIOS_FCLOSE(file);	  xSemaphoreGiveRecursive(mutex);#endif /* PIOS_INCLUDE_SDCARD */	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:64,


示例7: prvExerciseSemaphoreAPI

static void prvExerciseSemaphoreAPI( void ){SemaphoreHandle_t xSemaphore;const UBaseType_t uxMaxCount = 5, uxInitialCount = 0;	/* Most of the semaphore API is common to the queue API and is already being	used.  This function uses a few semaphore functions that are unique to the	RTOS objects, rather than generic and used by queues also.	First create and use a counting semaphore. */	xSemaphore = xSemaphoreCreateCounting( uxMaxCount, uxInitialCount );	configASSERT( xSemaphore );	/* Give the semaphore a couple of times and ensure the count is returned	correctly. */	xSemaphoreGive( xSemaphore );	xSemaphoreGive( xSemaphore );	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 2 );	vSemaphoreDelete( xSemaphore );	/* Create a recursive mutex, and ensure the mutex holder and count are	returned returned correctly. */	xSemaphore = xSemaphoreCreateRecursiveMutex();	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 );	configASSERT( xSemaphore );	xSemaphoreTakeRecursive( xSemaphore, mainDONT_BLOCK );	xSemaphoreTakeRecursive( xSemaphore, mainDONT_BLOCK );	configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetCurrentTaskHandle() );	configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetHandle( mainTASK_TO_DELETE_NAME ) );	xSemaphoreGiveRecursive( xSemaphore );	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 );	xSemaphoreGiveRecursive( xSemaphore );	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 );	configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == NULL );	vSemaphoreDelete( xSemaphore );	/* Create a normal mutex, and sure the mutex holder and count are returned	returned correctly. */	xSemaphore = xSemaphoreCreateMutex();	configASSERT( xSemaphore );	xSemaphoreTake( xSemaphore, mainDONT_BLOCK );	xSemaphoreTake( xSemaphore, mainDONT_BLOCK );	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 ); /* Not recursive so can only be 1. */	configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetCurrentTaskHandle() );	xSemaphoreGive( xSemaphore );	configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 );	configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == NULL );	vSemaphoreDelete( xSemaphore );}
开发者ID:sean93park,项目名称:freertos,代码行数:49,


示例8: UAVObjSetInstanceDataField

/** * Set the data of a specific object instance * /param[in] obj The object handle * /param[in] instId The object instance ID * /param[in] dataIn The object's data structure * /return 0 if success or -1 if failure */int32_t UAVObjSetInstanceDataField(UAVObjHandle obj, uint16_t instId, const void* dataIn, uint32_t offset, uint32_t size){	ObjectList* objEntry;	ObjectInstList* instEntry;	UAVObjMetadata* mdata;	// Lock	xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	// Cast to object info	objEntry = (ObjectList*)obj;	// Check access level	if ( !objEntry->isMetaobject )	{		mdata = (UAVObjMetadata*)(objEntry->linkedObj->instances.data);		if ( mdata->access == ACCESS_READONLY )		{			xSemaphoreGiveRecursive(mutex);			return -1;		}	}	// Get instance information	instEntry = getInstance(objEntry, instId);	if ( instEntry == NULL )	{		// Error, unlock and return		xSemaphoreGiveRecursive(mutex);		return -1;	}	// return if we set too much of what we have	if ( (size + offset) > objEntry->numBytes) {		// Error, unlock and return		xSemaphoreGiveRecursive(mutex);				return -1;	}	// Set data	memcpy(instEntry->data + offset, dataIn, size);	// Fire event	sendEvent(objEntry, instId, EV_UPDATED);	// Unlock	xSemaphoreGiveRecursive(mutex);	return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:56,


示例9: AlarmsSet

/** * Set an alarm * @param alarm The system alarm to be modified * @param severity The alarm severity * @return 0 if success, -1 if an error */int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity){	SystemAlarmsData alarms;	// Check that this is a valid alarm	if (alarm >= SYSTEMALARMS_ALARM_NUMELEM)	{		return -1;	}	// Lock    xSemaphoreTakeRecursive(lock, portMAX_DELAY);    // Read alarm and update its severity only if it was changed    SystemAlarmsGet(&alarms);    if ( alarms.Alarm[alarm] != severity )    {    	alarms.Alarm[alarm] = severity;    	SystemAlarmsSet(&alarms);    }    // Release lock    xSemaphoreGiveRecursive(lock);    return 0;}
开发者ID:1heinz,项目名称:TauLabs,代码行数:32,


示例10: UAVObjDelete

/** * Delete an object from the file system (SD card). * @param[in] obj The object handle. * @param[in] instId The object instance * @return 0 if success or -1 if failure */int32_t UAVObjDelete(UAVObjHandle obj, uint16_t instId){#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)	  PIOS_FLASHFS_ObjDelete(obj, instId);#endif#if defined(PIOS_INCLUDE_SDCARD)	  ObjectList *objEntry;	  uint8_t filename[14];	  // Check for file system availability	  if (PIOS_SDCARD_IsMounted() == 0) {		    return -1;	  }	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast to object	  objEntry = (ObjectList *) obj;	  // Get filename	  objectFilename(objEntry, filename);	  // Delete file	  PIOS_FUNLINK(filename);	  // Done	  xSemaphoreGiveRecursive(mutex);#endif /* PIOS_INCLUDE_SDCARD */	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:36,


示例11: TaskMonitorUpdateAll

/** * Update the status of all tasks */void TaskMonitorUpdateAll(void){	TaskInfoData data;	int n;	// Lock	xSemaphoreTakeRecursive(lock, portMAX_DELAY);	// Update all task information	for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n)	{		if (handles[n] != 0)		{			data.Running[n] = TASKINFO_RUNNING_TRUE;#if defined(ARCH_POSIX) || defined(ARCH_WIN32)			data.StackRemaining[n] = 10000;#else			data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4;#endif		}		else		{			data.Running[n] = TASKINFO_RUNNING_FALSE;			data.StackRemaining[n] = 0;		}	}	// Update object	TaskInfoSet(&data);	// Done	xSemaphoreGiveRecursive(lock);}
开发者ID:mcu786,项目名称:my_OpenPilot_mods,代码行数:36,


示例12: simpleQueueSize

int simpleQueueSize(struct SimpleQueue* queue){	int return_value;	while(xSemaphoreTakeRecursive(queue->xSemHandle,(TickType_t)0) != pdTRUE){}	return_value = queue->size;	xSemaphoreGiveRecursive(queue->xSemHandle);	return return_value;}
开发者ID:ntonjeta,项目名称:Nodo-Sensore,代码行数:7,


示例13: UAVTalkAddStats

/** * Get communication statistics counters * /param[in] connection UAVTalkConnection to be used * @param[out] statsOut Statistics counters */void UAVTalkAddStats(UAVTalkConnection connectionHandle, UAVTalkStats *statsOut, bool reset){    UAVTalkConnectionData *connection;    CHECKCONHANDLE(connectionHandle, connection, return );    // Lock    xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);    // Copy stats    statsOut->txBytes       += connection->stats.txBytes;    statsOut->txObjectBytes += connection->stats.txObjectBytes;    statsOut->txObjects     += connection->stats.txObjects;    statsOut->txErrors      += connection->stats.txErrors;    statsOut->rxBytes       += connection->stats.rxBytes;    statsOut->rxObjectBytes += connection->stats.rxObjectBytes;    statsOut->rxObjects     += connection->stats.rxObjects;    statsOut->rxErrors      += connection->stats.rxErrors;    statsOut->rxSyncErrors  += connection->stats.rxSyncErrors;    statsOut->rxCrcErrors   += connection->stats.rxCrcErrors;    if (reset) {        // Clear stats        memset(&connection->stats, 0, sizeof(UAVTalkStats));    }    // Release lock    xSemaphoreGiveRecursive(connection->lock);}
开发者ID:MAVProxyUser,项目名称:NinjaPilot-15.02.ninja,代码行数:34,


示例14: simpleQueueDestroy

void simpleQueueDestroy(struct SimpleQueue* queue){	while(xSemaphoreTakeRecursive(queue->xSemHandle,(TickType_t) 0)!=pdTRUE){}	while(!simpleQueueEmpty(queue))		simpleQueueDequeue(queue);	 xSemaphoreGiveRecursive(queue->xSemHandle);	 vSemaphoreDelete(queue->xSemHandle);	//TODO: ZUPPA}
开发者ID:ntonjeta,项目名称:Nodo-Sensore,代码行数:8,


示例15: objectTransaction

/** * Execute the requested transaction on an object. * /param[in] connection UAVLinkConnection to be used * /param[in] obj Object * /param[in] instId The instance ID of UAVOBJ_ALL_INSTANCES for all instances. * /param[in] type Transaction type * 			  UAVLINK_TYPE_OBJ: send object, * 			  UAVLINK_TYPE_OBJ_REQ: request object update * 			  UAVLINK_TYPE_OBJ_ACK: send object with an ack * /return 0 Success * /return -1 Failure */static int32_t objectTransaction(UAVLinkConnectionData *connection, UAVObjHandle obj, uint16_t instId, uint8_t type, int32_t timeoutMs){	int32_t respReceived;		// Send object depending on if a response is needed	if (type == UAVLINK_TYPE_OBJ_ACK || type == UAVLINK_TYPE_OBJ_REQ)	{		// Get transaction lock (will block if a transaction is pending)		xSemaphoreTakeRecursive(connection->transLock, portMAX_DELAY);		// Send object		xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);		connection->respId =  UAVObjGetID(obj);		connection->respInstId = instId;		sendObject(connection, obj, instId, type);		xSemaphoreGiveRecursive(connection->lock);		// Wait for response (or timeout)		respReceived = xSemaphoreTake(connection->respSema, timeoutMs/portTICK_RATE_MS);		// Check if a response was received		if (respReceived == pdFALSE)		{			// Cancel transaction			xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);			xSemaphoreTake(connection->respSema, 0); // non blocking call to make sure the value is reset to zero (binary sema)			connection->respId = 0;			xSemaphoreGiveRecursive(connection->lock);			xSemaphoreGiveRecursive(connection->transLock);			return -1;		}		else		{			xSemaphoreGiveRecursive(connection->transLock);			return 0;		}	}	else if (type == UAVLINK_TYPE_OBJ)	{		xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);		sendObject(connection, obj, instId, UAVLINK_TYPE_OBJ);		xSemaphoreGiveRecursive(connection->lock);		return 0;	}	else	{		return -1;	}}
开发者ID:auuuux,项目名称:raspberrypilot,代码行数:58,


示例16: UAVObjDisconnectCallback

/** * Disconnect an event callback from the object. * /param[in] obj The object handle * /param[in] cb The event callback * /return 0 if success or -1 if failure */int32_t UAVObjDisconnectCallback(UAVObjHandle obj, UAVObjEventCallback cb){	  int32_t res;	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  res = disconnectObj(obj, 0, cb);	  xSemaphoreGiveRecursive(mutex);	  return res;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:14,


示例17: __malloc_unlock

 void __malloc_unlock(struct _reent *reent){     if ( g_heap_mutex ){         if ( pdFALSE == xSemaphoreGiveRecursive( g_heap_mutex)){             Serial2.println("BUG! failed to unlock the heap!");             delay(1000);         }     } }
开发者ID:kyab,项目名称:mruby-thread-freertos,代码行数:8,


示例18: __malloc_unlock

void __malloc_unlock(struct _reent *ptr){    UNUSED_PARAMETER( ptr );    if( malloc_mutex )    {        xSemaphoreGiveRecursive( malloc_mutex );    }}
开发者ID:fishbaoz,项目名称:wiced-emw3165,代码行数:8,


示例19: UAVObjGetNumInstances

/** * Get the number of instances contained in the object. * /param[in] obj The object handle * /return The number of instances */uint16_t UAVObjGetNumInstances(UAVObjHandle obj){	  uint32_t numInstances;	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  numInstances = ((ObjectList *) obj)->numInstances;	  xSemaphoreGiveRecursive(mutex);	  return numInstances;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:13,


示例20: prvSanityCheckCreatedRecursiveMutex

static void prvSanityCheckCreatedRecursiveMutex( SemaphoreHandle_t xSemaphore ){const BaseType_t xLoops = 5;BaseType_t x, xReturned;	/* A very basic test that the recursive semaphore behaved like a recursive	semaphore. First the semaphore should not be able to be given, as it has not	yet been taken. */	xReturned = xSemaphoreGiveRecursive( xSemaphore );	if( xReturned != pdFAIL )	{		xErrorOccurred = pdTRUE;	}	/* Now it should be possible to take the mutex a number of times. */	for( x = 0; x < xLoops; x++ )	{		xReturned = xSemaphoreTakeRecursive( xSemaphore, staticDONT_BLOCK );		if( xReturned != pdPASS )		{			xErrorOccurred = pdTRUE;		}	}	/* Should be possible to give the semaphore the same number of times as it	was given in the loop above. */	for( x = 0; x < xLoops; x++ )	{		xReturned = xSemaphoreGiveRecursive( xSemaphore );		if( xReturned != pdPASS )		{			xErrorOccurred = pdTRUE;		}	}	/* No more gives should be possible though. */	xReturned = xSemaphoreGiveRecursive( xSemaphore );	if( xReturned != pdFAIL )	{		xErrorOccurred = pdTRUE;	}}
开发者ID:radiolok,项目名称:RelayComputer2,代码行数:46,


示例21: UAVObjDisconnectQueue

/** * Disconnect an event queue from the object. * /param[in] obj The object handle * /param[in] queue The event queue * /return 0 if success or -1 if failure */int32_t UAVObjDisconnectQueue(UAVObjHandle obj, xQueueHandle queue){	  int32_t res;	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  res = disconnectObj(obj, queue, 0);	  xSemaphoreGiveRecursive(mutex);	  return res;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:14,


示例22: xSemaphoreTakeRecursive

void dispatch_queue::dispatch_thread_handler(void){	BaseType_t status = xSemaphoreTakeRecursive(mutex_, portMAX_DELAY);	assert(status == pdTRUE && "Failed to lock mutex!");	do {		//after wait, we own the lock		if(!quit_ && q_.size())		{			auto op = std::move(q_.front());			q_.pop();			//unlock now that we're done messing with the queue			status = xSemaphoreGiveRecursive(mutex_);			assert(status == pdTRUE && "Failed to unlock mutex!");			op();			status = xSemaphoreTakeRecursive(mutex_, portMAX_DELAY);			assert(status == pdTRUE && "Failed to lock mutex!");		}		else if(!quit_)		{			status = xSemaphoreGiveRecursive(mutex_);			assert(status == pdTRUE && "Failed to unlock mutex!");			// Wait for new work - clear flags on exit			xEventGroupWaitBits(notify_flags_, DISPATCH_WAKE_EVT, pdTRUE, pdFALSE, portMAX_DELAY);			status = xSemaphoreTakeRecursive(mutex_, portMAX_DELAY);			assert(status == pdTRUE && "Failed to lock mutex!");		}	} while (!quit_);	// We were holding the mutex after we woke up	status = xSemaphoreGiveRecursive(mutex_);	assert(status == pdTRUE && "Failed to unlock mutex!");	// Set a signal to indicate a thread exited	status = xEventGroupSetBits(notify_flags_, DISPATCH_EXIT_EVT);	assert(status == pdTRUE && "Failed to set event flags!");	// Delete the current thread	vTaskDelete(NULL);}
开发者ID:typelogic,项目名称:embedded-resources,代码行数:45,


示例23: UAVObjSaveToFile

/** * Save the data of the specified object instance to the file system (SD card). * The object will be appended and the file will not be closed. * The object data can be restored using the UAVObjLoad function. * @param[in] obj The object handle. * @param[in] instId The instance ID * @param[in] file File to append to * @return 0 if success or -1 if failure */int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId,			 FILEINFO * file){#if defined(PIOS_INCLUDE_SDCARD)	  uint32_t bytesWritten;	  ObjectList *objEntry;	  ObjectInstList *instEntry;	  // Check for file system availability	  if (PIOS_SDCARD_IsMounted() == 0) {		    return -1;	  }	  // Lock	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  // Cast to object	  objEntry = (ObjectList *) obj;	  // Get the instance information	  instEntry = getInstance(objEntry, instId);	  if (instEntry == NULL) {		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Write the object ID	  PIOS_FWRITE(file, &objEntry->id, sizeof(objEntry->id),		      &bytesWritten);	  // Write the instance ID	  if (!objEntry->isSingleInstance) {		    PIOS_FWRITE(file, &instEntry->instId,				sizeof(instEntry->instId), &bytesWritten);	  }	  // Write the data and check that the write was successful	  PIOS_FWRITE(file, instEntry->data, objEntry->numBytes,		      &bytesWritten);	  if (bytesWritten != objEntry->numBytes) {		    xSemaphoreGiveRecursive(mutex);		    return -1;	  }	  // Done	  xSemaphoreGiveRecursive(mutex);#endif /* PIOS_INCLUDE_SDCARD */	  return 0;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:54,


示例24: __env_unlock

void __env_unlock ( struct _reent *_r ){#if OS_THREAD_SAFE_NEWLIB	if (!xTaskGetSchedulerState())		return;	  	xSemaphoreGiveRecursive(alt_envsem);#endif /* OS_THREAD_SAFE_NEWLIB */}
开发者ID:AlexShiLucky,项目名称:FreeLwIP-Nios-II,代码行数:9,


示例25: prvRecursiveMutexPollingTask

static void prvRecursiveMutexPollingTask( void *pvParameters ){	/* Just to remove compiler warning. */	( void ) pvParameters;	for( ;; )	{		/* Keep attempting to obtain the mutex.  We should only obtain it when		the blocking task has suspended itself, which in turn should only		happen when the controlling task is also suspended. */		if( xSemaphoreTakeRecursive( xMutex, recmuNO_DELAY ) == pdPASS )		{			/* Is the blocking task suspended? */			if( ( xBlockingIsSuspended != pdTRUE ) || ( xControllingIsSuspended != pdTRUE ) )			{				xErrorOccurred = pdTRUE;			}			else			{				/* Keep count of the number of cycles this task has performed 				so a stall can be detected. */				uxPollingCycles++;				/* We can resume the other tasks here even though they have a				higher priority than the polling task.  When they execute they				will attempt to obtain the mutex but fail because the polling				task is still the mutex holder.  The polling task (this task)				will then inherit the higher priority.  The Blocking task will				block indefinitely when it attempts to obtain the mutex, the				Controlling task will only block for a fixed period and an				error will be latched if the polling task has not returned the				mutex by the time this fixed period has expired. */				vTaskResume( xBlockingTaskHandle );                vTaskResume( xControllingTaskHandle );							/* The other two tasks should now have executed and no longer				be suspended. */				if( ( xBlockingIsSuspended == pdTRUE ) || ( xControllingIsSuspended == pdTRUE ) )				{					xErrorOccurred = pdTRUE;				}											/* Release the mutex, disinheriting the higher priority again. */				if( xSemaphoreGiveRecursive( xMutex ) != pdPASS )				{					xErrorOccurred = pdTRUE;				}			}		}		#if configUSE_PREEMPTION == 0		{			taskYIELD();		}		#endif	}}
开发者ID:DIYzzuzpb,项目名称:PIC32USB,代码行数:57,


示例26: UAVObjConnectQueue

/** * Connect an event queue to the object, if the queue is already connected then the event mask is only updated. * All events matching the event mask will be pushed to the event queue. * /param[in] obj The object handle * /param[in] queue The event queue * /param[in] eventMask The event mask, if EV_MASK_ALL then all events are enabled (e.g. EV_UPDATED | EV_UPDATED_MANUAL) * /return 0 if success or -1 if failure */int32_t UAVObjConnectQueue(UAVObjHandle obj, xQueueHandle queue,			   int32_t eventMask){	  int32_t res;	  xSemaphoreTakeRecursive(mutex, portMAX_DELAY);	  res = connectObj(obj, queue, 0, eventMask);	  xSemaphoreGiveRecursive(mutex);	  return res;}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:17,


示例27: objectTransaction

/** * Execute the requested transaction on an object. * /param[in] connection UAVTalkConnection to be used * /param[in] type Transaction type *                        UAVTALK_TYPE_OBJ: send object, *                        UAVTALK_TYPE_OBJ_REQ: request object update *                        UAVTALK_TYPE_OBJ_ACK: send object with an ack * /param[in] obj Object * /param[in] instId The instance ID of UAVOBJ_ALL_INSTANCES for all instances. * /param[in] timeoutMs Time to wait for the ack, when zero it will return immediately * /return 0 Success * /return -1 Failure */static int32_t objectTransaction(UAVTalkConnectionData *connection, uint8_t type, UAVObjHandle obj, uint16_t instId, int32_t timeoutMs){    int32_t respReceived;    int32_t ret = -1;    // Send object depending on if a response is needed    if (type == UAVTALK_TYPE_OBJ_ACK || type == UAVTALK_TYPE_OBJ_ACK_TS || type == UAVTALK_TYPE_OBJ_REQ) {        // Get transaction lock (will block if a transaction is pending)        xSemaphoreTakeRecursive(connection->transLock, portMAX_DELAY);        // Send object        xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);        // expected response type        connection->respType   = (type == UAVTALK_TYPE_OBJ_REQ) ? UAVTALK_TYPE_OBJ : UAVTALK_TYPE_ACK;        connection->respObjId  = UAVObjGetID(obj);        connection->respInstId = instId;        ret = sendObject(connection, type, UAVObjGetID(obj), instId, obj);        xSemaphoreGiveRecursive(connection->lock);        // Wait for response (or timeout) if sending the object succeeded        respReceived = pdFALSE;        if (ret == 0) {            respReceived = xSemaphoreTake(connection->respSema, timeoutMs / portTICK_RATE_MS);        }        // Check if a response was received        if (respReceived == pdTRUE) {            // We are done successfully            xSemaphoreGiveRecursive(connection->transLock);            ret = 0;        } else {            // Cancel transaction            xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);            // non blocking call to make sure the value is reset to zero (binary sema)            xSemaphoreTake(connection->respSema, 0);            connection->respObjId = 0;            xSemaphoreGiveRecursive(connection->lock);            xSemaphoreGiveRecursive(connection->transLock);            return -1;        }    } else if (type == UAVTALK_TYPE_OBJ || type == UAVTALK_TYPE_OBJ_TS) {        xSemaphoreTakeRecursive(connection->lock, portMAX_DELAY);        ret = sendObject(connection, type, UAVObjGetID(obj), instId, obj);        xSemaphoreGiveRecursive(connection->lock);    }    return ret;}
开发者ID:MAVProxyUser,项目名称:NinjaPilot-15.02.ninja,代码行数:57,


示例28: TaskMonitorUpdateAll

/** * Update the status of all tasks */void TaskMonitorUpdateAll(void){#if defined(DIAGNOSTICS)	TaskInfoData data;	int n;	// Lock	xSemaphoreTakeRecursive(lock, portMAX_DELAY);#if ( configGENERATE_RUN_TIME_STATS == 1 )	uint32_t currentTime;	uint32_t deltaTime;		/*	 * Calculate the amount of elapsed run time between the last time we	 * measured and now. Scale so that we can convert task run times	 * directly to percentages.	 */	currentTime = portGET_RUN_TIME_COUNTER_VALUE();	deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */	lastMonitorTime = currentTime;			#endif		// Update all task information	for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n)	{		if (handles[n] != 0)		{			data.Running[n] = TASKINFO_RUNNING_TRUE;#if defined(ARCH_POSIX) || defined(ARCH_WIN32)			data.StackRemaining[n] = 10000;#else			data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4;#if ( configGENERATE_RUN_TIME_STATS == 1 )			/* Generate run time stats */			data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime;			#endif#endif					}		else		{			data.Running[n] = TASKINFO_RUNNING_FALSE;			data.StackRemaining[n] = 0;			data.RunningTime[n] = 0;		}	}	// Update object	TaskInfoSet(&data);	// Done	xSemaphoreGiveRecursive(lock);#endif}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:59,


示例29: simpleQueueFront

SimpleQueueValue* simpleQueueFront(struct SimpleQueue* queue){	while(xSemaphoreTakeRecursive(queue->xSemHandle,(TickType_t)0) != pdTRUE){}	SimpleQueueValue* return_Value = NULL;	if (simpleQueueEmpty(queue))		return_Value =  NULL;	else		return_Value =  queue->head->value;	xSemaphoreGiveRecursive(queue->xSemHandle);	 return return_Value;}
开发者ID:ntonjeta,项目名称:Nodo-Sensore,代码行数:10,


示例30: osRecursiveMutexRelease

/*** @brief  Release a Recursive Mutex* @param   mutex_id      mutex ID obtained by /ref osRecursiveMutexCreate.* @retval  status code that indicates the execution status of the function.*/osStatus osRecursiveMutexRelease (osMutexId mutex_id){  osStatus result = osOK;    if (xSemaphoreGiveRecursive(mutex_id) != pdTRUE)   {    result = osErrorOS;  }  return result;}
开发者ID:timurey,项目名称:oryx_stm32f205,代码行数:15,



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


C++ xSemaphoreTake函数代码示例
C++ xSemaphoreGiveFromISR函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。