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

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

?? semtest.c

?? 最新版FreeRTOS, 包擴多種開發(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 two sets of two tasks.  The tasks within a set share a variable, access 
 * to which is guarded by a semaphore.
 * 
 * Each task starts by attempting to obtain the semaphore.  On obtaining a 
 * semaphore a task checks to ensure that the guarded variable has an expected 
 * value.  It then clears the variable to zero before counting it back up to the 
 * expected value in increments of 1.  After each increment the variable is checked 
 * to ensure it contains the value to which it was just set. When the starting 
 * value is again reached the task releases the semaphore giving the other task in 
 * the set a chance to do exactly the same thing.  The starting value is high 
 * enough to ensure that a tick is likely to occur during the incrementing loop.
 *
 * An error is flagged if at any time during the process a shared variable is 
 * found to have a value other than that expected.  Such an occurrence would 
 * suggest an error in the mutual exclusion mechanism by which access to the 
 * variable is restricted.
 *
 * The first set of two tasks poll their semaphore.  The second set use blocking 
 * calls.
 *
 */


#include <stdlib.h>

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

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

/* The value to which the shared variables are counted. */
#define semtstBLOCKING_EXPECTED_VALUE		( ( unsigned portLONG ) 0xfff )
#define semtstNON_BLOCKING_EXPECTED_VALUE	( ( unsigned portLONG ) 0xff  )

#define semtstSTACK_SIZE			configMINIMAL_STACK_SIZE

#define semtstNUM_TASKS				( 4 )

#define semtstDELAY_FACTOR			( ( portTickType ) 10 )

/* The task function as described at the top of the file. */
static portTASK_FUNCTION_PROTO( prvSemaphoreTest, pvParameters );

/* Structure used to pass parameters to each task. */
typedef struct SEMAPHORE_PARAMETERS
{
	xSemaphoreHandle xSemaphore;
	volatile unsigned portLONG *pulSharedVariable;
	portTickType xBlockTime;
} xSemaphoreParameters;

/* Variables used to check that all the tasks are still running without errors. */
static volatile portSHORT sCheckVariables[ semtstNUM_TASKS ] = { 0 };
static volatile portSHORT sNextCheckVariable = 0;

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

void vStartSemaphoreTasks( unsigned portBASE_TYPE uxPriority )
{
xSemaphoreParameters *pxFirstSemaphoreParameters, *pxSecondSemaphoreParameters;
const portTickType xBlockTime = ( portTickType ) 100;

	/* Create the structure used to pass parameters to the first two tasks. */
	pxFirstSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );

	if( pxFirstSemaphoreParameters != NULL )
	{
		/* Create the semaphore used by the first two tasks. */
		vSemaphoreCreateBinary( pxFirstSemaphoreParameters->xSemaphore );

		if( pxFirstSemaphoreParameters->xSemaphore != NULL )
		{
			/* Create the variable which is to be shared by the first two tasks. */
			pxFirstSemaphoreParameters->pulSharedVariable = ( unsigned portLONG * ) pvPortMalloc( sizeof( unsigned portLONG ) );

			/* Initialise the share variable to the value the tasks expect. */
			*( pxFirstSemaphoreParameters->pulSharedVariable ) = semtstNON_BLOCKING_EXPECTED_VALUE;

			/* The first two tasks do not block on semaphore calls. */
			pxFirstSemaphoreParameters->xBlockTime = ( portTickType ) 0;

			/* Spawn the first two tasks.  As they poll they operate at the idle priority. */
			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "PolSEM1", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "PolSEM2", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
		}
	}

	/* Do exactly the same to create the second set of tasks, only this time 
	provide a block time for the semaphore calls. */
	pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
	if( pxSecondSemaphoreParameters != NULL )
	{
		vSemaphoreCreateBinary( pxSecondSemaphoreParameters->xSemaphore );

		if( pxSecondSemaphoreParameters->xSemaphore != NULL )
		{
			pxSecondSemaphoreParameters->pulSharedVariable = ( unsigned portLONG * ) pvPortMalloc( sizeof( unsigned portLONG ) );
			*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;
			pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_RATE_MS;

			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "BlkSEM1", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
			xTaskCreate( prvSemaphoreTest, ( signed portCHAR * ) "BlkSEM2", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
		}
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( prvSemaphoreTest, pvParameters )
{
xSemaphoreParameters *pxParameters;
volatile unsigned portLONG *pulSharedVariable, ulExpectedValue;
unsigned portLONG ulCounter;
portSHORT sError = pdFALSE, sCheckVariableToUse;

	/* See which check variable to use.  sNextCheckVariable is not semaphore 
	protected! */
	portENTER_CRITICAL();
		sCheckVariableToUse = sNextCheckVariable;
		sNextCheckVariable++;
	portEXIT_CRITICAL();

	/* A structure is passed in as the parameter.  This contains the shared 
	variable being guarded. */
	pxParameters = ( xSemaphoreParameters * ) pvParameters;
	pulSharedVariable = pxParameters->pulSharedVariable;

	/* If we are blocking we use a much higher count to ensure loads of context
	switches occur during the count. */
	if( pxParameters->xBlockTime > ( portTickType ) 0 )
	{
		ulExpectedValue = semtstBLOCKING_EXPECTED_VALUE;
	}
	else
	{
		ulExpectedValue = semtstNON_BLOCKING_EXPECTED_VALUE;
	}

	for( ;; )
	{
		/* Try to obtain the semaphore. */
		if( xSemaphoreTake( pxParameters->xSemaphore, pxParameters->xBlockTime ) == pdPASS )
		{
			/* We have the semaphore and so expect any other tasks using the
			shared variable to have left it in the state we expect to find
			it. */
			if( *pulSharedVariable != ulExpectedValue )
			{
				sError = pdTRUE;
			}
			
			/* Clear the variable, then count it back up to the expected value
			before releasing the semaphore.  Would expect a context switch or
			two during this time. */
			for( ulCounter = ( unsigned portLONG ) 0; ulCounter <= ulExpectedValue; ulCounter++ )
			{
				*pulSharedVariable = ulCounter;
				if( *pulSharedVariable != ulCounter )
				{
					sError = pdTRUE;
				}
			}

			/* Release the semaphore, and if no errors have occurred increment the check
			variable. */
			if(	xSemaphoreGive( pxParameters->xSemaphore ) == pdFALSE )
			{
				sError = pdTRUE;
			}

			if( sError == pdFALSE )
			{
				if( sCheckVariableToUse < semtstNUM_TASKS )
				{
					( sCheckVariables[ sCheckVariableToUse ] )++;
				}
			}

			/* If we have a block time then we are running at a priority higher
			than the idle priority.  This task takes a long time to complete
			a cycle	(deliberately so to test the guarding) so will be starving
			out lower priority tasks.  Block for some time to allow give lower
			priority tasks some processor time. */
			vTaskDelay( pxParameters->xBlockTime * semtstDELAY_FACTOR );
		}
		else
		{
			if( pxParameters->xBlockTime == ( portTickType ) 0 )
			{
				/* We have not got the semaphore yet, so no point using the
				processor.  We are not blocking when attempting to obtain the
				semaphore. */
				taskYIELD();
			}
		}
	}
}
/*-----------------------------------------------------------*/

/* This is called to check that all the created tasks are still running. */
portBASE_TYPE xAreSemaphoreTasksStillRunning( void )
{
static portSHORT sLastCheckVariables[ semtstNUM_TASKS ] = { 0 };
portBASE_TYPE xTask, xReturn = pdTRUE;

	for( xTask = 0; xTask < semtstNUM_TASKS; xTask++ )
	{
		if( sLastCheckVariables[ xTask ] == sCheckVariables[ xTask ] )
		{
			xReturn = pdFALSE;
		}

		sLastCheckVariables[ xTask ] = sCheckVariables[ xTask ];
	}

	return xReturn;
}


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜av在线| proumb性欧美在线观看| 国产成人精品www牛牛影视| 日本道免费精品一区二区三区| 欧美一区二区久久久| 一区二区三区欧美亚洲| 激情成人午夜视频| 欧美日韩在线综合| 成人免费在线播放视频| 韩国三级在线一区| 91精品国产美女浴室洗澡无遮挡| 中文字幕亚洲视频| 国产精品一区二区久久不卡| 欧美精品第1页| 亚洲国产综合视频在线观看| av激情综合网| 国产精品女同一区二区三区| 久久国产精品第一页| 3atv一区二区三区| 婷婷丁香激情综合| 欧美天堂一区二区三区| 亚洲女女做受ⅹxx高潮| av在线这里只有精品| 久久午夜电影网| av电影在线观看不卡| 国产女人aaa级久久久级| 国产一区在线精品| 久久综合999| 经典三级视频一区| 2024国产精品| 国产一区二区精品久久99| 日韩美女在线视频 | 日韩高清在线一区| 欧洲精品在线观看| 亚洲尤物视频在线| 欧美日韩亚洲综合在线| 亚洲一区二区三区精品在线| 91在线一区二区| 亚洲免费看黄网站| 欧美性色欧美a在线播放| 一区二区免费在线| 欧美福利电影网| 免费在线看一区| 久久噜噜亚洲综合| 成人免费av资源| 亚洲乱码国产乱码精品精可以看| 色噜噜狠狠成人网p站| 亚洲午夜电影在线观看| 欧美一级夜夜爽| 国产一区二区福利| 亚洲人快播电影网| 91精选在线观看| 国产露脸91国语对白| 中文字幕亚洲在| 欧美精品久久99久久在免费线 | 久久免费精品国产久精品久久久久| 久久99精品久久久久久久久久久久 | 欧美精品视频www在线观看| 人人狠狠综合久久亚洲| 久久精品夜夜夜夜久久| 精品国产伦一区二区三区观看方式| 日韩二区三区在线观看| 国产喂奶挤奶一区二区三区| 在线一区二区三区四区| 狠狠色2019综合网| 一区二区三区毛片| 久久久99精品久久| 日本精品一区二区三区四区的功能| 视频一区视频二区中文字幕| 欧美成人福利视频| 在线视频观看一区| 国产麻豆精品在线观看| 一区二区三区产品免费精品久久75| 欧美一级精品在线| av成人老司机| 美洲天堂一区二卡三卡四卡视频| 国产精品国产三级国产aⅴ中文 | jlzzjlzz亚洲女人18| 日韩精品乱码av一区二区| 国产精品网友自拍| 欧美一区二区三区喷汁尤物| 成人av网站在线观看| 蜜桃视频免费观看一区| 一区二区三区在线影院| 精品国产麻豆免费人成网站| 欧美性生活久久| 成人97人人超碰人人99| 精品亚洲免费视频| 亚洲五月六月丁香激情| 亚洲天堂中文字幕| 国产精品视频线看| 欧美zozo另类异族| 欧美绝品在线观看成人午夜影视| www.视频一区| 国产成人综合亚洲网站| 久久国产精品区| 午夜激情综合网| 亚洲专区一二三| 亚洲视频一区二区免费在线观看| 久久久久久久久久久久久女国产乱 | 在线中文字幕一区| 99久久免费精品高清特色大片| 国产一区二区毛片| 狠狠狠色丁香婷婷综合激情 | 99久久国产免费看| 成人精品一区二区三区中文字幕| 麻豆免费看一区二区三区| 亚洲h在线观看| 亚洲第四色夜色| 亚洲在线成人精品| 亚洲午夜在线视频| 亚洲精品国产视频| 亚洲精品老司机| 夜夜揉揉日日人人青青一国产精品| 国产精品亲子伦对白| 国产精品入口麻豆原神| 中文字幕亚洲电影| 国产精品激情偷乱一区二区∴| 国产精品情趣视频| 亚洲欧洲成人精品av97| 精品综合免费视频观看| 捆绑调教美女网站视频一区| 日韩成人免费电影| 日韩高清在线一区| 久久精品国产第一区二区三区| 狠狠色综合色综合网络| 国产在线不卡一区| 国产91清纯白嫩初高中在线观看| 粉嫩av一区二区三区粉嫩| 99精品欧美一区二区三区小说| 一本大道久久a久久综合婷婷| 91福利视频久久久久| 欧美人成免费网站| 欧美电影免费观看高清完整版在线观看| 欧美电影免费观看高清完整版在| 久久久青草青青国产亚洲免观| 国产视频不卡一区| 亚洲美女免费视频| 日韩精品视频网站| 国产98色在线|日韩| 一本久道中文字幕精品亚洲嫩| 欧美日韩黄色影视| 久久蜜臀中文字幕| 亚洲在线中文字幕| 国产一区亚洲一区| 色综合久久久久综合| 欧美精品日日鲁夜夜添| 国产日韩精品一区二区三区| 亚洲激情第一区| 精品一区二区久久| 91久久精品网| 久久综合色8888| 亚洲精品国产一区二区精华液 | k8久久久一区二区三区| 欧美日韩免费观看一区三区| 久久亚洲影视婷婷| 一区二区三区四区av| 国产一区欧美日韩| 在线观看一区日韩| 国产午夜精品久久久久久久 | 日韩女优av电影| 亚洲激情一二三区| 国产黑丝在线一区二区三区| 日本精品一级二级| 国产亚洲一区二区三区四区 | 久久不见久久见免费视频7| 91网站最新网址| www国产亚洲精品久久麻豆| 亚洲小说欧美激情另类| 丁香婷婷综合激情五月色| 欧美一级日韩一级| 亚洲一区二区免费视频| 波多野结衣在线aⅴ中文字幕不卡| 日韩一级免费观看| 一卡二卡欧美日韩| 91视频免费播放| 国产欧美日韩另类一区| 久久国产精品99久久人人澡| 欧美视频一区在线观看| 国产精品欧美精品| 国产精品伊人色| 日韩亚洲电影在线| 午夜欧美电影在线观看| 色狠狠一区二区| 国产精品久久久久久久久快鸭 | 国产精品成人免费在线| 欧美精品自拍偷拍动漫精品| 1024亚洲合集| 成人av资源网站| 国产午夜亚洲精品午夜鲁丝片 | 欧美日韩国产三级| 一卡二卡三卡日韩欧美| 91九色02白丝porn| 亚洲人成网站精品片在线观看| av亚洲产国偷v产偷v自拍| 国产精品免费观看视频| 成人黄色小视频在线观看| 国产欧美精品一区二区三区四区| 国产乱一区二区| 久久久精品影视|