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

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

?? objqueue.cpp

?? 小型的操作系統開發的原代碼
?? CPP
字號:
//***********************************************************************/
//    Author                    : Garry
//    Original Date             : Oct,18 2004
//    Module Name               : objqueue.cpp
//    Module Funciton           : 
//                                This module countains Object Queue's implementation code.
//    Last modified Author      :
//    Last modified Date        :
//    Last modified Content     :
//                                1.
//                                2.
//    Lines number              :
//***********************************************************************/

#ifndef __STDAFX_H__
#include "StdAfx.h"
#endif

//
//Insert an element into Priority Queue.
//This routine insert an common object into priority queue,it's position in the queue is
//determined by the object's priority(dwPriority parameter).
//

static BOOL InsertIntoQueue(__COMMON_OBJECT* lpThis,__COMMON_OBJECT* lpObject,DWORD dwPriority)
{
	__PRIORITY_QUEUE_ELEMENT*    lpQueueElement  =  NULL;
	__PRIORITY_QUEUE_ELEMENT*    lpPrevElement   =  NULL;
	__PRIORITY_QUEUE_ELEMENT*    lpNextElement   =  NULL;
	__PRIORITY_QUEUE*            lpPriorityQueue =  NULL;
	BOOL                         bResult         =  FALSE;
	DWORD                        dwFlags         = 0L;
	//BYTE                         strThread[12];
	//DWORD                        dwThread;

	if((NULL == lpThis) || (NULL == lpObject))
		return bResult;

	lpQueueElement = (__PRIORITY_QUEUE_ELEMENT*)
		KMemAlloc(sizeof(__PRIORITY_QUEUE_ELEMENT),KMEM_SIZE_TYPE_ANY);
	if(NULL == lpQueueElement)  //Failed to allocate memory.
	{
		//dwThread = (DWORD)KernelThreadManager.lpCurrentKernelThread;
		//Hex2Str(dwThread,strThread);
		PrintLine("InsertIntoQueue: Can not allocate memory.");
		//PrintLine("The current kernel thread is :");
		//PrintLine(strThread);
//__DEADLOOP:
		//goto __DEADLOOP;

		goto __TERMINAL;
	}

	lpQueueElement->lpObject      = lpObject;    //Initialize the queue element.
	lpQueueElement->dwPriority    = dwPriority;
	lpQueueElement->lpNextElement = NULL;
	lpQueueElement->lpPrevElement = NULL;

	lpPriorityQueue = (__PRIORITY_QUEUE*)lpThis;

	//ENTER_CRITICAL_SECTION();
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	if(NULL == lpPriorityQueue->lpElementHeader)    //If the priority queue is empty.
	{
		//DisableInterrupt();
		lpPriorityQueue->lpElementHeader = lpQueueElement;
		lpPriorityQueue->dwCurrElementNum ++;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		bResult = TRUE;
		goto __TERMINAL;
	}

	lpPrevElement = lpPriorityQueue->lpElementHeader;
	lpNextElement = lpPrevElement;
	while(lpPrevElement->dwPriority >= dwPriority)    //To find the correct position.
	{
		lpNextElement = lpPrevElement;
		lpPrevElement = lpPrevElement->lpNextElement;
		if(NULL == lpPrevElement)
			break;
	}
	if(NULL == lpPrevElement)  //This newly object should be the last object.
	{
		//DisableInterrupt();
		lpNextElement->lpNextElement  = lpQueueElement;
		lpQueueElement->lpPrevElement = lpNextElement;
		lpPriorityQueue->dwCurrElementNum ++;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		bResult = TRUE;
		goto __TERMINAL;
	}
	if(lpPrevElement == lpNextElement)  //This newly object should be the first object in the
		                                //current queue.
	{
		//DisableInterrupt();
		lpQueueElement->lpNextElement    = lpPrevElement;
		lpPrevElement->lpPrevElement     = lpQueueElement;
		lpPriorityQueue->lpElementHeader = lpQueueElement;
		lpPriorityQueue->dwCurrElementNum ++;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		bResult = TRUE;
		goto __TERMINAL;
	}
	else    //The object is not the first object,is not the last object too.
	{
		//DisableInterrupt();
		lpQueueElement->lpNextElement = lpPrevElement;
		lpQueueElement->lpPrevElement = lpNextElement;
		lpPrevElement->lpPrevElement  = lpQueueElement;
		lpNextElement->lpNextElement  = lpQueueElement;
		lpPriorityQueue->dwCurrElementNum ++;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		bResult = TRUE;
		goto __TERMINAL;
	}

__TERMINAL:
	return bResult;
}

//
//Delete an element from Priority Queue.
//This routine searchs the queue,to find the object to be deleted,
//if find,delete the object from priority queue,returns TRUE,else,
//returns FALSE.
//If the object is inserted into this queue for many times,this
//operation only deletes one time.
//

static BOOL DeleteFromQueue(__COMMON_OBJECT* lpThis,__COMMON_OBJECT* lpObject)
{
	__PRIORITY_QUEUE_ELEMENT*  lpFirstElement    = NULL;
	__PRIORITY_QUEUE_ELEMENT*  lpSecondElement   = NULL;
	__PRIORITY_QUEUE_ELEMENT*  lpCurrElement     = NULL;
	__PRIORITY_QUEUE*          lpPriorityQueue   = NULL;
	BOOL                       bResult           = FALSE;
	DWORD                      dwFlags           = 0L;

	if((NULL == lpThis) || (NULL == lpObject)) //Parameters check.
		goto __TERMINAL;

	lpPriorityQueue = (__PRIORITY_QUEUE*)lpThis;
	//lpCurrElement = lpPriorityQueue->lpElementHeader;
	//ENTER_CRITICAL_SECTION();
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	lpFirstElement = lpPriorityQueue->lpElementHeader;

	if(NULL == lpFirstElement)  //If the queue does not countain any object,terminal.
	{
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		goto __TERMINAL;
	}

	while(lpFirstElement->lpObject != lpObject)
	{
		lpFirstElement = lpFirstElement->lpNextElement;
		if(NULL == lpFirstElement)
			break;
	}

	if(NULL == lpFirstElement)  //The queue does not countain the object.
	{
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		goto __TERMINAL;
	}

	if(NULL == lpFirstElement->lpPrevElement)  //If the object to be deleted is the first
		                                       //object of the current priority queue.
	{
		//DisableInterrupt();
		if(lpFirstElement->lpNextElement != NULL)    //Not the last element.
		{
			lpPriorityQueue->lpElementHeader = lpFirstElement->lpNextElement;
			lpFirstElement->lpNextElement->lpPrevElement = NULL;
		}
		else    //This is the last element.
			lpPriorityQueue->lpElementHeader = NULL;

		lpPriorityQueue->dwCurrElementNum --;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		KMemFree((LPVOID)lpFirstElement,KMEM_SIZE_TYPE_ANY,0L);  //Free the memory.
		bResult = TRUE;
		goto __TERMINAL;
	}
	if(NULL == lpFirstElement->lpNextElement)  //The object to be deleted is the last object.
	{
		//DisableInterrupt();
		lpFirstElement->lpPrevElement->lpNextElement = NULL;
		lpPriorityQueue->dwCurrElementNum --;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		KMemFree((LPVOID)lpFirstElement,KMEM_SIZE_TYPE_ANY,0L);
		bResult = TRUE;
		goto __TERMINAL;
	}
	else    //The object to be deleted is not the first,is not the last too.
	{
		//DisableInterrupt();
		lpFirstElement->lpNextElement->lpPrevElement = lpFirstElement->lpPrevElement;
		lpFirstElement->lpPrevElement->lpNextElement = lpFirstElement->lpNextElement;
		lpPriorityQueue->dwCurrElementNum --;
		//EnableInterrupt();
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		KMemFree((LPVOID)lpFirstElement,KMEM_SIZE_TYPE_ANY,0L);
		bResult = TRUE;
	}

__TERMINAL:
	return bResult;
}

//
//Get the header element from Priority Queue.
//This routine get the first(header) object of the priority queue,
//and release the memory this element occupies.
//

static __COMMON_OBJECT* GetHeaderElement(__COMMON_OBJECT* lpThis,DWORD* lpPriority)
{
	__COMMON_OBJECT*          lpCommonObject    = NULL;
	__PRIORITY_QUEUE*         lpPriorityQueue   = NULL;
	__PRIORITY_QUEUE_ELEMENT* lpQueueElement    = NULL;
	DWORD                     dwFlags           = 0L;

	if(NULL == lpThis)
		return NULL;

	lpPriorityQueue = (__PRIORITY_QUEUE*)lpThis;

	//ENTER_CRITICAL_SECTION();
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	lpQueueElement = lpPriorityQueue->lpElementHeader;
	if(NULL == lpQueueElement)    //The queue is empty.
	{
		if(lpPriority != NULL)
			*lpPriority = 0L;
		//LEAVE_CRITICAL_SECTION();
		__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		return NULL;
	}

	lpPriorityQueue->lpElementHeader = lpQueueElement->lpNextElement;  //Update the queue's
	                                                                   //element header.
	lpPriorityQueue->lpElementHeader->lpPrevElement = NULL;            //Set to NULL indicates the
	                                                                   //first element.

	lpCommonObject = lpQueueElement->lpObject;
	if(lpPriority != NULL)
	{
		*lpPriority = lpQueueElement->dwPriority;    //Return the priority value.
	}
	//LEAVE_CRITICAL_SECTION();
	__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
	KMemFree((LPVOID)lpQueueElement,KMEM_SIZE_TYPE_ANY,0L);  //Release the queue element.

	return lpCommonObject;
}

//Initialize routine of the Priority Queue.
BOOL PriQueueInitialize(__COMMON_OBJECT* lpThis)
{
	__PRIORITY_QUEUE*                lpPriorityQueue     = NULL;
	BOOL                             bResult             = FALSE;

	if(NULL == lpThis)           //Parameter check.
		return bResult;

	//Initialize the Priority Queue.
	lpPriorityQueue = (__PRIORITY_QUEUE*)lpThis;
	lpPriorityQueue->lpElementHeader  = NULL;
	lpPriorityQueue->dwCurrElementNum = 0L;
	lpPriorityQueue->InsertIntoQueue  = InsertIntoQueue;
	lpPriorityQueue->DeleteFromQueue  = DeleteFromQueue;
	lpPriorityQueue->GetHeaderElement = GetHeaderElement;
	bResult = TRUE;

	return bResult;
}

//
//Uninitialize routine of Priority Queue.
//This routine frees all memory this priority queue occupies.
//

VOID PriQueueUninitialize(__COMMON_OBJECT* lpThis)
{
	__PRIORITY_QUEUE_ELEMENT*    lpFirstElement    = NULL;
	__PRIORITY_QUEUE_ELEMENT*    lpSecondElement   = NULL;
	__PRIORITY_QUEUE*            lpPriorityQueue   = NULL;

	if(NULL == lpThis)
		return;

	lpPriorityQueue = (__PRIORITY_QUEUE*)lpThis;
	lpFirstElement  = lpPriorityQueue->lpElementHeader;
	if(NULL == lpFirstElement)
		return;

	while(lpFirstElement)  //Release the memory this priority queue occupies.
	{
		lpSecondElement = lpFirstElement;
		lpFirstElement  = lpFirstElement->lpNextElement;
		KMemFree((LPVOID)lpSecondElement,KMEM_SIZE_TYPE_ANY,0L);  //Free the memory.
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品天美传媒沈樵| 欧美一区二区三区在线视频| 日本一区二区三区dvd视频在线| 国产精品一二一区| 久久久久国产一区二区三区四区| 成人网在线免费视频| 国产精品国产三级国产普通话99 | 日本精品一区二区三区高清| 亚洲主播在线播放| 日韩一区二区在线免费观看| 国模冰冰炮一区二区| 久久精品亚洲国产奇米99| 99re热视频精品| 亚洲午夜电影网| 日韩一级片网址| 国产91精品一区二区麻豆亚洲| 一区二区中文视频| 制服丝袜亚洲精品中文字幕| 国产经典欧美精品| 亚洲综合激情网| 日韩精品一区在线观看| 99久久精品免费看国产| 五月天婷婷综合| 国产日韩欧美一区二区三区乱码| 色婷婷精品久久二区二区蜜臀av| 青青国产91久久久久久| 亚洲欧洲韩国日本视频| 欧美一级xxx| 91亚洲精华国产精华精华液| 日本午夜精品一区二区三区电影| 国产精品无遮挡| 欧美一级淫片007| 91在线看国产| 精品一区二区免费在线观看| 亚洲黄色av一区| 久久免费美女视频| 欧美日韩国产免费| 不卡影院免费观看| 蜜桃视频在线观看一区二区| 国产精品久久久久久妇女6080| 欧美巨大另类极品videosbest| 风间由美一区二区三区在线观看| 日日骚欧美日韩| 日韩伦理电影网| 久久精品免费在线观看| 91精品国产综合久久精品| 99精品在线观看视频| 国产综合成人久久大片91| 亚洲丰满少妇videoshd| 国产精品久久久久久户外露出| 欧美第一区第二区| 欧美日韩一区二区三区视频| 99久久精品免费看| 国产高清精品久久久久| 久久成人免费日本黄色| 日日摸夜夜添夜夜添亚洲女人| 亚洲日本va午夜在线电影| 久久精品亚洲乱码伦伦中文| 日韩美女在线视频| 欧美一级搡bbbb搡bbbb| 欧美日本精品一区二区三区| 在线免费观看成人短视频| eeuss鲁一区二区三区| 国产iv一区二区三区| 激情综合一区二区三区| 久久狠狠亚洲综合| 日本成人在线不卡视频| 天堂成人免费av电影一区| 亚洲成人av一区二区三区| 亚洲自拍偷拍av| 亚洲一二三四区不卡| 亚洲一区二区美女| 一区二区视频免费在线观看| 亚洲精品写真福利| 亚洲蜜臀av乱码久久精品| 亚洲精品va在线观看| 亚洲欧美激情插| 一区二区三区四区中文字幕| 洋洋av久久久久久久一区| 亚洲另类色综合网站| 亚洲自拍都市欧美小说| 亚洲成av人综合在线观看| 日韩中文欧美在线| 日本午夜一本久久久综合| 裸体歌舞表演一区二区| 精东粉嫩av免费一区二区三区| 九九九久久久精品| 国产精品一二三区在线| 成人网在线播放| 91视频一区二区三区| 欧美日韩色一区| 日韩一卡二卡三卡国产欧美| 久久久久成人黄色影片| 中文字幕日韩精品一区| 一区二区三区.www| 日一区二区三区| 国内精品自线一区二区三区视频| 国产成+人+日韩+欧美+亚洲| a在线播放不卡| 欧美特级限制片免费在线观看| 欧美一区二区三区白人| 久久综合九色综合欧美亚洲| 国产精品视频观看| 亚洲国产精品天堂| 国产乱人伦偷精品视频不卡 | 色乱码一区二区三区88| 欧美美女一区二区| 久久婷婷综合激情| 亚洲人亚洲人成电影网站色| 亚洲国产一区二区在线播放| 久久99精品国产.久久久久久| 成人黄色电影在线| 欧美理论片在线| 国产午夜精品一区二区三区视频| 樱花影视一区二区| 激情欧美一区二区| 91碰在线视频| 久久婷婷国产综合国色天香| 亚洲激情欧美激情| 激情综合网天天干| 欧美性猛交xxxx黑人交| 久久久91精品国产一区二区三区| 一二三四社区欧美黄| 激情欧美一区二区三区在线观看| 在线日韩国产精品| 国产亚洲精久久久久久| 五月婷婷综合激情| 成人久久视频在线观看| 日韩一区二区在线观看视频| 亚洲色图视频免费播放| 韩国欧美国产1区| 欧美日韩在线精品一区二区三区激情| 国产欧美精品在线观看| 久久精品国产免费看久久精品| 色综合久久久久综合体| 久久久久久久久久久黄色 | 免费观看91视频大全| 91香蕉视频污| 久久久精品日韩欧美| 男人的天堂亚洲一区| 91黄色免费网站| 中文字幕日韩一区| 国产成人综合视频| 精品伦理精品一区| 偷窥少妇高潮呻吟av久久免费| 99久久精品国产导航| 欧美精品一区二区不卡| 日韩经典中文字幕一区| 欧美视频一区二区在线观看| 亚洲欧洲日本在线| 国产成人午夜精品影院观看视频| 8v天堂国产在线一区二区| 一区二区三区欧美激情| 99精品视频中文字幕| 国产精品色哟哟网站| 国产精品一区在线| 久久人人97超碰com| 狠狠久久亚洲欧美| 精品国产不卡一区二区三区| 蜜臀久久99精品久久久久久9| 欧美日韩成人综合| 亚洲一区二区三区免费视频| 欧美性做爰猛烈叫床潮| 亚洲一区二区三区四区的 | 欧美精品色一区二区三区| 夜夜精品浪潮av一区二区三区| av毛片久久久久**hd| 国产精品久久久久久久蜜臀| 成人激情图片网| 国产精品久久久99| 91亚洲精华国产精华精华液| 一区二区久久久久久| 欧美丝袜自拍制服另类| 婷婷夜色潮精品综合在线| 69堂成人精品免费视频| 日日夜夜免费精品| 日韩欧美一区中文| 精品影视av免费| 久久久久88色偷偷免费| 成人h动漫精品| 亚洲美女屁股眼交| 欧美日韩精品系列| 美腿丝袜亚洲色图| 久久久久久综合| 国产91在线观看| 综合久久综合久久| 欧美日韩国产高清一区二区| 免费的国产精品| 久久九九全国免费| 日本韩国一区二区三区| 日韩福利电影在线| 久久先锋影音av鲁色资源网| 成人美女在线观看| 亚洲国产成人tv| 欧美电视剧免费全集观看| 成人的网站免费观看| 亚洲国产精品影院| 久久久久久久久久美女| 91官网在线观看| 麻豆精品视频在线|