• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ eTaskGetState函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prvTestMasterTask

static void prvTestMasterTask( void *pvParameters )
{
    BaseType_t xError;

    /* The handle to the slave task is passed in as the task parameter. */
    TaskHandle_t xTestSlaveTaskHandle = ( TaskHandle_t ) pvParameters;

    /* Avoid compiler warnings. */
    ( void ) pvParameters;

    /* Create the event group used by the tasks ready for the initial tests. */
    xEventGroup = xEventGroupCreate();
    configASSERT( xEventGroup );

    /* Perform the tests that block two tasks on different combinations of bits,
    then set each bit in turn and check the correct tasks unblock at the correct
    times. */
    xError = prvSelectiveBitsTestMasterFunction();

    for( ;; ) {
        /* Recreate the event group ready for the next cycle. */
        xEventGroup = xEventGroupCreate();
        configASSERT( xEventGroup );

        /* Perform the tests that check the behaviour when a single task is
        blocked on various combinations of event bits. */
        xError = prvBitCombinationTestMasterFunction( xError, xTestSlaveTaskHandle );

        /* Perform the task synchronisation tests. */
        xError = prvPerformTaskSyncTests( xError, xTestSlaveTaskHandle );

        /* Delete the event group. */
        vEventGroupDelete( xEventGroup );

        /* Now all the other tasks should have completed and suspended
        themselves ready for the next go around the loop. */
        if( eTaskGetState( xTestSlaveTaskHandle ) != eSuspended ) {
            xError = pdTRUE;
        }

        if( eTaskGetState( xSyncTask1 ) != eSuspended ) {
            xError = pdTRUE;
        }

        if( eTaskGetState( xSyncTask2 ) != eSuspended ) {
            xError = pdTRUE;
        }

        /* Only increment the cycle variable if no errors have been detected. */
        if( xError == pdFALSE ) {
            ulTestMasterCycles++;
        }

        configASSERT( xError == pdFALSE );
    }
}
开发者ID:peterliu2,项目名称:tivaWare,代码行数:56,代码来源:EventGroupsDemo.c


示例2: test_task_get_state

void test_task_get_state(void* arg)
{
    //Current task should return eRunning
    TEST_ASSERT(eTaskGetState(xTaskGetCurrentTaskHandle()) == eRunning);
    //Idle task of current core should return eReady
    TEST_ASSERT(eTaskGetState(xTaskGetIdleTaskHandle()) == eReady);
    //Blocked Task should return eBlocked
    TEST_ASSERT(eTaskGetState(blocked_task_handle) == eBlocked);
    //Suspended Task should return eSuspended
    TEST_ASSERT(eTaskGetState(suspended_task_handle) == eSuspended);

    xSemaphoreGive(done_sem);
    vTaskDelete(NULL);
}
开发者ID:altran-nl,项目名称:esp-idf,代码行数:14,代码来源:test_freertos_get_state.c


示例3: task_state_consistent

// returns whether the given task state is consistent with its current RTOS state (given by its task handle state)
static bool task_state_consistent(bool expected_state, task_type_t task_id) {
	configASSERT(task_handles[task_id] != NULL && *task_handles[task_id] != NULL);
	eTaskState task_state_rtos = eTaskGetState(*task_handles[task_id]);
	// a task is "running" (expected_state should be true) if it's NOT suspended
	// see https://www.freertos.org/RTOS-task-states.html
	return expected_state == (task_state_rtos != eSuspended);
}
开发者ID:BrownCubeSat,项目名称:EQUiSat,代码行数:8,代码来源:satellite_state_control.c


示例4: suspend

void Task::suspend() {
    if (mTaskHandle && eTaskGetState(mTaskHandle) != eSuspended) {
        debug::log("Suspend task: " + getName());
        vTaskSuspend(mTaskHandle);
        afterSuspension();
    } 
}
开发者ID:Embedder74,项目名称:Mk2-Firmware,代码行数:7,代码来源:Task.cpp


示例5: osThreadIsSuspended

/**
* @brief Check if a thread is already suspended or not.
* @param thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @retval status code that indicates the execution status of the function.
*/
osStatus osThreadIsSuspended(osThreadId thread_id)
{
  if (eTaskGetState(thread_id) == eSuspended)
    return osOK;
  else
    return osErrorOS;
}
开发者ID:Casa2011,项目名称:devices,代码行数:12,代码来源:cmsis_os.c


示例6: osThreadGetState

/**
* @brief  Obtain the state of any thread.
* @param   thread_id   thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @retval  the stae of the thread, states are encoded by the osThreadState enumerated type.
*/
osThreadState osThreadGetState(osThreadId thread_id)
{
  eTaskState ThreadState;
  osThreadState result;
  
  ThreadState = eTaskGetState(thread_id);
  
  switch (ThreadState)
  {
  case eRunning :
    result = osThreadRunning;
    break;
  case eReady :
    result = osThreadReady;
    break;
  case eBlocked :
    result = osThreadBlocked;
    break;
  case eSuspended :
    result = osThreadSuspended;
    break;
  case eDeleted :
    result = osThreadDeleted;
    break;
  default:
    result = osThreadError;
  } 
  
  return result;
}
开发者ID:Casa2011,项目名称:devices,代码行数:35,代码来源:cmsis_os.c


示例7: print_task_info

void print_task_info(void) {
	print("\n\n===========Task Information===========\n");
	print("state consistency: %s\n", 
		check_task_state_consistency() ? "consistent": "!! INCONSISTENT TASK STATES !!");
	for (int task = 0; task < NUM_TASKS; task++) {
		eTaskState task_state = eTaskGetState(*(task_handles[task]));
		uint16_t stack_space_left = uxTaskGetStackHighWaterMark(*task_handles[task]) * sizeof(portSTACK_TYPE);
		uint16_t stack_size = get_task_stack_size(task);
		uint16_t stack_space_available = stack_size * sizeof(portSTACK_TYPE);
		// note watchdog task as checked out in sys test so it doesn't look like something's up
		bool checked_in = (task == WATCHDOG_TASK) ? false : _get_task_checked_in(task);
		uint32_t last_check_in = _get_task_checked_in_time(task);
		uint32_t task_freq = get_task_freq(task);
		
		print("%s: %s (%s) LRT: %5d (%3d%%) stack: %4d / %4d (%3d%%)\n", 
			get_task_str(task), 
			get_task_state_str(task_state),
			checked_in ? "checked in " : "checked out",
			checked_in ? (xTaskGetTickCount() - last_check_in) : 0,
			checked_in ? (100 * (xTaskGetTickCount() - last_check_in) / task_freq) : 0,
			stack_space_available - stack_space_left,
			stack_space_available,
			(100 * (stack_space_available - stack_space_left)) / stack_space_available);
	}
}
开发者ID:BrownCubeSat,项目名称:EQUiSat,代码行数:25,代码来源:rtos_system_test.c


示例8: xEventGroupSetBits

dispatch_queue::~dispatch_queue()
{
	BaseType_t status;

	// Signal to dispatch threads that it's time to wrap up
	quit_ = true;

	// We will join each thread to confirm exiting
	for (size_t i = 0; i < threads_.size(); ++i) {
		eTaskState state;

		do {
			// Signal wake - check exit flag
			xEventGroupSetBits(notify_flags_, DISPATCH_WAKE_EVT);

			// Wait until a thread signals exit. Timeout is acceptable.
			xEventGroupWaitBits(notify_flags_, DISPATCH_EXIT_EVT, pdTRUE, pdFALSE, 10);

			// If it was not thread_[i], that is ok, but we will loop around
			// until threads_[i] has exited
			state = eTaskGetState(threads_[i].thread);
		} while (state != eDeleted);

		threads_[i].name.clear();
	}

	// Cleanup event flags and mutex
	vEventGroupDelete(notify_flags_);

	vSemaphoreDelete(mutex_);
}
开发者ID:typelogic,项目名称:embedded-resources,代码行数:31,代码来源:dispatch_freertos.cpp


示例9: vButtonTask

void vButtonTask(void* pvParameters){

	xSemaphoreTake(xButtonSemaphore,buttonNO_BLOCK);
	for(;;){
		xSemaphoreTake(xButtonSemaphore, portMAX_DELAY);
		ulButtonPressCount++;
		xSemaphoreGive(xStatusSemaphore);
		if(eTaskGetState(xLedTaskHandle)== eBlocked || eTaskGetState(xLedTaskHandle)== eRunning ){
			vTaskSuspend(xLedTaskHandle);
		}
		else if(eTaskGetState(xLedTaskHandle)==eSuspended){
			vTaskResume(xLedTaskHandle);
		}

		vTaskDelay(500);
	}
}
开发者ID:jakubszlendak,项目名称:modbus_sensor,代码行数:17,代码来源:buttonTask.c


示例10: MPU_eTaskGetState

eTaskState MPU_eTaskGetState( TaskHandle_t pxTask )
{
    BaseType_t xRunningPrivileged = prvRaisePrivilege();
    eTaskState eReturn;

    eReturn = eTaskGetState( pxTask );
    portRESET_PRIVILEGE( xRunningPrivileged );
    return eReturn;
}
开发者ID:RitikaGupta1207,项目名称:freertos,代码行数:9,代码来源:port.c


示例11: MPU_eTaskGetState

	eTaskState MPU_eTaskGetState( xTaskHandle pxTask )
	{
    portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();
	eTaskState eReturn;

		eReturn = eTaskGetState( pxTask );
        portRESET_PRIVILEGE( xRunningPrivileged );
		return eReturn;
	}
开发者ID:451506709,项目名称:automated_machine,代码行数:9,代码来源:port.c


示例12: MPU_eTaskGetState

	eTaskState MPU_eTaskGetState( TaskHandle_t pxTask )
	{
	BaseType_t xRunningPrivileged = xPortRaisePrivilege();
	eTaskState eReturn;

		eReturn = eTaskGetState( pxTask );
		vPortResetPrivilege( xRunningPrivileged );
		return eReturn;
	}
开发者ID:sean93park,项目名称:freertos,代码行数:9,代码来源:mpu_wrappers.c


示例13: getName

void Task::start() {
    if (mTaskHandle == NULL) {
        debug::log("Creating task: " + getName());
        
        // get task name
        String taskName = getName();

        // start the task
        if (xTaskCreate(_task, taskName.c_str(), ( uint8_t ) 255, static_cast<void*>(this), 2, &mTaskHandle) != pdPASS) {
            debug::stopWithMessage("Failed to create " + getName() + " task");
        }
    } else if (eTaskGetState(mTaskHandle) == eSuspended) {
        debug::log("Resume task: " + getName());
        beforeResume();
        vTaskResume(mTaskHandle);
    }
}
开发者ID:Embedder74,项目名称:Mk2-Firmware,代码行数:17,代码来源:Task.cpp


示例14: metal_finish_threads

void metal_finish_threads(int threads, void *tids)
{
	int i;
	TaskHandle_t *tid_p = (TaskHandle_t *)tids;

	if (!tids) {
		metal_log(METAL_LOG_ERROR, "invalid argument, tids is NULL.\n");
		return;
	}

	for (i = 0; i < threads; i++) {
		eTaskState ts;
		do {
			taskYIELD();
			ts=eTaskGetState(tid_p[i]);
		} while (ts != eDeleted);
	}
}
开发者ID:Xilinx,项目名称:embeddedsw,代码行数:18,代码来源:threads.c


示例15: task_resume

// resumes the given task if it was suspended, and (always) checks it in to the watchdog
void task_resume(task_type_t task_id)
{
	TaskHandle_t* task_handle = task_handles[task_id];
	configASSERT(task_handle != NULL && *task_handle != NULL);

	// always check in for watchdog when called
	// (in case it wasn't, for example on BOOT)
	// this is only called here so doesn't need to be safe
	check_in_task_unsafe(task_id);

	if (task_handle != NULL && *task_handle != NULL
		&& eTaskGetState(*task_handle) == eSuspended)
	{
		// actually resume task (will be graceful if task_handle task is not actually suspended)
		vTaskResume(*task_handle);
	}
	// if task_handle or it's value was NULL, we're in for a watchdog reset
	// which is what we want because somethings very wrong
}
开发者ID:BrownCubeSat,项目名称:EQUiSat,代码行数:20,代码来源:satellite_state_control.c


示例16: task_suspend

// suspends the given task if it was not already suspended, and (always) checks it out of the watchdog
void task_suspend(task_type_t task_id) {
	TaskHandle_t* task_handle = task_handles[task_id];
	configASSERT(task_handle != NULL && *task_handle != NULL); // the latter would suspend THIS task

	configASSERT(task_id != BATTERY_CHARGING_TASK
				&& task_id != STATE_HANDLING_TASK 
				&& task_id != WATCHDOG_TASK 
				&& task_id != PERSISTENT_DATA_BACKUP_TASK);

	// always check out of watchdog when called (to be double-sure)
	// this is only called here so doesn't need to be safe
	check_out_task_unsafe(task_id);
	if (task_handle != NULL && *task_handle != NULL
		&& eTaskGetState(*task_handle) != eSuspended) 
	{
		// actually suspend using handle
		vTaskSuspend(*task_handle);
	}
	// if task_handle or it's value was NULL, we're in for a watchdog reset
	// which is what we want because somethings very wrong
}
开发者ID:BrownCubeSat,项目名称:EQUiSat,代码行数:22,代码来源:satellite_state_control.c


示例17: prvTakeAndGiveInTheOppositeOrder

static void prvTakeAndGiveInTheOppositeOrder( void )
{
    /* Ensure the slave is suspended, and that this task is running at the
    lower priority as expected as the start conditions. */
#if( INCLUDE_eTaskGetState == 1 )
    {
        configASSERT( eTaskGetState( xSlaveHandle ) == eSuspended );
    }
#endif /* INCLUDE_eTaskGetState */

    if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) {
        xErrorDetected = pdTRUE;
    }

    /* Take the semaphore that is shared with the slave. */
    if( xSemaphoreTake( xMasterSlaveMutex, intsemNO_BLOCK ) != pdPASS ) {
        xErrorDetected = pdTRUE;
    }

    /* This task now has the mutex.  Unsuspend the slave so it too
    attempts to take the mutex. */
    vTaskResume( xSlaveHandle );

    /* The slave has the higher priority so should now have executed and
    blocked on the semaphore. */
#if( INCLUDE_eTaskGetState == 1 )
    {
        configASSERT( eTaskGetState( xSlaveHandle ) == eBlocked );
    }
#endif /* INCLUDE_eTaskGetState */

    /* This task should now have inherited the priority of the slave
    task. */
    if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) {
        xErrorDetected = pdTRUE;
    }

    /* Now wait a little longer than the time between ISR gives to also
    obtain the ISR mutex. */
    xOkToGiveMutex = pdTRUE;
    if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS ) {
        xErrorDetected = pdTRUE;
    }
    xOkToGiveMutex = pdFALSE;

    /* Attempting to take again immediately should fail as the mutex is
    already held. */
    if( xSemaphoreTake( xISRMutex, intsemNO_BLOCK ) != pdFAIL ) {
        xErrorDetected = pdTRUE;
    }

    /* Should still be at the priority of the slave task. */
    if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) {
        xErrorDetected = pdTRUE;
    }

    /* Give back the shared semaphore to ensure the priority is not disinherited
    as the ISR mutex is still held.  The higher priority slave task should run
    before this task runs again. */
    if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS ) {
        xErrorDetected = pdTRUE;
    }

    /* Should still be at the priority of the slave task as this task still
    holds one semaphore (this is a simplification in the priority inheritance
    mechanism. */
    if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) {
        xErrorDetected = pdTRUE;
    }

    /* Give back the ISR semaphore, which should result in the priority being
    disinherited as it was the last mutex held. */
    if( xSemaphoreGive( xISRMutex ) != pdPASS ) {
        xErrorDetected = pdTRUE;
    }

    if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) {
        xErrorDetected = pdTRUE;
    }

    /* Reset the mutex ready for the next round. */
    xQueueReset( xISRMutex );
}
开发者ID:peterliu2,项目名称:tivaWare,代码行数:83,代码来源:IntSemTest.c


示例18: 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 )
		{
			#if( INCLUDE_eTaskGetState == 1 )
			{
				configASSERT( eTaskGetState( xControllingTaskHandle ) == eSuspended );
				configASSERT( eTaskGetState( xBlockingTaskHandle ) == eSuspended );
			}
			#endif /* INCLUDE_eTaskGetState */

			/* 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;
				}

				#if( INCLUDE_uxTaskPriorityGet == 1 )
				{
					/* Check priority inherited. */
					configASSERT( uxTaskPriorityGet( NULL ) == recmuCONTROLLING_TASK_PRIORITY );
				}
				#endif /* INCLUDE_uxTaskPriorityGet */

				#if( INCLUDE_eTaskGetState == 1 )
				{
					configASSERT( eTaskGetState( xControllingTaskHandle ) == eBlocked );
					configASSERT( eTaskGetState( xBlockingTaskHandle ) == eBlocked );
				}
				#endif /* INCLUDE_eTaskGetState */

				/* Release the mutex, disinheriting the higher priority again. */
				if( xSemaphoreGiveRecursive( xMutex ) != pdPASS )
				{
					xErrorOccurred = pdTRUE;
				}

				#if( INCLUDE_uxTaskPriorityGet == 1 )
				{
					/* Check priority disinherited. */
					configASSERT( uxTaskPriorityGet( NULL ) == recmuPOLLING_TASK_PRIORITY );
				}
				#endif /* INCLUDE_uxTaskPriorityGet */
			}
		}

		#if configUSE_PREEMPTION == 0
		{
			taskYIELD();
		}
		#endif
	}
}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:85,代码来源:recmutex.c


示例19: portTASK_FUNCTION

/*
 * Controller task as described above.
 */
static portTASK_FUNCTION( vCounterControlTask, pvParameters )
{
uint32_t ulLastCounter;
short sLoops;
short sError = pdFALSE;

	/* Just to stop warning messages. */
	( void ) pvParameters;

	for( ;; )
	{
		/* Start with the counter at zero. */
		ulCounter = ( uint32_t ) 0;

		/* First section : */

		/* Check the continuous count task is running. */
		for( sLoops = 0; sLoops < priLOOPS; sLoops++ )
		{
			/* Suspend the continuous count task so we can take a mirror of the
			shared variable without risk of corruption.  This is not really
			needed as the other task raises its priority above this task's
			priority. */
			vTaskSuspend( xContinuousIncrementHandle );
			{
				#if( INCLUDE_eTaskGetState == 1 )
				{
					configASSERT( eTaskGetState( xContinuousIncrementHandle ) == eSuspended );
				}
				#endif /* INCLUDE_eTaskGetState */

				ulLastCounter = ulCounter;
			}
			vTaskResume( xContinuousIncrementHandle );

			#if( configUSE_PREEMPTION == 0 )
				taskYIELD();
			#endif

			#if( INCLUDE_eTaskGetState == 1 )
			{
				configASSERT( eTaskGetState( xContinuousIncrementHandle ) == eReady );
			}
			#endif /* INCLUDE_eTaskGetState */

			/* Now delay to ensure the other task has processor time. */
			vTaskDelay( priSLEEP_TIME );

			/* Check the shared variable again.  This time to ensure mutual
			exclusion the whole scheduler will be locked.  This is just for
			demo purposes! */
			vTaskSuspendAll();
			{
				if( ulLastCounter == ulCounter )
				{
					/* The shared variable has not changed.  There is a problem
					with the continuous count task so flag an error. */
					sError = pdTRUE;
				}
			}
			xTaskResumeAll();
		}

		/* Second section: */

		/* Suspend the continuous counter task so it stops accessing the shared
		variable. */
		vTaskSuspend( xContinuousIncrementHandle );

		/* Reset the variable. */
		ulCounter = ( uint32_t ) 0;

		#if( INCLUDE_eTaskGetState == 1 )
		{
			configASSERT( eTaskGetState( xLimitedIncrementHandle ) == eSuspended );
		}
		#endif /* INCLUDE_eTaskGetState */

		/* Resume the limited count task which has a higher priority than us.
		We should therefore not return from this call until the limited count
		task has suspended itself with a known value in the counter variable. */
		vTaskResume( xLimitedIncrementHandle );

		#if( configUSE_PREEMPTION == 0 )
			taskYIELD();
		#endif

		/* This task should not run again until xLimitedIncrementHandle has
		suspended itself. */
		#if( INCLUDE_eTaskGetState == 1 )
		{
			configASSERT( eTaskGetState( xLimitedIncrementHandle ) == eSuspended );
		}
		#endif /* INCLUDE_eTaskGetState */

		/* Does the counter variable have the expected value? */
		if( ulCounter != priMAX_COUNT )
//.........这里部分代码省略.........
开发者ID:pcsrule,项目名称:zybo-audio,代码行数:101,代码来源:dynamic.c


示例20: prvTakeTwoMutexesReturnInSameOrder

static void prvTakeTwoMutexesReturnInSameOrder( SemaphoreHandle_t xMutex, SemaphoreHandle_t xLocalMutex )
{
	/* Take the mutex.  It should be available now. */
	if( xSemaphoreTake( xMutex, intsemNO_BLOCK ) != pdPASS )
	{
		xErrorDetected = pdTRUE;
	}

	/* Set the guarded variable to a known start value. */
	ulGuardedVariable = 0;

	/* This task's priority should be as per that assigned when the task was
	created. */
	if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )
	{
		xErrorDetected = pdTRUE;
	}

	/* Now unsuspend the high priority task.  This will attempt to take the
	mutex, and block when it finds it cannot obtain it. */
	vTaskResume( xHighPriorityMutexTask );

	#if configUSE_PREEMPTION == 0
		taskYIELD();
	#endif

	/* Ensure the task is reporting its priority as blocked and not
	suspended (as it would have done in versions up to V7.5.3). */
	#if( INCLUDE_eTaskGetState == 1 )
	{
		configASSERT( eTaskGetState( xHighPriorityMutexTask ) == eBlocked );
	}
	#endif /* INCLUDE_eTaskGetState */

	/* The priority of the high priority task should now have been inherited
	as by now it will have attempted to get the mutex. */
	if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )
	{
		xErrorDetected = pdTRUE;
	}

	/* Now unsuspend the medium priority task.  This should not run as the
	inherited priority of this task is above that of the medium priority
	task. */
	vTaskResume( xMediumPriorityMutexTask );

	/* If the medium priority task did run then it will have incremented the
	guarded variable. */
	if( ulGuardedVariable != 0 )
	{
		xErrorDetected = pdTRUE;
	}

	/* Take the local mutex too, so two mutexes are now held. */
	if( xSemaphoreTake( xLocalMutex, intsemNO_BLOCK ) != pdPASS )
	{
		xErrorDetected = pdTRUE;
	}

	/* When the local semaphore is given back the priority of this task should
	not	yet be disinherited because the shared mutex is still held.  This is a
	simplification to allow FreeRTOS to be integrated with middleware that
	attempts to hold multiple mutexes without bloating the code with complex
	algorithms.  It is possible that the high priority mutex task will
	execute as it shares a priority with this task. */
	if( xSemaphoreGive( xLocalMutex ) != pdPASS )
	{
		xErrorDetected = pdTRUE;
	}

	#if configUSE_PREEMPTION == 0
		taskYIELD();
	#endif

	/* The guarded variable is only incremented by the medium priority task,
	which still should not have executed as this task should remain at the
	higher priority, ensure this is the case. */
	if( ulGuardedVariable != 0 )
	{
		xErrorDetected = pdTRUE;
	}

	if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )
	{
		xErrorDetected = pdTRUE;
	}

	/* Now also give back the shared mutex, taking the held count back to 0.
	This time the priority of this task should be disinherited back to the
	priority at which it was created.  This means the medium priority task
	should execute and increment the guarded variable.  When this task next runs
	both the high and medium priority tasks will have been suspended again. */
	if( xSemaphoreGive( xMutex ) != pdPASS )
	{
		xErrorDetected = pdTRUE;
	}

	#if configUSE_PREEMPTION == 0
		taskYIELD();
	#endif
//.........这里部分代码省略.........
开发者ID:LukasWoodtli,项目名称:QFreeRTOS,代码行数:101,代码来源:GenQTest.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ eWarning函数代码示例发布时间:2022-05-30
下一篇:
C++ eTaskConfirmSleepModeStatus函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap