亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dynamic.c

?? 最新版FreeRTOS, 包擴多種開發平臺的移植
?? C
字號:
/*
	FreeRTOS.org V4.1.1 - Copyright (C) 2003-2006 Richard Barry.

	This file is part of the FreeRTOS.org distribution.

	FreeRTOS.org is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	FreeRTOS.org is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with FreeRTOS.org; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	A special exception to the GPL can be applied should you wish to distribute
	a combined work that includes FreeRTOS.org, without being obliged to provide
	the source code for any proprietary components.  See the licensing section 
	of http://www.FreeRTOS.org for full details of how and when the exception
	can be applied.

	***************************************************************************
	See http://www.FreeRTOS.org for documentation, latest information, license 
	and contact details.  Please ensure to read the configuration and relevant 
	port sections of the online documentation.
	***************************************************************************
*/

/*
 * The first test creates three tasks - two counter tasks (one continuous count 
 * and one limited count) and one controller.  A "count" variable is shared 
 * between all three tasks.  The two counter tasks should never be in a "ready" 
 * state at the same time.  The controller task runs at the same priority as 
 * the continuous count task, and at a lower priority than the limited count 
 * task.
 *
 * One counter task loops indefinitely, incrementing the shared count variable
 * on each iteration.  To ensure it has exclusive access to the variable it
 * raises it's priority above that of the controller task before each 
 * increment, lowering it again to it's original priority before starting the
 * next iteration.
 *
 * The other counter task increments the shared count variable on each
 * iteration of it's loop until the count has reached a limit of 0xff - at
 * which point it suspends itself.  It will not start a new loop until the 
 * controller task has made it "ready" again by calling vTaskResume ().  
 * This second counter task operates at a higher priority than controller 
 * task so does not need to worry about mutual exclusion of the counter 
 * variable.
 *
 * The controller task is in two sections.  The first section controls and
 * monitors the continuous count task.  When this section is operational the 
 * limited count task is suspended.  Likewise, the second section controls 
 * and monitors the limited count task.  When this section is operational the 
 * continuous count task is suspended.
 *
 * In the first section the controller task first takes a copy of the shared
 * count variable.  To ensure mutual exclusion on the count variable it
 * suspends the continuous count task, resuming it again when the copy has been
 * taken.  The controller task then sleeps for a fixed period - during which
 * the continuous count task will execute and increment the shared variable.
 * When the controller task wakes it checks that the continuous count task
 * has executed by comparing the copy of the shared variable with its current
 * value.  This time, to ensure mutual exclusion, the scheduler itself is 
 * suspended with a call to vTaskSuspendAll ().  This is for demonstration 
 * purposes only and is not a recommended technique due to its inefficiency.
 *
 * After a fixed number of iterations the controller task suspends the 
 * continuous count task, and moves on to its second section.
 *
 * At the start of the second section the shared variable is cleared to zero.
 * The limited count task is then woken from it's suspension by a call to
 * vTaskResume ().  As this counter task operates at a higher priority than
 * the controller task the controller task should not run again until the
 * shared variable has been counted up to the limited value causing the counter
 * task to suspend itself.  The next line after vTaskResume () is therefore
 * a check on the shared variable to ensure everything is as expected.
 *
 *
 * The second test consists of a couple of very simple tasks that post onto a 
 * queue while the scheduler is suspended.  This test was added to test parts
 * of the scheduler not exercised by the first test.
 *
 */

#include <stdlib.h>

/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

/* Demo app include files. */
#include "dynamic.h"

/* Function that implements the "limited count" task as described above. */
static portTASK_FUNCTION_PROTO( vLimitedIncrementTask, pvParameters );

/* Function that implements the "continuous count" task as described above. */
static portTASK_FUNCTION_PROTO( vContinuousIncrementTask, pvParameters );

/* Function that implements the controller task as described above. */
static portTASK_FUNCTION_PROTO( vCounterControlTask, pvParameters );

static portTASK_FUNCTION_PROTO( vQueueReceiveWhenSuspendedTask, pvParameters );
static portTASK_FUNCTION_PROTO( vQueueSendWhenSuspendedTask, pvParameters );

/* Demo task specific constants. */
#define priSTACK_SIZE				( ( unsigned portSHORT ) 128 )
#define priSLEEP_TIME				( ( portTickType ) 100 )
#define priLOOPS					( 5 )
#define priMAX_COUNT				( ( unsigned portLONG ) 0xff )
#define priNO_BLOCK					( ( portTickType ) 0 )
#define priSUSPENDED_QUEUE_LENGTH	( 1 )

/*-----------------------------------------------------------*/

/* Handles to the two counter tasks.  These could be passed in as parameters
to the controller task to prevent them having to be file scope. */
static xTaskHandle xContinousIncrementHandle, xLimitedIncrementHandle;

/* The shared counter variable.  This is passed in as a parameter to the two 
counter variables for demonstration purposes. */
static unsigned portLONG ulCounter;

/* Variables used to check that the tasks are still operating without error.
Each complete iteration of the controller task increments this variable
provided no errors have been found.  The variable maintaining the same value
is therefore indication of an error. */
static unsigned portSHORT usCheckVariable = ( unsigned portSHORT ) 0;
static portBASE_TYPE xSuspendedQueueSendError = pdFALSE;
static portBASE_TYPE xSuspendedQueueReceiveError = pdFALSE;

/* Queue used by the second test. */
xQueueHandle xSuspendedTestQueue;

/*-----------------------------------------------------------*/
/*
 * Start the three tasks as described at the top of the file.
 * Note that the limited count task is given a higher priority.
 */
void vStartDynamicPriorityTasks( void )
{
	xSuspendedTestQueue = xQueueCreate( priSUSPENDED_QUEUE_LENGTH, sizeof( unsigned portLONG ) );
	xTaskCreate( vContinuousIncrementTask, ( signed portCHAR * ) "CNT_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY, &xContinousIncrementHandle );
	xTaskCreate( vLimitedIncrementTask, ( signed portCHAR * ) "LIM_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY + 1, &xLimitedIncrementHandle );
	xTaskCreate( vCounterControlTask, ( signed portCHAR * ) "C_CTRL", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vQueueSendWhenSuspendedTask, ( signed portCHAR * ) "SUSP_TX", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vQueueReceiveWhenSuspendedTask, ( signed portCHAR * ) "SUSP_RX", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
}
/*-----------------------------------------------------------*/

/*
 * Just loops around incrementing the shared variable until the limit has been
 * reached.  Once the limit has been reached it suspends itself. 
 */
static portTASK_FUNCTION( vLimitedIncrementTask, pvParameters )
{
unsigned portLONG *pulCounter;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned portLONG * ) pvParameters;

	/* This will run before the control task, so the first thing it does is
	suspend - the control task will resume it when ready. */
	vTaskSuspend( NULL );

	for( ;; )
	{
		/* Just count up to a value then suspend. */
		( *pulCounter )++;	
		
		if( *pulCounter >= priMAX_COUNT )
		{
			vTaskSuspend( NULL );
		} 	
	}
}
/*-----------------------------------------------------------*/

/*
 * Just keep counting the shared variable up.  The control task will suspend
 * this task when it wants.
 */
static portTASK_FUNCTION( vContinuousIncrementTask, pvParameters )
{
unsigned portLONG *pulCounter;
unsigned portBASE_TYPE uxOurPriority;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned portLONG * ) pvParameters;

	/* Query our priority so we can raise it when exclusive access to the 
	shared variable is required. */
	uxOurPriority = uxTaskPriorityGet( NULL );

	for( ;; )
	{
		/* Raise our priority above the controller task to ensure a context
		switch does not occur while we are accessing this variable. */
		vTaskPrioritySet( NULL, uxOurPriority + 1 );
			( *pulCounter )++;		
		vTaskPrioritySet( NULL, uxOurPriority );
	}
}
/*-----------------------------------------------------------*/

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

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

	for( ;; )
	{
		/* Start with the counter at zero. */
		ulCounter = ( unsigned portLONG ) 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. */
			vTaskSuspend( xContinousIncrementHandle );
				ulLastCounter = ulCounter;
			vTaskResume( xContinousIncrementHandle );
			
			/* 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( xContinousIncrementHandle );

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

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

		/* Does the counter variable have the expected value? */
		if( ulCounter != priMAX_COUNT )
		{
			sError = pdTRUE;
		}

		if( sError == pdFALSE )
		{
			/* If no errors have occurred then increment the check variable. */
			portENTER_CRITICAL();
				usCheckVariable++;
			portEXIT_CRITICAL();
		}

		/* Resume the continuous count task and do it all again. */
		vTaskResume( xContinousIncrementHandle );
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vQueueSendWhenSuspendedTask, pvParameters )
{
static unsigned portLONG ulValueToSend = ( unsigned portLONG ) 0;

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

	for( ;; )
	{
		vTaskSuspendAll();
		{
			/* We must not block while the scheduler is suspended! */
			if( xQueueSend( xSuspendedTestQueue, ( void * ) &ulValueToSend, priNO_BLOCK ) != pdTRUE )
			{
				xSuspendedQueueSendError = pdTRUE;
			}
		}
		xTaskResumeAll();

		vTaskDelay( priSLEEP_TIME );

		++ulValueToSend;
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vQueueReceiveWhenSuspendedTask, pvParameters )
{
static unsigned portLONG ulExpectedValue = ( unsigned portLONG ) 0, ulReceivedValue;
portBASE_TYPE xGotValue;

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

	for( ;; )
	{
		do
		{
			/* Suspending the scheduler here is fairly pointless and 
			undesirable for a normal application.  It is done here purely
			to test the scheduler.  The inner xTaskResumeAll() should
			never return pdTRUE as the scheduler is still locked by the
			outer call. */
			vTaskSuspendAll();
			{
				vTaskSuspendAll();
				{
					xGotValue = xQueueReceive( xSuspendedTestQueue, ( void * ) &ulReceivedValue, priNO_BLOCK );
				}
				if( xTaskResumeAll() )
				{
					xSuspendedQueueReceiveError = pdTRUE;
				}
			}
			xTaskResumeAll();

		} while( xGotValue == pdFALSE );

		if( ulReceivedValue != ulExpectedValue )
		{
			xSuspendedQueueReceiveError = pdTRUE;
		}

		++ulExpectedValue;
	}
}
/*-----------------------------------------------------------*/

/* Called to check that all the created tasks are still running without error. */
portBASE_TYPE xAreDynamicPriorityTasksStillRunning( void )
{
/* Keep a history of the check variables so we know if it has been incremented 
since the last call. */
static unsigned portSHORT usLastTaskCheck = ( unsigned portSHORT ) 0;
portBASE_TYPE xReturn = pdTRUE;

	/* Check the tasks are still running by ensuring the check variable
	is still incrementing. */

	if( usCheckVariable == usLastTaskCheck )
	{
		/* The check has not incremented so an error exists. */
		xReturn = pdFALSE;
	}

	if( xSuspendedQueueSendError == pdTRUE )
	{
		xReturn = pdFALSE;
	}

	if( xSuspendedQueueReceiveError == pdTRUE )
	{
		xReturn = pdFALSE;
	}

	usLastTaskCheck = usCheckVariable;
	return xReturn;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
人人精品人人爱| 国产麻豆精品久久一二三| 五月婷婷激情综合| 精品一区二区三区久久| 色综合一区二区三区| 日韩网站在线看片你懂的| 亚洲天堂免费在线观看视频| 青青草精品视频| 色婷婷亚洲精品| 久久久国产一区二区三区四区小说| 亚洲精品高清在线观看| 大白屁股一区二区视频| 日韩一区二区麻豆国产| 一区二区三区免费观看| 成人网在线播放| 欧美精品一区二区三区很污很色的| 亚洲另类春色校园小说| 成人激情午夜影院| 精品国产91乱码一区二区三区| 亚洲成人动漫av| 91蜜桃视频在线| 亚洲国产精品av| 久久精品国产亚洲一区二区三区| 在线一区二区三区四区五区 | 亚洲色图欧洲色图婷婷| 韩国午夜理伦三级不卡影院| 欧美日本在线一区| 综合婷婷亚洲小说| 波多野结衣在线aⅴ中文字幕不卡| 欧美一级xxx| 日韩1区2区3区| 欧美日韩免费视频| 亚洲国产精品久久久久秋霞影院 | 夜夜揉揉日日人人青青一国产精品| 国内成人精品2018免费看| 欧美高清激情brazzers| 亚洲一区二区在线观看视频| 91在线视频播放| 亚洲欧美日韩在线不卡| 一本一本大道香蕉久在线精品| 国产精品三级电影| 成人福利视频在线看| 欧美国产乱子伦| 国产91富婆露脸刺激对白| 欧美激情在线一区二区| 国产高清在线观看免费不卡| 久久久久亚洲蜜桃| 国产成人av福利| 国产精品乱人伦| 91久久精品一区二区三| 亚洲成人av在线电影| 6080国产精品一区二区| 麻豆精品视频在线观看免费| 久久久天堂av| 97精品久久久久中文字幕| 伊人一区二区三区| 337p亚洲精品色噜噜| 久久99精品久久久| 中文一区在线播放| 在线精品国精品国产尤物884a | 欧美国产一区视频在线观看| youjizz久久| 亚洲成av人片在线观看| 精品欧美一区二区三区精品久久| 国产精品一区二区久激情瑜伽| 国产精品久久久久久久久图文区 | 亚洲综合无码一区二区| 欧美视频日韩视频在线观看| 精品午夜一区二区三区在线观看 | 欧美刺激脚交jootjob| 成人性视频网站| 亚洲国产欧美另类丝袜| 欧美精品一区二区三区蜜臀| 色94色欧美sute亚洲线路一ni | 亚洲高清免费观看高清完整版在线观看 | 中文字幕欧美日本乱码一线二线| 91国偷自产一区二区三区成为亚洲经典| 亚洲福利一区二区| 中文字幕乱码一区二区免费| 欧美日韩成人一区二区| 成人黄色片在线观看| 日韩精品免费视频人成| 国产精品理伦片| 欧美刺激午夜性久久久久久久| 色综合中文字幕国产 | 亚洲精品亚洲人成人网| 精品日韩一区二区三区| 色婷婷av一区二区三区gif| 极品美女销魂一区二区三区| 亚洲欧美国产毛片在线| 久久久久免费观看| 日韩视频不卡中文| 欧美性视频一区二区三区| 国产高清一区日本| 久久66热re国产| 亚洲高清免费一级二级三级| 国产精品白丝在线| 国产欧美一区二区三区鸳鸯浴 | 欧美午夜电影在线播放| 成人午夜激情影院| 激情成人综合网| 秋霞电影一区二区| 午夜精品爽啪视频| 亚洲小少妇裸体bbw| 国产精品久久久久久久久免费桃花 | 国产精品免费视频网站| 2021国产精品久久精品| 在线播放欧美女士性生活| 91久久精品一区二区| 91同城在线观看| 成人国产精品免费网站| 成人精品亚洲人成在线| 国产精品69毛片高清亚洲| 国产乱国产乱300精品| 九九视频精品免费| 韩国毛片一区二区三区| 久久99精品国产.久久久久久 | 2023国产精华国产精品| 欧美成人三级在线| 亚洲精品在线电影| wwwwxxxxx欧美| 久久一二三国产| 精品国产91久久久久久久妲己| 欧美大片拔萝卜| 久久久久亚洲蜜桃| 国产色爱av资源综合区| 国产精品高潮久久久久无| 日本一区二区在线不卡| 国产精品麻豆欧美日韩ww| 亚洲欧洲国产日韩| 亚洲免费观看视频| 亚洲v精品v日韩v欧美v专区| 奇米888四色在线精品| 久久国内精品自在自线400部| 精品夜夜嗨av一区二区三区| 国产不卡视频在线播放| 成人久久视频在线观看| 一本色道久久综合亚洲精品按摩| 欧美在线小视频| 欧美区视频在线观看| 日韩亚洲电影在线| 国产欧美一区二区精品仙草咪| 亚洲欧洲国产日本综合| 亚洲成人av在线电影| 激情文学综合插| www.日本不卡| 欧美精品在线观看播放| 欧美va亚洲va| 亚洲欧洲日产国码二区| 亚洲超碰精品一区二区| 国产精品77777竹菊影视小说| 一本色道**综合亚洲精品蜜桃冫| 欧美一区三区四区| 中文字幕第一区第二区| 天天影视色香欲综合网老头| 国产精品一区二区在线看| 在线观看视频91| 国产午夜精品久久| 亚洲福利一区二区| 成人三级在线视频| 欧美日韩一级大片网址| 欧美高清在线一区| 天天综合色天天综合| av电影在线观看一区| 日韩限制级电影在线观看| 亚洲人亚洲人成电影网站色| 日韩电影免费在线| 99久久综合精品| 日韩欧美黄色影院| 亚洲午夜成aⅴ人片| 国产999精品久久| 欧美日韩高清一区二区三区| 国产精品高潮呻吟| 国产综合成人久久大片91| 在线观看成人免费视频| 国产日韩欧美亚洲| 久久精品999| 91麻豆精品国产91久久久资源速度 | 自拍偷拍欧美激情| 久草热8精品视频在线观看| 在线免费av一区| 1000精品久久久久久久久| 九一九一国产精品| 欧美一级高清大全免费观看| 亚洲一二三四久久| 91在线观看高清| 国产欧美一区二区精品性色| 久久99精品久久久久久国产越南 | 日韩中文字幕区一区有砖一区| 99在线精品观看| 国产欧美精品一区aⅴ影院| 国产自产v一区二区三区c| 91精品国产美女浴室洗澡无遮挡| 夜夜精品视频一区二区| 一本久久精品一区二区| 亚洲人吸女人奶水| 91同城在线观看| 亚洲欧美福利一区二区| 91丨九色丨尤物| 一区二区高清免费观看影视大全|