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

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

?? croutine.c

?? Modbus協議的源代碼 Modbus協議的源代碼、 Modbus協議的源代碼 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一区二区三区高| 欧美成人伊人久久综合网| 欧美麻豆精品久久久久久| 欧美性猛交xxxx黑人交| 欧美视频在线一区二区三区 | 国产精品免费视频观看| 久久久久久免费网| 久久久久久久久久久久电影| 国产亚洲欧美日韩日本| 欧美国产一区在线| 亚洲欧美在线aaa| 亚洲人成网站色在线观看| 一区二区三区在线影院| 亚洲福中文字幕伊人影院| 天堂在线亚洲视频| 国内精品视频666| 国产v日产∨综合v精品视频| 成av人片一区二区| 欧美在线视频不卡| 欧美一区二区三区成人| 久久久噜噜噜久久人人看| 国产精品拍天天在线| 亚洲另类色综合网站| 五月激情综合网| 国产精品88av| 97国产精品videossex| 欧美精三区欧美精三区| 亚洲精品在线观看网站| 亚洲三级在线免费| 婷婷久久综合九色综合伊人色| 久久国产福利国产秒拍| av一区二区三区四区| 欧美视频在线一区| 久久综合中文字幕| 一区二区三区在线观看视频| 美脚の诱脚舐め脚责91| 欧美电影影音先锋| 国产精品全国免费观看高清| 亚洲韩国精品一区| 国产不卡一区视频| 7777精品伊人久久久大香线蕉最新版| 久久精子c满五个校花| 亚洲乱码国产乱码精品精可以看| 久久爱www久久做| 91美女精品福利| 久久综合九色综合久久久精品综合 | 福利视频网站一区二区三区| 欧美亚州韩日在线看免费版国语版| 欧美不卡一区二区三区四区| 亚洲黄色在线视频| 成人综合在线视频| 欧美成人精品福利| 亚洲永久免费视频| 成人av在线电影| 久久久噜噜噜久噜久久综合| 日本不卡一区二区三区高清视频| 色呦呦国产精品| 中文av一区二区| 国内成人免费视频| 欧美一区2区视频在线观看| 亚洲精品久久久久久国产精华液| 国产白丝精品91爽爽久久| 精品国产三级电影在线观看| 日韩精品一区第一页| 欧美三级电影一区| 一区二区三区四区国产精品| 成人福利视频在线| 欧美激情一区二区三区不卡| 国产精品1区2区| 久久久久久夜精品精品免费| 国产美女精品人人做人人爽| 欧美草草影院在线视频| 九一九一国产精品| 日韩一区二区三区观看| 人人狠狠综合久久亚洲| 8v天堂国产在线一区二区| 性感美女极品91精品| 欧美日韩国产综合一区二区| 亚洲成人黄色小说| 欧美性色aⅴ视频一区日韩精品| 亚洲午夜视频在线观看| 欧美日韩一区二区三区四区| 亚洲成av人综合在线观看| 欧美日韩国产一级二级| 日本成人超碰在线观看| 欧美mv日韩mv国产网站app| 国产一区二区三区免费在线观看| 精品国产电影一区二区| 国产黄色精品网站| 国产精品久久久久一区| 在线视频欧美区| 天堂精品中文字幕在线| 日韩午夜激情视频| 国产成人小视频| 亚洲天堂中文字幕| 日本一区二区高清| 91尤物视频在线观看| 亚洲国产人成综合网站| 日韩一级高清毛片| 国产**成人网毛片九色| 亚洲欧美韩国综合色| 91精品国产高清一区二区三区| 九色porny丨国产精品| 国产精品国产成人国产三级| 欧日韩精品视频| 国产在线播精品第三| 综合色天天鬼久久鬼色| 91精品国产综合久久福利软件| 国产综合色视频| 亚洲丝袜制服诱惑| 日韩亚洲国产中文字幕欧美| 本田岬高潮一区二区三区| 亚洲a一区二区| 国产精品无圣光一区二区| 欧美精品99久久久**| 成人黄动漫网站免费app| 午夜视频在线观看一区| 国产欧美日韩卡一| 3d动漫精品啪啪| jiyouzz国产精品久久| 男人的天堂久久精品| ●精品国产综合乱码久久久久| 日韩一级视频免费观看在线| 色诱亚洲精品久久久久久| 国产综合色视频| 免费在线观看日韩欧美| 亚洲三级在线播放| 久久久久久久国产精品影院| 欧美日本在线视频| 色综合天天综合网天天看片| 国产一区二区网址| 日本在线观看不卡视频| 亚洲三级理论片| 国产欧美日韩麻豆91| 精品久久国产老人久久综合| 欧美无砖砖区免费| 91农村精品一区二区在线| 国产一区在线观看视频| 蜜臀99久久精品久久久久久软件| 亚洲一区二区三区视频在线播放| 欧美精彩视频一区二区三区| 亚洲精品一区二区三区精华液| 欧美日韩一二区| 欧美日韩mp4| 欧洲av一区二区嗯嗯嗯啊| 一本大道久久a久久精二百 | 日本一二三四高清不卡| 欧美精品一区二区久久婷婷| 日韩丝袜美女视频| 欧美一区二区在线免费观看| 欧美三级三级三级爽爽爽| 欧美在线视频日韩| 欧美视频一区二区在线观看| 欧洲精品在线观看| 欧美性做爰猛烈叫床潮| 欧美在线啊v一区| 色哟哟亚洲精品| 欧美性色aⅴ视频一区日韩精品| 91精彩视频在线| 欧美日韩精品欧美日韩精品一| 欧美高清激情brazzers| 欧美一级日韩不卡播放免费| 日韩一区二区精品葵司在线| 欧美成人一级视频| 国产日韩欧美电影| 精久久久久久久久久久| 国产一区不卡在线| 不卡欧美aaaaa| 日本道在线观看一区二区| 欧美日韩国产高清一区二区 | 精久久久久久久久久久| 国产精品资源在线看| 成人高清av在线| 在线国产电影不卡| 91精品国产综合久久国产大片| 欧美一区二区女人| 国产欧美一区二区精品秋霞影院| 国产精品嫩草久久久久| 亚洲高清视频的网址| 久久精品国产99国产| 成人黄色av网站在线| 欧美性色aⅴ视频一区日韩精品| 欧美成人精精品一区二区频| 国产日韩欧美a| 亚洲国产日产av| 国产成人免费视频| 欧美午夜精品久久久久久孕妇| 欧美一卡2卡3卡4卡| 成人欧美一区二区三区1314| 天天操天天干天天综合网| 高清不卡一区二区| 欧美乱妇23p| 亚洲色图一区二区三区| 免费久久99精品国产| 99视频精品全部免费在线| 9191成人精品久久| 亚洲欧洲日韩综合一区二区|