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

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

?? dynamic.c

?? Este é um rtos free para a familia arm7
?? C
字號:
/*
	FreeRTOS V4.0.0 - Copyright (C) 2003-2006 Richard Barry.

	This file is part of the FreeRTOS distribution.

	FreeRTOS 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 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; 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, 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 ) 50 )
#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一区二区三区免费野_久草精品视频
国产盗摄一区二区| 欧美性受极品xxxx喷水| 欧美日韩一卡二卡三卡| 久久九九影视网| 久久66热偷产精品| 欧美二区在线观看| 免费观看久久久4p| 日韩一二三四区| 久久国产精品99精品国产 | 亚洲亚洲人成综合网络| 欧美性生活一区| 中文字幕一区二区日韩精品绯色| 精品一区二区三区久久| 久久先锋影音av| 大胆欧美人体老妇| 欧美高清在线视频| 日本高清不卡aⅴ免费网站| 亚洲少妇中出一区| 欧美丰满高潮xxxx喷水动漫| 日韩在线a电影| 久久精品亚洲精品国产欧美 | 高清av一区二区| 一区免费观看视频| 欧美老女人第四色| 国产精品538一区二区在线| 亚洲国产成人午夜在线一区| 色综合久久久久综合| 午夜激情综合网| 国产三级一区二区| 欧美体内she精视频| 国产毛片精品视频| 亚洲电影激情视频网站| 久久久精品日韩欧美| 欧美体内she精视频| av在线不卡电影| 麻豆精品在线播放| 亚洲国产综合色| 久久久欧美精品sm网站| 欧美人妖巨大在线| 粉嫩av一区二区三区| 美女视频免费一区| 亚洲免费高清视频在线| 久久蜜桃av一区二区天堂| 日本丶国产丶欧美色综合| 国产传媒欧美日韩成人| 久久精品国产亚洲a| 日韩黄色免费网站| 亚洲国产视频直播| 亚洲日本欧美天堂| 国产精品无圣光一区二区| 欧美变态tickling挠脚心| 欧美中文字幕亚洲一区二区va在线| 国产高清精品网站| 国产成人综合视频| 国产精品夜夜爽| 国产suv精品一区二区6| 国内成人免费视频| 国产99精品国产| av在线不卡免费看| 中文字幕日韩av资源站| 久久久一区二区三区捆绑**| 欧美精品一区男女天堂| 精品国产sm最大网站免费看| 久久一区二区三区四区| 久久久久国产一区二区三区四区| 国产日韩欧美激情| 国产精品久久久久久亚洲伦| 亚洲桃色在线一区| 亚洲国产精品久久人人爱| 日本aⅴ免费视频一区二区三区| 日韩视频在线永久播放| 99久久久精品| 东方aⅴ免费观看久久av| va亚洲va日韩不卡在线观看| 色老综合老女人久久久| 日韩无一区二区| 亚洲视频在线观看三级| 天天爽夜夜爽夜夜爽精品视频| 麻豆成人av在线| 91蝌蚪porny九色| 精品三级av在线| 一级日本不卡的影视| 青青草成人在线观看| eeuss鲁片一区二区三区 | 国产在线国偷精品产拍免费yy| 不卡欧美aaaaa| wwwwxxxxx欧美| 性欧美大战久久久久久久久| 成人午夜免费视频| 日韩午夜激情电影| 图片区小说区国产精品视频| 成人a免费在线看| 国产亚洲综合在线| 日韩在线一区二区| 欧美视频在线不卡| 亚洲激情图片qvod| av在线这里只有精品| 久久久五月婷婷| 麻豆91免费观看| 欧美一区二区三区视频在线观看 | 精品一区二区av| 日韩视频一区二区三区| 日本伊人色综合网| 91精品在线免费观看| 日本视频免费一区| 日韩一区二区在线看片| 免费不卡在线视频| 日韩欧美成人午夜| 国内精品伊人久久久久av影院 | 丝袜脚交一区二区| 337p亚洲精品色噜噜狠狠| 青青草91视频| 欧美精品一区二区不卡| 国产成人在线观看免费网站| 国产精品麻豆久久久| 在线一区二区三区| 久久99最新地址| 国产精品色呦呦| 在线观看国产精品网站| 日本成人在线网站| 日本一区二区三区在线不卡| 在线亚洲一区二区| 美国十次综合导航| 亚洲视频一二区| 日韩一级黄色大片| 99综合电影在线视频| 三级不卡在线观看| 欧美国产日韩亚洲一区| 9191国产精品| 国产v综合v亚洲欧| 伦理电影国产精品| 亚洲黄色免费网站| 国产日韩精品一区二区浪潮av| 欧洲一区二区三区在线| 国产精品原创巨作av| 视频一区视频二区中文| 国产精品久久久久aaaa| wwwwxxxxx欧美| 欧美一区二区三区小说| 欧美三级资源在线| 色88888久久久久久影院按摩 | 日韩成人dvd| 亚洲综合在线五月| 国产精品麻豆久久久| 久久久精品综合| 欧美mv日韩mv亚洲| 欧美一级二级三级蜜桃| 欧美性欧美巨大黑白大战| 91麻豆国产自产在线观看| 97久久超碰精品国产| 国产99精品国产| 成人app网站| 91丝袜美腿高跟国产极品老师| 成人教育av在线| 成人精品亚洲人成在线| 成人av手机在线观看| 成人精品gif动图一区| 波多野结衣的一区二区三区| 99久久免费视频.com| 91免费版在线| 欧美性猛交xxxx黑人交| 欧美无砖专区一中文字| 欧美福利视频导航| 日韩免费看网站| 国产色综合一区| 自拍偷拍亚洲激情| 五月婷婷激情综合网| 免费欧美在线视频| 奇米在线7777在线精品| 亚洲精品在线观看视频| 99久久免费精品高清特色大片| 色综合网色综合| 欧美一区二区三区免费视频| 国产欧美一区二区在线| 亚洲免费电影在线| 久久精品国产亚洲a| 99精品久久免费看蜜臀剧情介绍| 欧美日韩国产高清一区| 久久精品视频在线免费观看| 中文字幕一区av| 蜜桃91丨九色丨蝌蚪91桃色| 成人深夜在线观看| 欧美三级欧美一级| 国产精品久久久久三级| 久草这里只有精品视频| 在线区一区二视频| 国产日产亚洲精品系列| 日本午夜精品视频在线观看| 在线视频国内自拍亚洲视频| 精品国产91亚洲一区二区三区婷婷| 亚洲九九爱视频| 成人高清视频在线观看| 久久综合色婷婷| 久久99精品一区二区三区| 欧美老女人在线| 亚洲一区二区欧美| 欧美日韩一级二级三级| 亚洲一区二区黄色| 欧美午夜精品理论片a级按摩| 国产精品人妖ts系列视频 |