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

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

?? croutine.c

?? 一個開源的Modbus協議棧
?? 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.

	***************************************************************************

*/



#include "FreeRTOS.h"

#include "task.h"

#include "croutine.h"



/* Lists for ready and blocked co-routines. --------------------*/

static xList pxReadyCoRoutineLists[ configMAX_CO_ROUTINE_PRIORITIES ];	/*< Prioritised ready co-routines. */

static xList xDelayedCoRoutineList1;									/*< Delayed co-routines. */

static xList xDelayedCoRoutineList2;									/*< Delayed co-routines (two lists are used - one for delays that have overflowed the current tick count. */

static xList * pxDelayedCoRoutineList;									/*< Points to the delayed co-routine list currently being used. */

static xList * pxOverflowDelayedCoRoutineList;							/*< Points to the delayed co-routine list currently being used to hold co-routines that have overflowed the current tick count. */

static xList xPendingReadyList;											/*< Holds co-routines that have been readied by an external event.  They cannot be added directly to the ready lists as the ready lists cannot be accessed by interrupts. */



/* Other file private variables. --------------------------------*/

corCRCB * pxCurrentCoRoutine = NULL;

static unsigned portBASE_TYPE uxTopCoRoutineReadyPriority = 0;

static portTickType xCoRoutineTickCount = 0;



/* The initial state of the co-routine when it is created. */

#define corINITIAL_STATE	( 0 )



/*

 * Place the co-routine represented by pxCRCB into the appropriate ready queue

 * for the priority.  It is inserted at the end of the list.

 *

 * This macro accesses the co-routine ready lists and therefore must not be

 * used from within an ISR.

 */

#define prvAddCoRoutineToReadyQueue( pxCRCB )																		\

{																													\

	if( pxCRCB->uxPriority > uxTopCoRoutineReadyPriority )															\

	{																												\

		uxTopCoRoutineReadyPriority = pxCRCB->uxPriority;															\

	}																												\

	vListInsertEnd( ( xList * ) &( pxReadyCoRoutineLists[ pxCRCB->uxPriority ] ), &( pxCRCB->xGenericListItem ) );	\

}	



/*

 * Utility to ready all the lists used by the scheduler.  This is called

 * automatically upon the creation of the first co-routine.

 */

static void prvInitialiseCoRoutineLists( void );



/*

 * Co-routines that are readied by an interrupt cannot be placed directly into

 * the ready lists (there is no mutual exclusion).  Instead they are placed in

 * in the pending ready list in order that they can later be moved to the ready

 * list by the co-routine scheduler.

 */

static inline void prvCheckPendingReadyList( void );



/*

 * Macro that looks at the list of co-routines that are currently delayed to

 * see if any require waking.

 *

 * Co-routines are stored in the queue in the order of their wake time -

 * meaning once one co-routine has been found whose timer has not expired

 * we need not look any further down the list.

 */

static inline void prvCheckDelayedList( void );



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



signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex )

{

signed portBASE_TYPE xReturn;

corCRCB *pxCoRoutine;



	/* Allocate the memory that will store the co-routine control block. */

	pxCoRoutine = ( corCRCB * ) pvPortMalloc( sizeof( corCRCB ) );

	if( pxCoRoutine )

	{

		/* If pxCurrentCoRoutine is NULL then this is the first co-routine to

		be created and the co-routine data structures need initialising. */

		if( pxCurrentCoRoutine == NULL )

		{

			pxCurrentCoRoutine = pxCoRoutine;

			prvInitialiseCoRoutineLists();

		}



		/* Check the priority is within limits. */

		if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )

		{

			uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;

		}



		/* Fill out the co-routine control block from the function parameters. */

		pxCoRoutine->uxState = corINITIAL_STATE;

		pxCoRoutine->uxPriority = uxPriority;

		pxCoRoutine->uxIndex = uxIndex;

		pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;



		/* Initialise all the other co-routine control block parameters. */

		vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );

		vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );



		/* Set the co-routine control block as a link back from the xListItem.

		This is so we can get back to the containing CRCB from a generic item

		in a list. */

		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );

		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );

	

		/* Event lists are always in priority order. */

		listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority );

		

		/* Now the co-routine has been initialised it can be added to the ready

		list at the correct priority. */

		prvAddCoRoutineToReadyQueue( pxCoRoutine );



		xReturn = pdPASS;

	}

	else

	{		

		xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;

	}

	

	return xReturn;	

}

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



void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList )

{

portTickType xTimeToWake;



	/* Calculate the time to wake - this may overflow but this is

	not a problem. */

	xTimeToWake = xCoRoutineTickCount + xTicksToDelay;



	/* We must remove ourselves from the ready list before adding

	ourselves to the blocked list as the same list item is used for

	both lists. */

	vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );



	/* The list item will be inserted in wake time order. */

	listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );



	if( xTimeToWake < xCoRoutineTickCount )

	{

		/* Wake time has overflowed.  Place this item in the

		overflow list. */

		vListInsert( ( xList * ) pxOverflowDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );

	}

	else

	{

		/* The wake time has not overflowed, so we can use the

		current block list. */

		vListInsert( ( xList * ) pxDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );

	}



	if( pxEventList )

	{

		/* Also add the co-routine to an event list.  If this is done then the

		function must be called with interrupts disabled. */

		vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );

	}

}

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



static inline void prvCheckPendingReadyList( void )

{

	/* Are there any co-routines waiting to get moved to the ready list?  These

	are co-routines that have been readied by an ISR.  The ISR cannot access

	the	ready lists itself. */

	while( !listLIST_IS_EMPTY( &xPendingReadyList ) )

	{

		corCRCB *pxUnblockedCRCB;



		/* The pending ready list can be accessed by an ISR. */

		portDISABLE_INTERRUPTS();

		{	

			pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyList) );			

			vListRemove( &( pxUnblockedCRCB->xEventListItem ) );

		}

		portENABLE_INTERRUPTS();



		vListRemove( &( pxUnblockedCRCB->xGenericListItem ) );

		prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );	

	}

}

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



static inline void prvCheckDelayedList( void )

{

static portTickType xLastTickCount, xPassedTicks;

corCRCB *pxCRCB;



	xPassedTicks = xTaskGetTickCount() - xLastTickCount;

	while( xPassedTicks )

	{

		xCoRoutineTickCount++;

		xPassedTicks--;



		/* If the tick count has overflowed we need to swap the ready lists. */

		if( xCoRoutineTickCount == 0 )

		{

			xList * pxTemp;



			/* Tick count has overflowed so we need to swap the delay lists.  If there are

			any items in pxDelayedCoRoutineList here then there is an error! */

			pxTemp = pxDelayedCoRoutineList;

			pxDelayedCoRoutineList = pxOverflowDelayedCoRoutineList;

			pxOverflowDelayedCoRoutineList = pxTemp;

		}



		/* See if this tick has made a timeout expire. */

		while( ( pxCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedCoRoutineList ) ) != NULL )

		{	

			if( xCoRoutineTickCount < listGET_LIST_ITEM_VALUE( &( pxCRCB->xGenericListItem ) ) )				

			{			

				/* Timeout not yet expired. */																			

				break;																				

			}																						



			portDISABLE_INTERRUPTS();

			{

				/* The event could have occurred just before this critical

				section.  If this is the case then the generic list item will

				have been moved to the pending ready list and the following

				line is still valid.  Also the pvContainer parameter will have

				been set to NULL so the following lines are also valid. */

				vListRemove( &( pxCRCB->xGenericListItem ) );											



				/* Is the co-routine waiting on an event also? */												

				if( pxCRCB->xEventListItem.pvContainer )													

				{															

					vListRemove( &( pxCRCB->xEventListItem ) );											

				}

			}

			portENABLE_INTERRUPTS();



			prvAddCoRoutineToReadyQueue( pxCRCB );													

		}																									

	}



	xLastTickCount = xCoRoutineTickCount;

}

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



void vCoRoutineSchedule( void )

{

	/* See if any co-routines readied by events need moving to the ready lists. */

	prvCheckPendingReadyList();



	/* See if any delayed co-routines have timed out. */

	prvCheckDelayedList();



	/* Find the highest priority queue that contains ready co-routines. */

	while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )

	{

		if( uxTopCoRoutineReadyPriority == 0 )

		{

			/* No more co-routines to check. */

			return;

		}

		--uxTopCoRoutineReadyPriority;

	}



	/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines

	 of the	same priority get an equal share of the processor time. */

	listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );



	/* Call the co-routine. */

	( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );



	return;

}

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



static void prvInitialiseCoRoutineLists( void )

{

unsigned portBASE_TYPE uxPriority;



	for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )

	{

		vListInitialise( ( xList * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );

	}



	vListInitialise( ( xList * ) &xDelayedCoRoutineList1 );

	vListInitialise( ( xList * ) &xDelayedCoRoutineList2 );

	vListInitialise( ( xList * ) &xPendingReadyList );



	/* Start with pxDelayedCoRoutineList using list1 and the

	pxOverflowDelayedCoRoutineList using list2. */

	pxDelayedCoRoutineList = &xDelayedCoRoutineList1;

	pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;

}

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



signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList )

{

corCRCB *pxUnblockedCRCB;

signed portBASE_TYPE xReturn;



	/* This function is called from within an interrupt.  It can only access

	event lists and the pending ready list. */

	pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );

	vListRemove( &( pxUnblockedCRCB->xEventListItem ) );

	vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxUnblockedCRCB->xEventListItem ) );



	if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )

	{

		xReturn = pdTRUE;

	}

	else

	{

		xReturn = pdFALSE;

	}



	return xReturn;

}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产激情一区二区三区四区| 高清在线不卡av| 国产精品每日更新在线播放网址| 欧美日韩视频在线一区二区| 精品一区二区三区欧美| 亚洲精品成人悠悠色影视| 日韩女优制服丝袜电影| 欧美亚洲高清一区| 成人综合在线网站| 久久国产夜色精品鲁鲁99| 一区二区三区在线不卡| 国产精品女上位| 精品剧情在线观看| 8x8x8国产精品| 色综合久久久久综合99| 国产成人免费视频一区| 精品一区二区三区免费视频| 伊人开心综合网| 国产精品美女久久久久久| 久久综合av免费| 欧美一区二区三区日韩| 欧美日韩中文另类| 在线看国产日韩| 色八戒一区二区三区| 99视频一区二区三区| 国产麻豆精品一区二区| 久久精品免费观看| 美国十次综合导航| 精品一区二区av| 亚洲成人av一区| 亚洲一区影音先锋| 一区二区三区色| 一区二区三区四区激情| 亚洲精品大片www| 一区二区三区影院| 夜夜爽夜夜爽精品视频| 亚洲欧美二区三区| 一区二区三区四区中文字幕| 一区二区三区色| 亚洲国产精品综合小说图片区| 一区二区成人在线| 亚洲亚洲精品在线观看| 亚洲韩国一区二区三区| 婷婷亚洲久悠悠色悠在线播放| 亚洲成a人v欧美综合天堂下载| 亚洲国产精品天堂| 日韩电影在线观看网站| 美国欧美日韩国产在线播放| 蜜桃视频在线观看一区二区| 久久激情五月激情| 国产精品 日产精品 欧美精品| 国产大陆a不卡| 成人性色生活片免费看爆迷你毛片| 国产成a人亚洲精品| 91视频在线观看免费| 在线免费观看日本欧美| 欧美精品tushy高清| 欧美va亚洲va在线观看蝴蝶网| 久久青草欧美一区二区三区| 欧美极品美女视频| 亚洲精品成人a在线观看| 五月综合激情网| 国产一区在线看| 一本久久a久久免费精品不卡| 欧美日韩国产经典色站一区二区三区| 欧美精品v国产精品v日韩精品| 欧美成人午夜电影| 国产精品久久三| 午夜欧美一区二区三区在线播放| 精品一区二区影视| 91免费国产在线| 日韩小视频在线观看专区| 久久蜜臀精品av| 亚洲一区二区三区四区的| 久久精品72免费观看| 91小视频免费看| 制服丝袜av成人在线看| 国产精品欧美综合在线| 亚洲二区在线观看| 国产成人在线观看免费网站| 欧美在线观看18| 久久女同精品一区二区| 亚洲福中文字幕伊人影院| 国产电影一区二区三区| 欧美日韩国产首页| 国产精品人人做人人爽人人添 | 亚洲欧美日韩成人高清在线一区| 亚洲国产va精品久久久不卡综合 | 99精品黄色片免费大全| 欧美一级艳片视频免费观看| 中文字幕免费观看一区| 亚洲国产精品精华液网站| 国内精品伊人久久久久av影院 | 五月天网站亚洲| 国产一区二区不卡在线| 欧美视频中文字幕| 国产欧美日韩亚州综合| 五月天亚洲精品| 99精品国产91久久久久久| 欧美成人高清电影在线| 亚洲美女免费视频| 国产成人啪免费观看软件| 欧美一级二级三级乱码| 伊人开心综合网| 99久久99久久精品免费观看| 日韩精品中文字幕一区二区三区 | 成人一区二区三区中文字幕| 337p亚洲精品色噜噜狠狠| 中文字幕在线一区免费| 久久av资源站| 欧美久久久久久久久中文字幕| 亚洲人成7777| 懂色av一区二区三区蜜臀| 精品久久人人做人人爰| 日韩av一区二区三区四区| 欧美亚洲一区二区三区四区| 国产精品色婷婷| 成人激情综合网站| 久久精品日产第一区二区三区高清版| 青青草精品视频| 欧美日韩成人在线一区| 亚洲国产成人精品视频| 一本色道久久综合狠狠躁的推荐| 国产人久久人人人人爽| 国产在线精品一区二区| 精品久久久久av影院| 日本午夜一本久久久综合| 欧美日韩日日摸| 亚洲福利一二三区| 欧美日韩精品一区二区三区| 一二三四区精品视频| 欧美丝袜丝nylons| 婷婷成人激情在线网| 欧美日韩国产综合一区二区| 亚洲自拍偷拍综合| 欧美日韩视频一区二区| 亚洲国产精品人人做人人爽| 欧美在线观看一区二区| 亚洲一区二区在线播放相泽 | 国产精品久久久爽爽爽麻豆色哟哟| 国精品**一区二区三区在线蜜桃| 精品美女一区二区| 国产精品亚洲一区二区三区妖精| 久久亚区不卡日本| 成人精品一区二区三区四区 | 亚洲丝袜精品丝袜在线| 色综合一个色综合亚洲| 亚洲综合免费观看高清完整版| 在线观看欧美黄色| 日本不卡中文字幕| 精品欧美久久久| 粉嫩av亚洲一区二区图片| 日本欧美一区二区在线观看| 日韩视频在线你懂得| 国产欧美精品日韩区二区麻豆天美 | 亚洲自拍偷拍九九九| 在线亚洲高清视频| 婷婷开心久久网| 2020国产精品| 大胆亚洲人体视频| 一区二区在线看| 欧美一级片在线| 国产精品91一区二区| 国产精品不卡在线| 欧美日本国产视频| 精品一区二区三区蜜桃| 亚洲欧洲无码一区二区三区| 欧美中文字幕一区二区三区亚洲| 天天综合天天做天天综合| 2014亚洲片线观看视频免费| a亚洲天堂av| 人人狠狠综合久久亚洲| 久久久av毛片精品| 欧美色综合久久| 国产美女主播视频一区| 亚洲男人的天堂在线观看| 91精品中文字幕一区二区三区| 国产一区二区三区四| 亚洲男人的天堂在线观看| 正在播放亚洲一区| www.久久精品| 麻豆国产精品一区二区三区| 自拍av一区二区三区| 日韩一二三区视频| 91丝袜美腿高跟国产极品老师 | 亚洲中国最大av网站| 精品国产一区二区精华| 一本大道久久a久久综合| 美国三级日本三级久久99| 一区二区三区精品在线观看| 日韩精品一区二区三区视频| 91一区在线观看| 激情文学综合网| 亚洲国产成人tv| 《视频一区视频二区| 337p日本欧洲亚洲大胆色噜噜| 精品视频资源站| 一道本成人在线| 国产成人精品免费| 久久国产乱子精品免费女|