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

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

?? semtest.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 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.
 *
 * \page SemTestC semtest.c
 * \ingroup DemoFiles
 * <HR>
 */

/*
Changes from V1.2.0:

	+ The tasks that operate at the idle priority now use a lower expected
	  count than those running at a higher priority.  This prevents the low
	  priority tasks from signaling an error because they have not been 
	  scheduled enough time for each of them to count the shared variable to
	  the high value.

Changes from V2.0.0

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

Changes from V2.1.1

	+ The stack size now uses configMINIMAL_STACK_SIZE.
	+ String constants made file scope to decrease stack depth on 8051 port.
*/

#include <stdlib.h>

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

/* Demo app include files. */
#include "semtest.h"
#include "print.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 void prvSemaphoreTest( void *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;

/* Strings to print if USE_STDIO is defined. */
const portCHAR * const pcPollingSemaphoreTaskError = "Guarded shared variable in unexpected state.\r\n";
const portCHAR * const pcSemaphoreTaskStart = "Guarded shared variable task started.\r\n";

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

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, "PolSEM1", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
			xTaskCreate( prvSemaphoreTest, "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, "BlkSEM1", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
			xTaskCreate( prvSemaphoreTest, "BlkSEM2", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( xTaskHandle * ) NULL );
		}
	}
}
/*-----------------------------------------------------------*/

static void prvSemaphoreTest( void *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();

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

	/* 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 )
			{
				vPrintDisplayMessage( &pcPollingSemaphoreTaskError );
				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 )
				{
					if( sError == pdFALSE )
					{
						vPrintDisplayMessage( &pcPollingSemaphoreTaskError );
					}
					sError = pdTRUE;
				}
			}

			/* Release the semaphore, and if no errors have occurred increment the check
			variable. */
			if(	xSemaphoreGive( pxParameters->xSemaphore ) == pdFALSE )
			{
				vPrintDisplayMessage( &pcPollingSemaphoreTaskError );
				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;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品精华液一区二区三区| 成人av在线资源| 亚洲老妇xxxxxx| 久久老女人爱爱| 6080亚洲精品一区二区| 高清视频一区二区| 蜜臀av性久久久久蜜臀av麻豆| 亚洲大尺度视频在线观看| 亚洲欧美激情小说另类| 中文字幕日韩一区| 中文字幕亚洲区| 成人免费在线观看入口| 亚洲国产精品二十页| 国产农村妇女精品| 精品免费国产一区二区三区四区| 欧美午夜精品免费| 欧美写真视频网站| 欧美亚洲愉拍一区二区| 欧美三级韩国三级日本三斤| 日本韩国欧美一区二区三区| 色88888久久久久久影院野外| 欧美影视一区在线| 欧美日高清视频| 91精品在线免费| 欧美一级免费观看| 久久亚洲精品国产精品紫薇| 久久久久九九视频| 国产精品成人免费在线| 一区二区三区精密机械公司| 视频一区二区三区中文字幕| 美女看a上一区| 成人精品在线视频观看| 一本久道中文字幕精品亚洲嫩| 欧美日韩视频不卡| 精品国产乱码久久久久久影片| 中文字幕精品一区二区三区精品| 亚洲精品一卡二卡| 极品少妇xxxx精品少妇| 国产精品一区专区| 欧美在线你懂的| 久久久综合视频| 亚洲成人手机在线| 国产 欧美在线| 欧美肥大bbwbbw高潮| 国产精品毛片大码女人| 日韩电影一二三区| 91视频观看免费| 精品日韩99亚洲| 亚洲夂夂婷婷色拍ww47| 激情都市一区二区| 在线一区二区三区| 国产欧美一区二区三区网站| 亚洲国产精品久久人人爱| 国产精品资源站在线| 欧美精品久久99| 亚洲精品国产一区二区三区四区在线| 日本欧美在线观看| 在线免费亚洲电影| 国产精品入口麻豆九色| 免费成人小视频| 欧美特级限制片免费在线观看| 国产亚洲制服色| 麻豆精品在线视频| 欧美专区亚洲专区| 亚洲欧美日韩国产另类专区| 国精产品一区一区三区mba视频| 欧美区视频在线观看| 亚洲一区二区三区四区五区黄| www.欧美色图| 亚洲国产精品成人综合| 国产一区二区精品久久99| 欧美精品一卡二卡| 日韩av网站免费在线| 3d成人h动漫网站入口| 亚洲一区二区在线免费观看视频| 99九九99九九九视频精品| 国产精品久久久久国产精品日日| 国产一级精品在线| 久久日一线二线三线suv| 麻豆91在线播放| 日韩欧美一卡二卡| 极品少妇一区二区| www国产精品av| 成人免费观看男女羞羞视频| 国产精品全国免费观看高清| 99国内精品久久| 亚洲精品视频在线观看免费| 日本久久电影网| 亚洲成人你懂的| 91精品国产麻豆国产自产在线| 日产欧产美韩系列久久99| 欧美一区二区三区电影| 久久精品国产99久久6| 欧美精品一区二区三区久久久| 国产成人亚洲精品狼色在线| 国产精品福利一区二区三区| aaa欧美大片| 日日摸夜夜添夜夜添精品视频| 日韩午夜在线播放| 国产成人av在线影院| 亚洲精品视频在线观看网站| 欧美人伦禁忌dvd放荡欲情| 国内精品第一页| 亚洲精品视频在线观看网站| 欧美高清hd18日本| 成人在线视频一区二区| 同产精品九九九| 欧美激情在线观看视频免费| 欧美性极品少妇| 国产一区二区三区日韩| 亚洲精品成人a在线观看| 精品国产91洋老外米糕| 91在线你懂得| 国产中文字幕一区| 午夜影院久久久| 国产精品乱码一区二区三区软件| 91精品国产综合久久香蕉的特点| 成人国产亚洲欧美成人综合网| 日韩高清在线一区| 亚洲男人天堂av网| 久久伊人蜜桃av一区二区| 欧美日韩国产天堂| 成年人网站91| 国产精品 日产精品 欧美精品| 亚洲国产精品久久人人爱| 中文字幕中文在线不卡住| 精品国产亚洲在线| 欧美区在线观看| 在线观看一区日韩| 不卡一区二区三区四区| 国产伦精品一区二区三区免费| 日韩高清不卡在线| 亚洲成人免费在线| 色域天天综合网| 色哟哟国产精品| 91在线小视频| 91老师片黄在线观看| av不卡免费在线观看| 成人小视频免费观看| 国产成人欧美日韩在线电影| 国内精品免费**视频| 狠狠色综合色综合网络| 极品少妇一区二区三区精品视频| 久久精品国产免费| 久久电影网电视剧免费观看| 久久国产尿小便嘘嘘| 国产综合一区二区| 高清在线观看日韩| 91麻豆自制传媒国产之光| 色狠狠综合天天综合综合| 日本高清不卡一区| 欧美久久久久久久久中文字幕| 欧美视频一区二区三区四区| 欧美肥妇bbw| 久久综合国产精品| 国产亚洲制服色| 亚洲乱码一区二区三区在线观看| 亚洲综合色视频| 欧美aa在线视频| 成人综合婷婷国产精品久久蜜臀 | 国产福利精品一区二区| 99久久综合99久久综合网站| www.av精品| 欧美日韩综合色| 久久精子c满五个校花| 亚洲六月丁香色婷婷综合久久| 亚洲123区在线观看| 国产精品99久久久久久似苏梦涵 | 欧美婷婷六月丁香综合色| 日韩欧美一区二区久久婷婷| 亚洲国产精品精华液2区45| 亚洲一区二区欧美| 国产成人免费视频网站| 欧洲亚洲精品在线| 久久久久国产精品人| 一区二区三区波多野结衣在线观看| 日韩电影在线观看一区| 97国产一区二区| 欧美电视剧在线观看完整版| 亚洲美女淫视频| 黄页视频在线91| 欧美午夜电影在线播放| 国产日韩三级在线| 美女性感视频久久| 在线中文字幕不卡| 国产精品久久夜| 欧美aa在线视频| 欧美色手机在线观看| 国产日韩欧美激情| 精品一区二区三区视频| 欧美最猛性xxxxx直播| 国产精品二三区| 国产老肥熟一区二区三区| 欧美高清视频不卡网| 亚洲蜜臀av乱码久久精品蜜桃| 国产麻豆成人精品| 精品国产一区二区国模嫣然| 性做久久久久久免费观看欧美| 99国产精品99久久久久久| 国产日韩欧美一区二区三区乱码|