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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? blockq.c

?? 最新版FreeRTOS, 包擴(kuò)多種開發(fā)平臺的移植
?? 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.
	***************************************************************************
*/

/*
 * Creates six tasks that operate on three queues as follows:
 *
 * The first two tasks send and receive an incrementing number to/from a queue.
 * One task acts as a producer and the other as the consumer.  The consumer is a
 * higher priority than the producer and is set to block on queue reads.  The queue
 * only has space for one item - as soon as the producer posts a message on the
 * queue the consumer will unblock, pre-empt the producer, and remove the item.
 *
 * The second two tasks work the other way around.  Again the queue used only has
 * enough space for one item.  This time the consumer has a lower priority than the
 * producer.  The producer will try to post on the queue blocking when the queue is
 * full.  When the consumer wakes it will remove the item from the queue, causing
 * the producer to unblock, pre-empt the consumer, and immediately re-fill the
 * queue.
 *
 * The last two tasks use the same queue producer and consumer functions.  This time the queue has
 * enough space for lots of items and the tasks operate at the same priority.  The
 * producer will execute, placing items into the queue.  The consumer will start
 * executing when either the queue becomes full (causing the producer to block) or
 * a context switch occurs (tasks of the same priority will time slice).
 *
 */

/* 

Changes from V4.0.2

	+ The second set of tasks were created the wrong way around.  This has been
	  corrected.
*/


#include <stdlib.h>

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

/* Demo program include files. */
#include "BlockQ.h"

#define blckqSTACK_SIZE		configMINIMAL_STACK_SIZE
#define blckqNUM_TASK_SETS	( 3 )

/* Structure used to pass parameters to the blocking queue tasks. */
typedef struct BLOCKING_QUEUE_PARAMETERS
{
	xQueueHandle xQueue;					/*< The queue to be used by the task. */
	portTickType xBlockTime;				/*< The block time to use on queue reads/writes. */
	volatile portSHORT *psCheckVariable;	/*< Incremented on each successful cycle to check the task is still running. */
} xBlockingQueueParameters;

/* Task function that creates an incrementing number and posts it on a queue. */
static portTASK_FUNCTION_PROTO( vBlockingQueueProducer, pvParameters );

/* Task function that removes the incrementing number from a queue and checks that
it is the expected number. */
static portTASK_FUNCTION_PROTO( vBlockingQueueConsumer, pvParameters );

/* Variables which are incremented each time an item is removed from a queue, and
found to be the expected value.
These are used to check that the tasks are still running. */
static volatile portSHORT sBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0 };

/* Variable which are incremented each time an item is posted on a queue.   These
are used to check that the tasks are still running. */
static volatile portSHORT sBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0 };

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

void vStartBlockingQueueTasks( unsigned portBASE_TYPE uxPriority )
{
xBlockingQueueParameters *pxQueueParameters1, *pxQueueParameters2;
xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;
xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;
const unsigned portBASE_TYPE uxQueueSize1 = 1, uxQueueSize5 = 5;
const portTickType xBlockTime = ( portTickType ) 1000 / portTICK_RATE_MS;
const portTickType xDontBlock = ( portTickType ) 0;

	/* Create the first two tasks as described at the top of the file. */
	
	/* First create the structure used to pass parameters to the consumer tasks. */
	pxQueueParameters1 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );

	/* Create the queue used by the first two tasks to pass the incrementing number.
	Pass a pointer to the queue in the parameter structure. */
	pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );

	/* The consumer is created first so gets a block time as described above. */
	pxQueueParameters1->xBlockTime = xBlockTime;

	/* Pass in the variable that this task is going to increment so we can check it
	is still running. */
	pxQueueParameters1->psCheckVariable = &( sBlockingConsumerCount[ 0 ] );
		
	/* Create the structure used to pass parameters to the producer task. */
	pxQueueParameters2 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );

	/* Pass the queue to this task also, using the parameter structure. */
	pxQueueParameters2->xQueue = pxQueueParameters1->xQueue;

	/* The producer is not going to block - as soon as it posts the consumer will
	wake and remove the item so the producer should always have room to post. */
	pxQueueParameters2->xBlockTime = xDontBlock;

	/* Pass in the variable that this task is going to increment so we can check
	it is still running. */
	pxQueueParameters2->psCheckVariable = &( sBlockingProducerCount[ 0 ] );


	/* Note the producer has a lower priority than the consumer when the tasks are
	spawned. */
	xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QConsB1", blckqSTACK_SIZE, ( void * ) pxQueueParameters1, uxPriority, NULL );
	xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QProdB2", blckqSTACK_SIZE, ( void * ) pxQueueParameters2, tskIDLE_PRIORITY, NULL );

	

	/* Create the second two tasks as described at the top of the file.   This uses
	the same mechanism but reverses the task priorities. */

	pxQueueParameters3 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );
	pxQueueParameters3->xBlockTime = xDontBlock;
	pxQueueParameters3->psCheckVariable = &( sBlockingProducerCount[ 1 ] );

	pxQueueParameters4 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters4->xQueue = pxQueueParameters3->xQueue;
	pxQueueParameters4->xBlockTime = xBlockTime;
	pxQueueParameters4->psCheckVariable = &( sBlockingConsumerCount[ 1 ] );

	xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QProdB3", blckqSTACK_SIZE, ( void * ) pxQueueParameters3, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QConsB4", blckqSTACK_SIZE, ( void * ) pxQueueParameters4, uxPriority, NULL );



	/* Create the last two tasks as described above.  The mechanism is again just
	the same.  This time both parameter structures are given a block time. */
	pxQueueParameters5 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) );
	pxQueueParameters5->xBlockTime = xBlockTime;
	pxQueueParameters5->psCheckVariable = &( sBlockingProducerCount[ 2 ] );

	pxQueueParameters6 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
	pxQueueParameters6->xQueue = pxQueueParameters5->xQueue;
	pxQueueParameters6->xBlockTime = xBlockTime;
	pxQueueParameters6->psCheckVariable = &( sBlockingConsumerCount[ 2 ] );	

	xTaskCreate( vBlockingQueueProducer, ( signed portCHAR * ) "QProdB5", blckqSTACK_SIZE, ( void * ) pxQueueParameters5, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueConsumer, ( signed portCHAR * ) "QConsB6", blckqSTACK_SIZE, ( void * ) pxQueueParameters6, tskIDLE_PRIORITY, NULL );
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vBlockingQueueProducer, pvParameters )
{
unsigned portSHORT usValue = 0;
xBlockingQueueParameters *pxQueueParameters;
portSHORT sErrorEverOccurred = pdFALSE;

	pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;

	for( ;; )
	{		
		if( xQueueSend( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS )
		{
			sErrorEverOccurred = pdTRUE;
		}
		else
		{
			/* We have successfully posted a message, so increment the variable
			used to check we are still running. */
			if( sErrorEverOccurred == pdFALSE )
			{
				( *pxQueueParameters->psCheckVariable )++;
			}

			/* Increment the variable we are going to post next time round.  The
			consumer will expect the numbers to	follow in numerical order. */
			++usValue;
		}
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vBlockingQueueConsumer, pvParameters )
{
unsigned portSHORT usData, usExpectedValue = 0;
xBlockingQueueParameters *pxQueueParameters;
portSHORT sErrorEverOccurred = pdFALSE;

	pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;

	for( ;; )
	{	
		if( xQueueReceive( pxQueueParameters->xQueue, &usData, pxQueueParameters->xBlockTime ) == pdPASS )
		{
			if( usData != usExpectedValue )
			{
				/* Catch-up. */
				usExpectedValue = usData;

				sErrorEverOccurred = pdTRUE;
			}
			else
			{
				/* We have successfully received a message, so increment the
				variable used to check we are still running. */	
				if( sErrorEverOccurred == pdFALSE )
				{
					( *pxQueueParameters->psCheckVariable )++;
				}
							
				/* Increment the value we expect to remove from the queue next time
				round. */
				++usExpectedValue;
			}			
		}		
	}
}
/*-----------------------------------------------------------*/

/* This is called to check that all the created tasks are still running. */
portBASE_TYPE xAreBlockingQueuesStillRunning( void )
{
static portSHORT sLastBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0 };
static portSHORT sLastBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0, ( unsigned portSHORT ) 0 };
portBASE_TYPE xReturn = pdPASS, xTasks;

	/* Not too worried about mutual exclusion on these variables as they are 16
	bits and we are only reading them. We also only care to see if they have
	changed or not.
	
	Loop through each check variable to and return pdFALSE if any are found not
	to have changed since the last call. */

	for( xTasks = 0; xTasks < blckqNUM_TASK_SETS; xTasks++ )
	{
		if( sBlockingConsumerCount[ xTasks ] == sLastBlockingConsumerCount[ xTasks ]  )
		{
			xReturn = pdFALSE;
		}
		sLastBlockingConsumerCount[ xTasks ] = sBlockingConsumerCount[ xTasks ];


		if( sBlockingProducerCount[ xTasks ] == sLastBlockingProducerCount[ xTasks ]  )
		{
			xReturn = pdFALSE;
		}
		sLastBlockingProducerCount[ xTasks ] = sBlockingProducerCount[ xTasks ];
	}

	return xReturn;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美挠脚心视频网站| 99re热这里只有精品视频| 91精品综合久久久久久| 亚洲高清免费视频| 日韩精品影音先锋| 精品亚洲成a人在线观看| 久久蜜臀中文字幕| 成人免费观看av| 一区二区三区日韩欧美精品 | 蜜臀91精品一区二区三区| 欧美一区二区美女| 国产成人综合精品三级| 亚洲三级免费观看| 欧美日韩视频不卡| 国产一区亚洲一区| 一区二区三区小说| 精品少妇一区二区三区免费观看 | 国内精品久久久久影院色| 国产日韩精品一区| 欧美午夜理伦三级在线观看| 免费在线一区观看| 国产精品免费aⅴ片在线观看| 91精品办公室少妇高潮对白| 麻豆91在线观看| 成人免费视频在线观看| 欧美一区二区三区四区高清| 成人黄色综合网站| 亚洲成人动漫一区| 国产精品对白交换视频| 欧美日韩高清一区二区| 大桥未久av一区二区三区中文| 一区二区三区国产豹纹内裤在线 | 中文字幕av不卡| 欧美日韩国产高清一区二区| 国产电影一区二区三区| 五月天欧美精品| 亚洲国产精品激情在线观看| 91精品国产欧美一区二区18| 91色porny| 国产精品一卡二卡在线观看| 亚洲综合视频在线| 日本一区二区在线不卡| 日韩欧美在线123| 欧美亚洲综合久久| eeuss鲁片一区二区三区| 久久精品国产色蜜蜜麻豆| 亚洲一区二区黄色| 亚洲欧洲www| 日本一区二区免费在线| 精品成人一区二区三区| 欧美老年两性高潮| 色偷偷成人一区二区三区91| 国产成人午夜精品5599| 免费看精品久久片| 日韩高清一区在线| 亚洲成av人影院在线观看网| 亚洲人成人一区二区在线观看 | 91麻豆高清视频| 国产99久久久国产精品潘金网站| 免费在线观看日韩欧美| 亚洲综合男人的天堂| 最好看的中文字幕久久| 欧美韩日一区二区三区| 久久久99久久| 久久久亚洲精华液精华液精华液 | 国产日韩av一区| 久久在线观看免费| 欧美成人国产一区二区| 日韩精品一区二区三区在线| 欧美一区欧美二区| 制服丝袜一区二区三区| 欧美丰满高潮xxxx喷水动漫| 欧美日韩三级在线| 欧美电影一区二区三区| 欧美人与禽zozo性伦| 欧美日韩视频在线一区二区 | 欧美精品日日鲁夜夜添| 欧美日韩一区二区三区免费看 | 日韩免费电影网站| 精品国产伦理网| 久久综合网色—综合色88| 欧美精品一区二区高清在线观看| 欧美电影免费观看高清完整版在| 日韩一级片网站| 精品日韩一区二区三区| 久久免费精品国产久精品久久久久| 精品999久久久| 国产亚洲欧美色| 国产精品久久综合| 亚洲免费大片在线观看| 亚洲国产精品久久久久秋霞影院| 日日摸夜夜添夜夜添国产精品| 日韩国产欧美在线播放| 蜜桃免费网站一区二区三区| 国产成人精品亚洲777人妖| 成人黄色在线网站| 欧美一a一片一级一片| 日韩欧美精品在线视频| 欧美韩国一区二区| 亚洲午夜激情网站| 精品一区二区三区在线视频| 国产激情偷乱视频一区二区三区| 国产成人aaa| 一本久道久久综合中文字幕| 欧美日免费三级在线| 欧美成人女星排名| 亚洲色大成网站www久久九九| 亚洲一区在线免费观看| 国产一区在线视频| 91精品福利视频| 欧美刺激午夜性久久久久久久| 欧美激情一区二区在线| 亚洲图片自拍偷拍| 国产精品一二三在| 欧美亚洲愉拍一区二区| 久久免费视频一区| 亚洲成人你懂的| 国产成人亚洲精品狼色在线| 欧美艳星brazzers| 国产欧美va欧美不卡在线| 亚洲国产一区二区视频| 懂色av噜噜一区二区三区av| 欧美视频在线一区| 国产嫩草影院久久久久| 青青草精品视频| a在线播放不卡| 欧美成人免费网站| 亚洲chinese男男1069| 97国产精品videossex| 2024国产精品| 偷拍亚洲欧洲综合| 91免费小视频| 久久精品一级爱片| 久久国产乱子精品免费女| 欧美三级日本三级少妇99| 国产精品青草综合久久久久99| 欧美bbbbb| 在线中文字幕不卡| 国产精品成人免费在线| 国产酒店精品激情| 欧美变态tickling挠脚心| 天堂va蜜桃一区二区三区| 色系网站成人免费| 国产精品福利影院| 国产精品影视网| 日韩精品在线网站| 日韩 欧美一区二区三区| 欧美性xxxxxx少妇| 亚洲欧美一区二区三区极速播放| 国产成人啪免费观看软件 | 欧美日韩大陆一区二区| 亚洲欧洲另类国产综合| 成人深夜在线观看| 国产亚洲欧洲一区高清在线观看| 乱中年女人伦av一区二区| 91精品国产91久久久久久一区二区| 亚洲精品视频在线观看免费 | 五月婷婷激情综合网| 91福利国产成人精品照片| 亚洲乱码国产乱码精品精98午夜| 处破女av一区二区| 欧美激情综合五月色丁香 | 色av一区二区| 国产精品久久久久久久久免费樱桃| 国内精品视频666| 久久看人人爽人人| 国产精品一区二区三区99| 久久久天堂av| 国产成人aaa| 亚洲丝袜自拍清纯另类| 色综合色综合色综合色综合色综合| 亚洲视频在线一区观看| 91豆麻精品91久久久久久| 一区二区成人在线视频| 欧美精品三级在线观看| 蜜臀av一区二区在线观看| 日韩精品一区国产麻豆| 国产一区在线观看麻豆| 欧美国产一区二区| 99国产精品99久久久久久| 亚洲女人的天堂| 欧美三级电影在线看| 免费成人在线观看视频| 欧美成人aa大片| 国产成人精品免费网站| 国产精品国产自产拍高清av王其| 91免费精品国自产拍在线不卡| 亚洲精品高清在线观看| 欧美精品视频www在线观看| 久久精品国产秦先生| 欧美极品少妇xxxxⅹ高跟鞋| 91在线高清观看| 日韩影院精彩在线| 久久嫩草精品久久久精品一| 精品福利二区三区| 国产另类ts人妖一区二区| 亚洲桃色在线一区| 欧美高清你懂得| 从欧美一区二区三区| 国产大陆精品国产|