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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? blocktim.c

?? 最新版FreeRTOS, 包擴(kuò)多種開(kāi)發(fā)平臺(tái)的移植
?? C
字號(hào):
/*
	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.
	***************************************************************************
*/

/*
 * This file contains some test scenarios that ensure tasks do not exit queue
 * send or receive functions prematurely.  A description of the tests is 
 * included within the code.
 */

/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

/* Task priorities. */
#define bktPRIMARY_PRIORITY			( 3 )
#define bktSECONDARY_PRIORITY		( 2 )

/* Task behaviour. */
#define bktQUEUE_LENGTH				( 5 )
#define bktSHORT_WAIT				( ( ( portTickType ) 20 ) / portTICK_RATE_MS )
#define bktPRIMARY_BLOCK_TIME		( 10 )
#define bktALLOWABLE_MARGIN			( 12 )
#define bktTIME_TO_BLOCK			( 175 )
#define bktDONT_BLOCK				( ( portTickType ) 0 )
#define bktRUN_INDICATOR			( ( unsigned portBASE_TYPE ) 0x55 )

/* The queue on which the tasks block. */
static xQueueHandle xTestQueue;

/* Handle to the secondary task is required by the primary task for calls
to vTaskSuspend/Resume(). */
static xTaskHandle xSecondary;

/* Used to ensure that tasks are still executing without error. */
static portBASE_TYPE xPrimaryCycles = 0, xSecondaryCycles = 0;
static portBASE_TYPE xErrorOccurred = pdFALSE;

/* Provides a simple mechanism for the primary task to know when the 
secondary task has executed. */
static volatile unsigned portBASE_TYPE xRunIndicator;

/* The two test tasks.  Their behaviour is commented within the files. */
static void vPrimaryBlockTimeTestTask( void *pvParameters );
static void vSecondaryBlockTimeTestTask( void *pvParameters );

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

void vCreateBlockTimeTasks( void )
{
	/* Create the queue on which the two tasks block. */
    xTestQueue = xQueueCreate( bktQUEUE_LENGTH, sizeof( portBASE_TYPE ) );

	/* Create the two test tasks. */
	xTaskCreate( vPrimaryBlockTimeTestTask, "BTest1", configMINIMAL_STACK_SIZE, NULL, bktPRIMARY_PRIORITY, NULL );
	xTaskCreate( vSecondaryBlockTimeTestTask, "BTest2", configMINIMAL_STACK_SIZE, NULL, bktSECONDARY_PRIORITY, &xSecondary );
}
/*-----------------------------------------------------------*/

static void vPrimaryBlockTimeTestTask( void *pvParameters )
{
portBASE_TYPE xItem, xData;
portTickType xTimeWhenBlocking;
portTickType xTimeToBlock, xBlockedTime;

	for( ;; )
	{
		/*********************************************************************
        Test 1

        Simple block time wakeup test on queue receives. */
		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			/* The queue is empty. Attempt to read from the queue using a block
			time.  When we wake, ensure the delta in time is as expected. */
			xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem;

			/* A critical section is used to minimise the jitter in the time
			measurements. */
			portENTER_CRITICAL();
			{
				xTimeWhenBlocking = xTaskGetTickCount();
				
				/* We should unblock after xTimeToBlock having not received
				anything on the queue. */
				if( xQueueReceive( xTestQueue, &xData, xTimeToBlock ) != errQUEUE_EMPTY )
				{
					xErrorOccurred = pdTRUE;
				}

				/* How long were we blocked for? */
				xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;
			}
			portEXIT_CRITICAL();

			if( xBlockedTime < xTimeToBlock ) 
			{
				/* Should not have blocked for less than we requested. */
				xErrorOccurred = pdTRUE;
			}

			if( xBlockedTime > ( xTimeToBlock + bktALLOWABLE_MARGIN ) )
			{
				/* Should not have blocked for longer than we requested,
				although we would not necessarily run as soon as we were 
				unblocked so a margin is allowed. */
				xErrorOccurred = pdTRUE;
			}
		}

		/*********************************************************************
        Test 2

        Simple block time wakeup test on queue sends.

		First fill the queue.  It should be empty so all sends should pass. */
		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}
		}

		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			/* The queue is full. Attempt to write to the queue using a block
			time.  When we wake, ensure the delta in time is as expected. */
			xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem;

			portENTER_CRITICAL();
			{
				xTimeWhenBlocking = xTaskGetTickCount();
				
				/* We should unblock after xTimeToBlock having not received
				anything on the queue. */
				if( xQueueSend( xTestQueue, &xItem, xTimeToBlock ) != errQUEUE_FULL )
				{
					xErrorOccurred = pdTRUE;
				}

				/* How long were we blocked for? */
				xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;
			}
			portEXIT_CRITICAL();

			if( xBlockedTime < xTimeToBlock ) 
			{
				/* Should not have blocked for less than we requested. */
				xErrorOccurred = pdTRUE;
			}

			if( xBlockedTime > ( xTimeToBlock + bktALLOWABLE_MARGIN ) )
			{
				/* Should not have blocked for longer than we requested,
				although we would not necessarily run as soon as we were 
				unblocked so a margin is allowed. */
				xErrorOccurred = pdTRUE;
			}
		}

		
		/*********************************************************************
        Test 3

		Wake the other task, it will block attempting to post to the queue.
		When we read from the queue the other task will wake, but before it
		can run we will post to the queue again.  When the other task runs it
		will find the queue still full, even though it was woken.  It should
		recognise that its block time has not expired and return to block for
		the remains of its block time.

		Wake the other task so it blocks attempting to post to the already
		full queue. */
		xRunIndicator = 0;
		vTaskResume( xSecondary );

		/* We need to wait a little to ensure the other task executes. */
		while( xRunIndicator != bktRUN_INDICATOR )
		{
			/* The other task has not yet executed. */
			vTaskDelay( bktSHORT_WAIT );
		}
		/* Make sure the other task is blocked on the queue. */
		vTaskDelay( bktSHORT_WAIT );
		xRunIndicator = 0;

		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			/* Now when we make space on the queue the other task should wake
			but not execute as this task has higher priority. */				
			if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}

			/* Now fill the queue again before the other task gets a chance to
			execute.  If the other task had executed we would find the queue 
			full ourselves, and the other task have set xRunIndicator. */
			if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}

			if( xRunIndicator == bktRUN_INDICATOR )
			{
				/* The other task should not have executed. */
				xErrorOccurred = pdTRUE;
			}

			/* Raise the priority of the other task so it executes and blocks
			on the queue again. */
			vTaskPrioritySet( xSecondary, bktPRIMARY_PRIORITY + 2 );

			/* The other task should now have re-blocked without exiting the
			queue function. */
			if( xRunIndicator == bktRUN_INDICATOR )
			{
				/* The other task should not have executed outside of the
				queue function. */
				xErrorOccurred = pdTRUE;
			}

			/* Set the priority back down. */
			vTaskPrioritySet( xSecondary, bktSECONDARY_PRIORITY );			
		}

		/* Let the other task timeout.  When it unblockes it will check that it
		unblocked at the correct time, then suspend itself. */
		while( xRunIndicator != bktRUN_INDICATOR )
		{
			vTaskDelay( bktSHORT_WAIT );
		}
		vTaskDelay( bktSHORT_WAIT );
		xRunIndicator = 0;


		/*********************************************************************
        Test 4

		As per test 3 - but with the send and receive the other way around.  
		The other task blocks attempting to read from the queue.

		Empty the queue.  We should find that it is full. */
		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}
		}
		
		/* Wake the other task so it blocks attempting to read from  the 
		already	empty queue. */
		vTaskResume( xSecondary );

		/* We need to wait a little to ensure the other task executes. */
		while( xRunIndicator != bktRUN_INDICATOR )
		{
			vTaskDelay( bktSHORT_WAIT );
		}
		vTaskDelay( bktSHORT_WAIT );
		xRunIndicator = 0;

		for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ )
		{
			/* Now when we place an item on the queue the other task should 
			wake but not execute as this task has higher priority. */				
			if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}

			/* Now empty the queue again before the other task gets a chance to
			execute.  If the other task had executed we would find the queue 
			empty ourselves, and the other task would be suspended. */
			if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS )
			{
				xErrorOccurred = pdTRUE;
			}

			if( xRunIndicator == bktRUN_INDICATOR )
			{
				/* The other task should not have executed. */
				xErrorOccurred = pdTRUE;
			}

			/* Raise the priority of the other task so it executes and blocks
			on the queue again. */
			vTaskPrioritySet( xSecondary, bktPRIMARY_PRIORITY + 2 );

			/* The other task should now have re-blocked without exiting the 
			queue function. */
			if( xRunIndicator == bktRUN_INDICATOR )
			{
				/* The other task should not have executed outside of the
				queue function. */
				xErrorOccurred = pdTRUE;
			}
			vTaskPrioritySet( xSecondary, bktSECONDARY_PRIORITY );			
		}

		/* Let the other task timeout.  When it unblockes it will check that it
		unblocked at the correct time, then suspend itself. */
		while( xRunIndicator != bktRUN_INDICATOR )
		{
			vTaskDelay( bktSHORT_WAIT );
		}
		vTaskDelay( bktSHORT_WAIT );

		xPrimaryCycles++;
	}
}
/*-----------------------------------------------------------*/

static void vSecondaryBlockTimeTestTask( void *pvParameters )
{
portTickType xTimeWhenBlocking, xBlockedTime;
portBASE_TYPE xData;

	for( ;; )
	{
		/*********************************************************************
        Test 1 and 2

		This task does does not participate in these tests. */
		vTaskSuspend( NULL );

		/*********************************************************************
        Test 3

		The first thing we do is attempt to read from the queue.  It should be
		full so we block.  Note the time before we block so we can check the
		wake time is as per that expected. */
		portENTER_CRITICAL();
		{
			xTimeWhenBlocking = xTaskGetTickCount();
			
			/* We should unblock after bktTIME_TO_BLOCK having not received
			anything on the queue. */
			xData = 0;
			xRunIndicator = bktRUN_INDICATOR;
			if( xQueueSend( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL )
			{
				xErrorOccurred = pdTRUE;
			}

			/* How long were we inside the send function? */
			xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;
		}
		portEXIT_CRITICAL();

		/* We should not have blocked for less time than bktTIME_TO_BLOCK. */
		if( xBlockedTime < bktTIME_TO_BLOCK )
		{
			xErrorOccurred = pdTRUE;
		}

		/* We should of not blocked for much longer than bktALLOWABLE_MARGIN 
		either.  A margin is permitted as we would not necessarily run as
		soon as we unblocked. */
		if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) )
		{
			xErrorOccurred = pdTRUE;
		}

		/* Suspend ready for test 3. */
		xRunIndicator = bktRUN_INDICATOR;
		vTaskSuspend( NULL );

		/*********************************************************************
        Test 4

		As per test three, but with the send and receive reversed. */
		portENTER_CRITICAL();
		{
			xTimeWhenBlocking = xTaskGetTickCount();
			
			/* We should unblock after bktTIME_TO_BLOCK having not received
			anything on the queue. */
			xRunIndicator = bktRUN_INDICATOR;
			if( xQueueReceive( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_EMPTY )
			{
				xErrorOccurred = pdTRUE;
			}

			xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;
		}
		portEXIT_CRITICAL();

		/* We should not have blocked for less time than bktTIME_TO_BLOCK. */
		if( xBlockedTime < bktTIME_TO_BLOCK )
		{
			xErrorOccurred = pdTRUE;
		}

		/* We should of not blocked for much longer than bktALLOWABLE_MARGIN 
		either.  A margin is permitted as we would not necessarily run as soon
		as we unblocked. */
		if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) )
		{
			xErrorOccurred = pdTRUE;
		}

		xRunIndicator = bktRUN_INDICATOR;

		xSecondaryCycles++;
	}
}
/*-----------------------------------------------------------*/

portBASE_TYPE xAreBlockTimeTestTasksStillRunning( void )
{
static portBASE_TYPE xLastPrimaryCycleCount = 0, xLastSecondaryCycleCount = 0;
portBASE_TYPE xReturn = pdPASS;

	/* Have both tasks performed at least one cycle since this function was
	last called? */
	if( xPrimaryCycles == xLastPrimaryCycleCount )
	{
		xReturn = pdFAIL;
	}

	if( xSecondaryCycles == xLastSecondaryCycleCount )
	{
		xReturn = pdFAIL;
	}

	if( xErrorOccurred == pdTRUE )
	{
		xReturn = pdFAIL;
	}

	xLastSecondaryCycleCount = xSecondaryCycles;
	xLastPrimaryCycleCount = xPrimaryCycles;

	return xReturn;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费不卡在线视频| 日韩女优av电影| 色综合天天在线| 99久久99久久精品免费看蜜桃| 国产精品一品二品| 国产精品亚洲第一区在线暖暖韩国| 久久99精品国产.久久久久久| 日韩国产精品91| 捆绑变态av一区二区三区| 久久国产尿小便嘘嘘| 狠狠色丁香久久婷婷综| 国产成人综合自拍| 成人a级免费电影| 99re这里只有精品视频首页| 在线观看91视频| 欧美一区二区三区小说| 精品国产99国产精品| 国产午夜三级一区二区三| 国产精品久久久久天堂| 亚洲一区二区影院| 视频精品一区二区| 国产一区二区剧情av在线| 成a人片国产精品| 欧美午夜电影在线播放| 日韩欧美另类在线| 国产精品久久久久一区| 一区二区三区日韩欧美精品| 日韩成人一级大片| 国产成人精品一区二区三区网站观看| 成av人片一区二区| 欧美久久久久免费| 久久久久久久久岛国免费| 自拍偷拍亚洲激情| 亚洲国产成人高清精品| 国产精品一区一区| 欧美网站大全在线观看| 精品国产免费人成在线观看| 国产精品灌醉下药二区| 午夜精彩视频在线观看不卡| 精久久久久久久久久久| 91在线视频在线| 欧美一区二区视频观看视频| 国产欧美一区二区三区沐欲| 一区二区免费视频| 国产在线视频一区二区| 欧美亚洲丝袜传媒另类| 久久女同精品一区二区| 亚洲狠狠爱一区二区三区| 国产在线播放一区三区四| 91久久奴性调教| 久久午夜免费电影| 亚洲成a人片综合在线| 成人毛片视频在线观看| 91精品国产综合久久精品麻豆| 中文字幕 久热精品 视频在线 | 国产精品系列在线| 亚洲午夜精品在线| 国产福利视频一区二区三区| 欧美日韩成人一区| 国产精品久久久久久久久久久免费看 | 99精品视频在线观看免费| 欧美日韩国产美女| 亚洲欧洲韩国日本视频| 九九久久精品视频| 欧美在线三级电影| 国产精品久久久久婷婷二区次| 久久爱另类一区二区小说| 欧美午夜视频网站| 亚洲视频在线观看三级| 国产高清不卡一区| 日韩精品一区二区三区swag| 亚洲va国产va欧美va观看| 白白色亚洲国产精品| 精品国产乱码久久久久久久| 午夜精品久久久久久久久久久| av电影在线观看一区| 久久免费电影网| 久草这里只有精品视频| 69堂精品视频| 亚洲一区在线观看视频| 色一情一乱一乱一91av| 中国色在线观看另类| 国产精品996| 精品毛片乱码1区2区3区| 日韩和欧美一区二区| 欧美色国产精品| 亚洲自拍偷拍综合| 91年精品国产| 最近日韩中文字幕| 成人黄色片在线观看| 欧美国产丝袜视频| 成人午夜激情在线| 国产亚洲福利社区一区| 国产传媒久久文化传媒| 国产亚洲欧美色| 国产精品99久久久久久似苏梦涵| 久久伊人中文字幕| 国产九色精品成人porny| 久久一留热品黄| 国产精品一区二区91| 久久品道一品道久久精品| 国产精品一区二区视频| 久久精品免费在线观看| 国产福利精品一区二区| 国产精品人妖ts系列视频| 岛国av在线一区| 国产校园另类小说区| 成人影视亚洲图片在线| 国产精品毛片久久久久久久| 99视频精品全部免费在线| 亚洲欧美成aⅴ人在线观看| 色婷婷久久久亚洲一区二区三区| 亚洲一级电影视频| 欧美一级一级性生活免费录像| 麻豆免费看一区二区三区| xfplay精品久久| 国产成人av福利| 成人免费在线视频观看| 91激情在线视频| 日韩国产一二三区| 久久婷婷综合激情| kk眼镜猥琐国模调教系列一区二区| 亚洲视频一区二区免费在线观看| 日本道免费精品一区二区三区| 亚洲成av人片在www色猫咪| 欧美电影免费观看高清完整版在| 国产精品影音先锋| 亚洲色图19p| 欧美三级日韩三级| 黑人精品欧美一区二区蜜桃| 中文字幕一区二区三区精华液| 欧美优质美女网站| 精品一区二区在线看| 亚洲欧洲99久久| 欧美肥妇毛茸茸| 国产91综合一区在线观看| 亚洲精品国产成人久久av盗摄| 欧美一区二区三区日韩| 国产91精品一区二区麻豆网站| ㊣最新国产の精品bt伙计久久| 欧美体内she精高潮| 激情五月播播久久久精品| 最新欧美精品一区二区三区| 欧美一级二级在线观看| 成人午夜大片免费观看| 日韩电影在线看| 国产精品日日摸夜夜摸av| 宅男噜噜噜66一区二区66| 国产电影一区二区三区| 亚洲午夜一二三区视频| 国产欧美一区二区三区在线老狼| 欧美中文字幕一区| 国产精品69久久久久水密桃| 亚洲一区日韩精品中文字幕| 国产欧美一区视频| 欧美一区二区在线免费观看| 成人av免费观看| 日本美女一区二区三区| 亚洲欧洲精品天堂一级| 精品国产自在久精品国产| 91国偷自产一区二区三区观看 | 91啪亚洲精品| 国内精品免费**视频| 亚洲电影一级黄| 欧美国产日韩亚洲一区| 欧美一级欧美一级在线播放| 99精品欧美一区二区蜜桃免费 | xf在线a精品一区二区视频网站| 在线区一区二视频| 成人午夜碰碰视频| 蜜臀精品一区二区三区在线观看 | 99国产欧美久久久精品| 国产一区欧美二区| 热久久免费视频| 亚洲国产精品久久人人爱 | 91在线视频18| 国产成人综合亚洲网站| 久久国产婷婷国产香蕉| 午夜欧美大尺度福利影院在线看| 一区精品在线播放| 欧美极品美女视频| 精品国产三级a在线观看| 欧美情侣在线播放| 在线观看三级视频欧美| heyzo一本久久综合| 国产精品1区二区.| 国产精品一区二区三区乱码| 极品尤物av久久免费看| 琪琪一区二区三区| 天涯成人国产亚洲精品一区av| 亚洲精品中文字幕在线观看| 椎名由奈av一区二区三区| 亚洲国产精品成人综合色在线婷婷 | 欧美熟乱第一页| 日本韩国一区二区| 色欧美88888久久久久久影院| jiyouzz国产精品久久| 成人精品亚洲人成在线| 成人av电影在线网| 不卡的av网站|