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

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

?? blockq.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.
	***************************************************************************
*/

/**
 * 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).
 *
 * \page BlockQC blockQ.c
 * \ingroup DemoFiles
 * <HR>
 */

/*
Changes from V1.00:
	
	+ Reversed the priority and block times of the second two demo tasks so
	  they operate as per the description above.

Changes from V2.0.0

	+ Delay periods are now specified using variables and constants of
	  portTickType rather than unsigned portLONG.
*/


#include <stdlib.h>

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

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

#define blckqSTACK_SIZE		( ( unsigned portSHORT ) 128 )
#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 void vBlockingQueueProducer( void *pvParameters );

/* Task function that removes the incrementing number from a queue and checks that 
it is the expected number. */
static void vBlockingQueueConsumer( void *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 ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( 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 ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( 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, "QConsB1", blckqSTACK_SIZE, ( void * ) pxQueueParameters1, uxPriority, NULL );
	xTaskCreate( vBlockingQueueProducer, "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, "QProdB3", blckqSTACK_SIZE, ( void * ) pxQueueParameters3, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueConsumer, "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, "QProdB5", blckqSTACK_SIZE, ( void * ) pxQueueParameters5, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vBlockingQueueConsumer, "QConsB6", blckqSTACK_SIZE, ( void * ) pxQueueParameters6, tskIDLE_PRIORITY, NULL );
}
/*-----------------------------------------------------------*/

static void vBlockingQueueProducer( void *pvParameters )
{
unsigned portSHORT usValue = 0;
xBlockingQueueParameters *pxQueueParameters;
const portCHAR * const pcTaskStartMsg = "Blocking queue producer started.\r\n";
const portCHAR * const pcTaskErrorMsg = "Could not post on blocking queue\r\n";
portSHORT sErrorEverOccurred = pdFALSE;

	pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );

	for( ;; )
	{		
		if( xQueueSend( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS )
		{
			vPrintDisplayMessage( &pcTaskErrorMsg );
			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 void vBlockingQueueConsumer( void *pvParameters )
{
unsigned portSHORT usData, usExpectedValue = 0;
xBlockingQueueParameters *pxQueueParameters;
const portCHAR * const pcTaskStartMsg = "Blocking queue consumer started.\r\n";
const portCHAR * const pcTaskErrorMsg = "Incorrect value received on blocking queue.\r\n";
portSHORT sErrorEverOccurred = pdFALSE;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );

	pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;

	for( ;; )
	{	
		if( xQueueReceive( pxQueueParameters->xQueue, &usData, pxQueueParameters->xBlockTime ) == pdPASS )
		{
			if( usData != usExpectedValue )
			{
				vPrintDisplayMessage( &pcTaskErrorMsg );

				/* 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 ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( portSHORT ) 0 };
static portSHORT sLastBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( 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 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;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品72免费观看| 国产精品一级片| 91精品国产色综合久久| 日韩不卡一区二区三区| 日韩免费在线观看| 国产a精品视频| 亚洲欧洲日本在线| 欧洲精品在线观看| 日韩精品一级中文字幕精品视频免费观看 | 欧美日韩国产天堂| 日韩精品一级中文字幕精品视频免费观看 | 在线观看中文字幕不卡| 日韩精品亚洲专区| 精品国产乱码久久久久久免费 | 精品乱人伦小说| 成人免费视频视频| 夜夜亚洲天天久久| 日韩午夜中文字幕| 国产高清不卡一区| 亚洲欧美另类小说| 欧美一区二区三区精品| 国产成人av福利| 一区二区三区精品视频| 日韩视频免费观看高清在线视频| 国产精品自拍三区| 亚洲精品亚洲人成人网在线播放| 欧美丰满少妇xxxbbb| 国产精品一区二区三区99| 亚洲女同一区二区| 日韩一区二区三区三四区视频在线观看| 国内精品久久久久影院薰衣草| 一区视频在线播放| 欧美一级高清片在线观看| 国产ts人妖一区二区| 亚洲r级在线视频| 国产日韩欧美a| 欧美视频一区二区三区四区 | 国产精品久久久久久户外露出| 欧美三级韩国三级日本一级| 国产在线不卡一区| 亚洲一区二区中文在线| 久久婷婷国产综合国色天香| 在线欧美一区二区| 国产麻豆精品在线观看| 亚洲成人av电影在线| 国产午夜精品一区二区三区四区| 欧美性感一类影片在线播放| 国产精品1区2区3区在线观看| 亚洲不卡av一区二区三区| 国产欧美精品一区aⅴ影院| 欧美精品一卡二卡| 成人av在线播放网址| 热久久一区二区| 亚洲卡通欧美制服中文| 久久久久久久综合| 91精品国产综合久久精品麻豆 | 欧美一卡2卡三卡4卡5免费| k8久久久一区二区三区| 久久国产免费看| 亚洲一区二区偷拍精品| 国产精品午夜电影| 精品免费日韩av| 欧美日韩精品三区| 色综合久久88色综合天天免费| 国产一区欧美日韩| 日本亚洲欧美天堂免费| 一区二区三区日韩在线观看| 亚洲国产精品二十页| 欧美变态tickle挠乳网站| 欧美日韩一二区| 99久久精品免费| 国产精品1024| 精品一区二区三区在线播放| 亚洲地区一二三色| 亚洲美女少妇撒尿| 中文无字幕一区二区三区 | 亚洲免费毛片网站| 中文字幕精品一区二区三区精品| 精品久久久三级丝袜| 欧美精品乱人伦久久久久久| 一本大道av一区二区在线播放| 国产69精品一区二区亚洲孕妇 | 免费成人美女在线观看| 亚洲综合在线电影| 亚洲欧美一区二区久久| 国产日产亚洲精品系列| www久久精品| www欧美成人18+| 精品播放一区二区| 欧美一级免费大片| 911精品国产一区二区在线| 欧美怡红院视频| 91久久国产最好的精华液| av电影在线观看一区| 懂色av一区二区在线播放| 国产在线不卡一区| 国产一区二区三区黄视频 | 亚洲韩国精品一区| 一区二区三区av电影| 亚洲免费视频成人| 一区二区欧美国产| 亚洲综合在线第一页| 亚洲综合另类小说| 亚洲综合一区二区三区| 亚洲国产日韩一区二区| 亚洲国产色一区| 日韩激情中文字幕| 日韩精品欧美成人高清一区二区| 午夜精品影院在线观看| 丝袜脚交一区二区| 奇米在线7777在线精品| 蜜桃精品视频在线| 国产一区二区三区美女| 成人午夜av电影| 暴力调教一区二区三区| 91丨九色丨国产丨porny| 色婷婷综合久久久久中文| 在线视频一区二区免费| 欧美日韩国产免费一区二区| 制服丝袜亚洲精品中文字幕| 日韩区在线观看| 久久一区二区三区四区| 欧美激情一区二区三区全黄| 中文字幕亚洲视频| 一区二区三区在线观看欧美| 亚洲国产va精品久久久不卡综合| 日韩在线卡一卡二| 国模冰冰炮一区二区| 懂色av一区二区在线播放| 一道本成人在线| 欧美日韩精品福利| 欧美大片在线观看一区二区| 国产亚洲精品7777| 亚洲欧美日韩小说| 午夜精品视频在线观看| 精品一区二区影视| 99久久免费精品| 欧美日韩一区二区欧美激情| 欧美一区二区不卡视频| 国产亚洲精品中文字幕| 亚洲精品成人精品456| 日韩电影在线观看电影| 国产精品小仙女| 99re亚洲国产精品| 欧美丰满少妇xxxbbb| 久久精品亚洲麻豆av一区二区| 亚洲天堂精品在线观看| 亚洲sss视频在线视频| 国产精品香蕉一区二区三区| 色94色欧美sute亚洲线路二 | 免费在线观看一区二区三区| 国产美女精品一区二区三区| 色综合久久综合网欧美综合网| 91精品国产入口| 国产欧美日韩麻豆91| 亚洲一区二区综合| 国产一区二区主播在线| 色综合天天性综合| 日韩欧美在线网站| 国产精品高潮呻吟| 免费人成精品欧美精品| 不卡一卡二卡三乱码免费网站| 欧美人xxxx| 国产日产精品一区| 午夜精品久久久久久久蜜桃app| 国产一区二区三区| 欧美视频中文一区二区三区在线观看| 久久综合久久鬼色中文字| 一二三四社区欧美黄| 国产精品 欧美精品| 欧美日韩亚洲丝袜制服| 国产欧美日韩综合精品一区二区 | 国产精品一级片| 欧美日韩一级二级| 国产精品国产三级国产普通话99| 日韩国产在线观看一区| 成人动漫一区二区在线| 欧美一区二区三区色| 亚洲人成在线观看一区二区| 久草热8精品视频在线观看| 色婷婷国产精品久久包臀| 26uuu精品一区二区三区四区在线| 一区二区三区四区乱视频| 国产成人在线免费观看| 91麻豆精品国产91久久久| 1024亚洲合集| 国产剧情一区在线| 3d动漫精品啪啪| 亚洲另类一区二区| 国产成人在线电影| 欧美一区日本一区韩国一区| 亚洲欧美日韩国产综合| 国产1区2区3区精品美女| 日韩三级视频中文字幕| 亚洲第一二三四区| 91免费版pro下载短视频| 国产三级精品三级| 麻豆成人av在线| 欧美日韩国产精选| 亚洲色图制服诱惑|