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

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

?? dynamic.c

?? MCS-51的一個Free小型操作系統,在KeilC中下編譯工作
?? C
字號:
/*
	FreeRTOS.org V4.1.3 - 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.
	***************************************************************************
*/

/*
 * The first test creates three tasks - two counter tasks (one continuous count 
 * and one limited count) and one controller.  A "count" variable is shared 
 * between all three tasks.  The two counter tasks should never be in a "ready" 
 * state at the same time.  The controller task runs at the same priority as 
 * the continuous count task, and at a lower priority than the limited count 
 * task.
 *
 * One counter task loops indefinitely, incrementing the shared count variable
 * on each iteration.  To ensure it has exclusive access to the variable it
 * raises it's priority above that of the controller task before each 
 * increment, lowering it again to it's original priority before starting the
 * next iteration.
 *
 * The other counter task increments the shared count variable on each
 * iteration of it's loop until the count has reached a limit of 0xff - at
 * which point it suspends itself.  It will not start a new loop until the 
 * controller task has made it "ready" again by calling vTaskResume ().  
 * This second counter task operates at a higher priority than controller 
 * task so does not need to worry about mutual exclusion of the counter 
 * variable.
 *
 * The controller task is in two sections.  The first section controls and
 * monitors the continuous count task.  When this section is operational the 
 * limited count task is suspended.  Likewise, the second section controls 
 * and monitors the limited count task.  When this section is operational the 
 * continuous count task is suspended.
 *
 * In the first section the controller task first takes a copy of the shared
 * count variable.  To ensure mutual exclusion on the count variable it
 * suspends the continuous count task, resuming it again when the copy has been
 * taken.  The controller task then sleeps for a fixed period - during which
 * the continuous count task will execute and increment the shared variable.
 * When the controller task wakes it checks that the continuous count task
 * has executed by comparing the copy of the shared variable with its current
 * value.  This time, to ensure mutual exclusion, the scheduler itself is 
 * suspended with a call to vTaskSuspendAll ().  This is for demonstration 
 * purposes only and is not a recommended technique due to its inefficiency.
 *
 * After a fixed number of iterations the controller task suspends the 
 * continuous count task, and moves on to its second section.
 *
 * At the start of the second section the shared variable is cleared to zero.
 * The limited count task is then woken from it's suspension by a call to
 * vTaskResume ().  As this counter task operates at a higher priority than
 * the controller task the controller task should not run again until the
 * shared variable has been counted up to the limited value causing the counter
 * task to suspend itself.  The next line after vTaskResume () is therefore
 * a check on the shared variable to ensure everything is as expected.
 *
 *
 * The second test consists of a couple of very simple tasks that post onto a 
 * queue while the scheduler is suspended.  This test was added to test parts
 * of the scheduler not exercised by the first test.
 *
 */

#include <stdlib.h>

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

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

/* Function that implements the "limited count" task as described above. */
static portTASK_FUNCTION_PROTO( vLimitedIncrementTask, pvParameters );

/* Function that implements the "continuous count" task as described above. */
static portTASK_FUNCTION_PROTO( vContinuousIncrementTask, pvParameters );

/* Function that implements the controller task as described above. */
static portTASK_FUNCTION_PROTO( vCounterControlTask, pvParameters );

static portTASK_FUNCTION_PROTO( vQueueReceiveWhenSuspendedTask, pvParameters );
static portTASK_FUNCTION_PROTO( vQueueSendWhenSuspendedTask, pvParameters );

/* Demo task specific constants. */
#define priSTACK_SIZE				( ( unsigned portSHORT ) 128 )
#define priSLEEP_TIME				( ( portTickType ) 100 )
#define priLOOPS					( 5 )
#define priMAX_COUNT				( ( unsigned portLONG ) 0xff )
#define priNO_BLOCK					( ( portTickType ) 0 )
#define priSUSPENDED_QUEUE_LENGTH	( 1 )

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

/* Handles to the two counter tasks.  These could be passed in as parameters
to the controller task to prevent them having to be file scope. */
static xTaskHandle xContinousIncrementHandle, xLimitedIncrementHandle;

/* The shared counter variable.  This is passed in as a parameter to the two 
counter variables for demonstration purposes. */
static unsigned portLONG ulCounter;

/* Variables used to check that the tasks are still operating without error.
Each complete iteration of the controller task increments this variable
provided no errors have been found.  The variable maintaining the same value
is therefore indication of an error. */
static unsigned portSHORT usCheckVariable = ( unsigned portSHORT ) 0;
static portBASE_TYPE xSuspendedQueueSendError = pdFALSE;
static portBASE_TYPE xSuspendedQueueReceiveError = pdFALSE;

/* Queue used by the second test. */
xQueueHandle xSuspendedTestQueue;

/*-----------------------------------------------------------*/
/*
 * Start the three tasks as described at the top of the file.
 * Note that the limited count task is given a higher priority.
 */
void vStartDynamicPriorityTasks( void )
{
	xSuspendedTestQueue = xQueueCreate( priSUSPENDED_QUEUE_LENGTH, sizeof( unsigned portLONG ) );
	xTaskCreate( vContinuousIncrementTask, ( signed portCHAR * ) "CNT_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY, &xContinousIncrementHandle );
	xTaskCreate( vLimitedIncrementTask, ( signed portCHAR * ) "LIM_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY + 1, &xLimitedIncrementHandle );
	xTaskCreate( vCounterControlTask, ( signed portCHAR * ) "C_CTRL", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vQueueSendWhenSuspendedTask, ( signed portCHAR * ) "SUSP_TX", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vQueueReceiveWhenSuspendedTask, ( signed portCHAR * ) "SUSP_RX", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
}
/*-----------------------------------------------------------*/

/*
 * Just loops around incrementing the shared variable until the limit has been
 * reached.  Once the limit has been reached it suspends itself. 
 */
static portTASK_FUNCTION( vLimitedIncrementTask, pvParameters )
{
unsigned portLONG *pulCounter;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned portLONG * ) pvParameters;

	/* This will run before the control task, so the first thing it does is
	suspend - the control task will resume it when ready. */
	vTaskSuspend( NULL );

	for( ;; )
	{
		/* Just count up to a value then suspend. */
		( *pulCounter )++;	
		
		if( *pulCounter >= priMAX_COUNT )
		{
			vTaskSuspend( NULL );
		} 	
	}
}
/*-----------------------------------------------------------*/

/*
 * Just keep counting the shared variable up.  The control task will suspend
 * this task when it wants.
 */
static portTASK_FUNCTION( vContinuousIncrementTask, pvParameters )
{
unsigned portLONG *pulCounter;
unsigned portBASE_TYPE uxOurPriority;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned portLONG * ) pvParameters;

	/* Query our priority so we can raise it when exclusive access to the 
	shared variable is required. */
	uxOurPriority = uxTaskPriorityGet( NULL );

	for( ;; )
	{
		/* Raise our priority above the controller task to ensure a context
		switch does not occur while we are accessing this variable. */
		vTaskPrioritySet( NULL, uxOurPriority + 1 );
			( *pulCounter )++;		
		vTaskPrioritySet( NULL, uxOurPriority );
	}
}
/*-----------------------------------------------------------*/

/*
 * Controller task as described above.
 */
static portTASK_FUNCTION( vCounterControlTask, pvParameters )
{
unsigned portLONG ulLastCounter;
portSHORT sLoops;
portSHORT sError = pdFALSE;

	/* Just to stop warning messages. */
	( void ) pvParameters;

	for( ;; )
	{
		/* Start with the counter at zero. */
		ulCounter = ( unsigned portLONG ) 0;

		/* First section : */

		/* Check the continuous count task is running. */
		for( sLoops = 0; sLoops < priLOOPS; sLoops++ )
		{
			/* Suspend the continuous count task so we can take a mirror of the
			shared variable without risk of corruption. */
			vTaskSuspend( xContinousIncrementHandle );
				ulLastCounter = ulCounter;
			vTaskResume( xContinousIncrementHandle );
			
			/* Now delay to ensure the other task has processor time. */
			vTaskDelay( priSLEEP_TIME );

			/* Check the shared variable again.  This time to ensure mutual 
			exclusion the whole scheduler will be locked.  This is just for
			demo purposes! */
			vTaskSuspendAll();
			{
				if( ulLastCounter == ulCounter )
				{
					/* The shared variable has not changed.  There is a problem
					with the continuous count task so flag an error. */
					sError = pdTRUE;
				}
			}
			xTaskResumeAll();
		}


		/* Second section: */

		/* Suspend the continuous counter task so it stops accessing the shared variable. */
		vTaskSuspend( xContinousIncrementHandle );

		/* Reset the variable. */
		ulCounter = ( unsigned portLONG ) 0;

		/* Resume the limited count task which has a higher priority than us.
		We should therefore not return from this call until the limited count
		task has suspended itself with a known value in the counter variable. */
		vTaskResume( xLimitedIncrementHandle );

		/* Does the counter variable have the expected value? */
		if( ulCounter != priMAX_COUNT )
		{
			sError = pdTRUE;
		}

		if( sError == pdFALSE )
		{
			/* If no errors have occurred then increment the check variable. */
			portENTER_CRITICAL();
				usCheckVariable++;
			portEXIT_CRITICAL();
		}

		/* Resume the continuous count task and do it all again. */
		vTaskResume( xContinousIncrementHandle );
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vQueueSendWhenSuspendedTask, pvParameters )
{
static unsigned portLONG ulValueToSend = ( unsigned portLONG ) 0;

	/* Just to stop warning messages. */
	( void ) pvParameters;

	for( ;; )
	{
		vTaskSuspendAll();
		{
			/* We must not block while the scheduler is suspended! */
			if( xQueueSend( xSuspendedTestQueue, ( void * ) &ulValueToSend, priNO_BLOCK ) != pdTRUE )
			{
				xSuspendedQueueSendError = pdTRUE;
			}
		}
		xTaskResumeAll();

		vTaskDelay( priSLEEP_TIME );

		++ulValueToSend;
	}
}
/*-----------------------------------------------------------*/

static portTASK_FUNCTION( vQueueReceiveWhenSuspendedTask, pvParameters )
{
static unsigned portLONG ulExpectedValue = ( unsigned portLONG ) 0, ulReceivedValue;
portBASE_TYPE xGotValue;

	/* Just to stop warning messages. */
	( void ) pvParameters;

	for( ;; )
	{
		do
		{
			/* Suspending the scheduler here is fairly pointless and 
			undesirable for a normal application.  It is done here purely
			to test the scheduler.  The inner xTaskResumeAll() should
			never return pdTRUE as the scheduler is still locked by the
			outer call. */
			vTaskSuspendAll();
			{
				vTaskSuspendAll();
				{
					xGotValue = xQueueReceive( xSuspendedTestQueue, ( void * ) &ulReceivedValue, priNO_BLOCK );
				}
				if( xTaskResumeAll() )
				{
					xSuspendedQueueReceiveError = pdTRUE;
				}
			}
			xTaskResumeAll();

		} while( xGotValue == pdFALSE );

		if( ulReceivedValue != ulExpectedValue )
		{
			xSuspendedQueueReceiveError = pdTRUE;
		}

		++ulExpectedValue;
	}
}
/*-----------------------------------------------------------*/

/* Called to check that all the created tasks are still running without error. */
portBASE_TYPE xAreDynamicPriorityTasksStillRunning( void )
{
/* Keep a history of the check variables so we know if it has been incremented 
since the last call. */
static unsigned portSHORT usLastTaskCheck = ( unsigned portSHORT ) 0;
portBASE_TYPE xReturn = pdTRUE;

	/* Check the tasks are still running by ensuring the check variable
	is still incrementing. */

	if( usCheckVariable == usLastTaskCheck )
	{
		/* The check has not incremented so an error exists. */
		xReturn = pdFALSE;
	}

	if( xSuspendedQueueSendError == pdTRUE )
	{
		xReturn = pdFALSE;
	}

	if( xSuspendedQueueReceiveError == pdTRUE )
	{
		xReturn = pdFALSE;
	}

	usLastTaskCheck = usCheckVariable;
	return xReturn;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线亚洲高清视频| 欧美国产丝袜视频| 久久久国际精品| 一区二区欧美视频| 成人一道本在线| 日韩欧美一级精品久久| 亚洲美女在线国产| 高清在线不卡av| 精品精品欲导航| 日韩电影免费在线看| 日本韩国欧美一区| 国产精品妹子av| 国产精品一级在线| 精品国产不卡一区二区三区| 丝袜诱惑制服诱惑色一区在线观看| 不卡免费追剧大全电视剧网站| 久久先锋资源网| 青青草原综合久久大伊人精品| 在线视频国产一区| 国产精品网站在线| 国产91精品免费| 欧美成人vr18sexvr| 午夜精品国产更新| 欧美日韩五月天| 亚洲精品久久久蜜桃| 成人动漫一区二区三区| 国产片一区二区| 成人手机在线视频| 国产精品久久福利| av男人天堂一区| 中文字幕在线观看一区二区| 国产不卡视频在线播放| 国产日韩欧美麻豆| 国产91精品一区二区| 国产精品色呦呦| www.欧美日韩国产在线| 中文字幕亚洲综合久久菠萝蜜| 粉嫩av一区二区三区在线播放 | 国产视频一区不卡| 天天免费综合色| 欧美精品乱码久久久久久按摩 | 国产欧美日韩精品一区| 成人影视亚洲图片在线| 国产亚洲va综合人人澡精品 | 色综合色狠狠综合色| 亚洲精品久久7777| 欧美日韩成人综合天天影院| 亚洲综合区在线| 91精品婷婷国产综合久久 | 91超碰这里只有精品国产| 视频一区二区中文字幕| 日韩欧美在线观看一区二区三区| 久久国产精品露脸对白| 国产精品久久久久久久久免费丝袜 | 国产精品色一区二区三区| 91香蕉国产在线观看软件| 亚洲一区二区三区四区五区黄 | 免费观看91视频大全| 国产欧美日韩视频在线观看| 97精品久久久久中文字幕| 亚洲午夜一区二区| 久久夜色精品一区| 91亚洲永久精品| 丝袜诱惑制服诱惑色一区在线观看| 精品免费一区二区三区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 亚洲欧美日韩国产综合在线 | 97精品电影院| 日本成人中文字幕在线视频| 国产性天天综合网| 欧美亚洲动漫精品| 国产精品一区二区久久精品爱涩 | 韩国女主播一区二区三区| 亚洲三级在线观看| 日韩精品最新网址| 色婷婷亚洲精品| 国产一区不卡在线| 亚洲超丰满肉感bbw| 国产精品久久久久天堂| 欧美va在线播放| 色婷婷国产精品| 国产精品乡下勾搭老头1| 亚洲成a人v欧美综合天堂| 中文字幕欧美日韩一区| 欧美xxxxx裸体时装秀| 欧美日韩国产高清一区| 99久久精品久久久久久清纯| 国内精品视频666| 五月婷婷激情综合| 亚洲女人****多毛耸耸8| 国产视频亚洲色图| 久久综合九色欧美综合狠狠| 欧美精品18+| 在线观看成人免费视频| 北条麻妃一区二区三区| 国产一区二区三区国产| 久久精品久久久精品美女| 亚洲高清视频中文字幕| 亚洲品质自拍视频网站| 国产精品久久久久久久久免费相片 | 在线观看欧美精品| av影院午夜一区| 国内精品视频666| 久久不见久久见中文字幕免费| 亚洲成a人片在线不卡一二三区| 亚洲男同性恋视频| 欧美国产一区在线| 国产欧美日本一区二区三区| 欧美精品一区男女天堂| 91精品国产综合久久香蕉麻豆| 欧美在线播放高清精品| 91一区二区在线| 91免费精品国自产拍在线不卡| 99国产精品99久久久久久| 91在线视频官网| 99在线视频精品| 91亚洲精品一区二区乱码| 99国产精品久| 欧美亚洲禁片免费| 69堂精品视频| 欧美一级欧美一级在线播放| 日韩一区二区视频在线观看| 日韩欧美国产一区二区三区| 精品奇米国产一区二区三区| 国产亚洲一区二区三区四区| 国产精品美女一区二区三区 | 国产精品一二三区| 不卡一卡二卡三乱码免费网站 | 国产激情一区二区三区| jlzzjlzz亚洲日本少妇| 欧美体内she精视频| 欧美一区二区三区思思人| 欧美xxxx老人做受| 国产精品天干天干在观线| 亚洲欧美日韩综合aⅴ视频| 亚洲成av人片一区二区三区 | 国产亚洲精品精华液| 亚洲天天做日日做天天谢日日欢 | 欧美一区二区国产| 国产视频在线观看一区二区三区 | 国产日韩精品一区二区三区| 中文字幕一区二区三区四区| 一区二区三区中文在线观看| 日韩高清不卡一区二区| 国产在线精品一区在线观看麻豆| zzijzzij亚洲日本少妇熟睡| 欧美日韩一区二区三区不卡| 精品免费99久久| 国产精品福利一区二区三区| 亚洲va欧美va人人爽| 国产精品综合一区二区三区| 色菇凉天天综合网| 久久综合色鬼综合色| 亚洲美女一区二区三区| 国产乱子轮精品视频| 欧美剧在线免费观看网站| 中文字幕不卡在线观看| 日韩高清电影一区| 色综合天天综合网国产成人综合天 | 欧美日本免费一区二区三区| 久久人人97超碰com| 亚洲国产欧美一区二区三区丁香婷| 国产一区二区美女诱惑| 欧美三级韩国三级日本一级| 久久久久久9999| 午夜一区二区三区视频| 成人动漫在线一区| 久久午夜电影网| 午夜久久久久久| 97aⅴ精品视频一二三区| 亚洲精品在线观看网站| 亚洲国产成人av| jlzzjlzz亚洲女人18| 国产亚洲视频系列| 精品在线免费视频| 欧美丰满美乳xxx高潮www| 亚洲欧美一区二区三区国产精品 | 色8久久人人97超碰香蕉987| 久久精品这里都是精品| 九九国产精品视频| 欧美日韩国产中文| 伊人婷婷欧美激情| a在线播放不卡| 久久久久99精品一区| 麻豆国产91在线播放| 91精品久久久久久久99蜜桃 | 日韩伦理免费电影| 福利一区二区在线观看| 久久久www成人免费毛片麻豆 | 日本三级韩国三级欧美三级| 欧美日韩在线三级| 亚洲制服欧美中文字幕中文字幕| av中文字幕在线不卡| 国产精品免费免费| av色综合久久天堂av综合| 最新日韩av在线| 91社区在线播放| 亚洲色图欧洲色图| 在线观看国产精品网站| 亚洲影视在线播放|