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

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

?? system.cpp

?? 小型的操作系統開發的原代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//***********************************************************************/
//    Author                    : Garry
//    Original Date             : Nov,06 2004
//    Module Name               : system.cpp
//    Module Funciton           : 
//                                This module countains system mechanism releated objects's
//                                implementation..
//                                Including the following aspect:
//                                1. Interrupt object and interrupt management code;
//                                2. Timer object and timer management code;
//                                3. System level parameters management coee,such as
//                                   physical memory,system time,etc;
//                                4. Other system mechanism releated objects.
//
//                                ************
//                                This file is one of the most important file of Hello China.
//                                ************
//    Last modified Author      :
//    Last modified Date        :
//    Last modified Content     :
//                                1.
//                                2.
//    Lines number              :
//***********************************************************************/

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

__PERF_RECORDER  TimerIntPr = {
	U64_ZERO,
	U64_ZERO,
	U64_ZERO,
	U64_ZERO};                  //Performance recorder object used to mesure
                                //the performance of timer interrupt.

//
//TimerInterruptHandler routine.
//The following routine is the most CRITICAL routine of kernel of Hello China.
//The routine does the following:
// 1. Schedule timer object;
// 2. Update the system level variables,such as dwClockTickCounter;
// 3. Schedule kernel thread(s).
//

static BOOL TimerInterruptHandler(LPVOID lpEsp,LPVOID)
{
	DWORD                     dwPriority        = 0L;
	__TIMER_OBJECT*           lpTimerObject     = 0L;
	__KERNEL_THREAD_MESSAGE   Msg                   ;
	__PRIORITY_QUEUE*         lpTimerQueue      = NULL;
	__PRIORITY_QUEUE*         lpSleepingQueue   = NULL;
	__KERNEL_THREAD_OBJECT*   lpKernelThread    = NULL;
	DWORD                     dwFlags           = 0L;

	if(NULL == lpEsp)    //Parameter check.
		return TRUE;

	if(System.dwClockTickCounter == System.dwNextTimerTick)     //Should schedule timer.
	{
		lpTimerQueue = System.lpTimerQueue;
		lpTimerObject = (__TIMER_OBJECT*)lpTimerQueue->GetHeaderElement(
			(__COMMON_OBJECT*)lpTimerQueue,
			&dwPriority);
		if(NULL == lpTimerObject)
			goto __CONTINUE_1;
		dwPriority = MAX_DWORD_VALUE - dwPriority;
		while(dwPriority <= System.dwNextTimerTick)    //Strictly speaking,the dwPriority
			                                           //variable must EQUAL System.dw-
													   //NextTimerTick,but in the implement-
													   //ing of the current version,there
													   //may be some error exists,so we assume
													   //dwPriority equal or less than dwNext-
													   //TimerTic.
		{
			if(NULL == lpTimerObject->DirectTimerHandler)  //Send a message to the kernel thread.
			{
				Msg.wCommand = KERNEL_MESSAGE_TIMER;
				Msg.dwParam  = lpTimerObject->dwTimerID;
				KernelThreadManager.SendMessage(
					(__COMMON_OBJECT*)lpTimerObject->lpKernelThread,
					&Msg);
				//PrintLine("Send a timer message to kernel thread.");
			}
			else
			{
				lpTimerObject->DirectTimerHandler(
					lpTimerObject->lpHandlerParam);    //Call the associated handler.
			}

			switch(lpTimerObject->dwTimerFlags)
			{
			case TIMER_FLAGS_ONCE:        //Delete the timer object processed just now.
				ObjectManager.DestroyObject(&ObjectManager,
					(__COMMON_OBJECT*)lpTimerObject);
				break;
			case TIMER_FLAGS_ALWAYS:    //Re-insert the timer object into timer queue.
				dwPriority  = lpTimerObject->dwTimeSpan;
				dwPriority /= SYSTEM_TIME_SLICE;
				dwPriority += System.dwClockTickCounter;
				dwPriority  = MAX_DWORD_VALUE - dwPriority;
				lpTimerQueue->InsertIntoQueue((__COMMON_OBJECT*)lpTimerQueue,
					(__COMMON_OBJECT*)lpTimerObject,
					dwPriority);
				break;
			default:
				break;
			}

			lpTimerObject = (__TIMER_OBJECT*)lpTimerQueue->GetHeaderElement(
				(__COMMON_OBJECT*)lpTimerQueue,
				&dwPriority);    //Check another timer object.
			if(NULL == lpTimerObject)
				break;
			dwPriority = MAX_DWORD_VALUE - dwPriority;
		}

		if(NULL == lpTimerObject)  //There is no timer object in queue.
		{
			__ENTER_CRITICAL_SECTION(NULL,dwFlags);
			System.dwNextTimerTick = 0L;
			__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		}
		else
		{
			__ENTER_CRITICAL_SECTION(NULL,dwFlags);
			System.dwNextTimerTick = dwPriority;    //Update the next timer tick counter.
			__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
			dwPriority = MAX_DWORD_VALUE - dwPriority;
			lpTimerQueue->InsertIntoQueue((__COMMON_OBJECT*)lpTimerQueue,
				(__COMMON_OBJECT*)lpTimerObject,
				dwPriority);
		}
	}

__CONTINUE_1:

	//
	//The following code wakes up all kernel thread(s) whose status is SLEEPING and
	//the time it(then) set is out.
	//
	if(System.dwClockTickCounter == KernelThreadManager.dwNextWakeupTick)  //There must existes
		                                                                   //kernel thread(s) to
																		   //be wake up.
	{
		lpSleepingQueue = KernelThreadManager.lpSleepingQueue;
		lpKernelThread  = (__KERNEL_THREAD_OBJECT*)lpSleepingQueue->GetHeaderElement(
			(__COMMON_OBJECT*)lpSleepingQueue,
			&dwPriority);
		while(lpKernelThread)
		{
			dwPriority = MAX_DWORD_VALUE - dwPriority;  //Now,dwPriority countains the tick
			                                            //counter value.
			if(dwPriority > System.dwClockTickCounter)
				break;    //This kernel thread should not be wake up.
			lpKernelThread->dwThreadStatus = KERNEL_THREAD_STATUS_READY;
			KernelThreadManager.AddReadyKernelThread(
				(__COMMON_OBJECT*)&KernelThreadManager,
				lpKernelThread);  //Insert the waked up kernel thread into ready queue.

			lpKernelThread = (__KERNEL_THREAD_OBJECT*)lpSleepingQueue->GetHeaderElement(
				(__COMMON_OBJECT*)lpSleepingQueue,
				&dwPriority);  //Check next kernel thread in sleeping queue.
		}
		if(NULL == lpKernelThread)
		{
			__ENTER_CRITICAL_SECTION(NULL,dwFlags);
			KernelThreadManager.dwNextWakeupTick = 0L;
			__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
		}
		else
		{
			__ENTER_CRITICAL_SECTION(NULL,dwFlags);
			KernelThreadManager.dwNextWakeupTick = dwPriority;
			__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
			dwPriority = MAX_DWORD_VALUE - dwPriority;
			lpSleepingQueue->InsertIntoQueue((__COMMON_OBJECT*)lpSleepingQueue,
				(__COMMON_OBJECT*)lpKernelThread,
				dwPriority);
		}
	}

	goto __TERMINAL;

__TERMINAL:
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	System.dwClockTickCounter ++;    //Update the system clock interrupt counter.
	__LEAVE_CRITICAL_SECTION(NULL,dwFlags);

	//KernelThreadManager.ScheduleFromInt((__COMMON_OBJECT*)&KernelThreadManager,
	//	lpEsp);

	return TRUE;
}


//
//The implementation of ConnectInterrupt routine of Interrupt Object.
//The routine do the following:
// 1. Insert the current object into interrupt object array(maintenanced by system object);
// 2. Set the object's data members correctly.
//

__COMMON_OBJECT* BOOL ConnectInterrupt(__COMMON_OBJECT*     lpThis,
							 __INTERRUPT_HANDLER  lpInterruptHandler,
							 LPVOID               lpHandlerParam,
							 UCHAR                ucVector,
							 UCHAR                ucReserved1,
							 UCHAR                ucReserved2,
							 UCHAR                ucInterruptMode,
							 BOOL                 bIfShared,
							 DWORD                dwCPUMask)
{
	__INTERRUPT_OBJECT*      lpInterrupt          = NULL;
	__INTERRUPT_OBJECT*      lpObjectRoot         = NULL;
	__SYSTEM*                lpSystem             = NULL;
	DWORD                    dwFlags              = 0L;

	if((NULL == lpThis) || (NULL == lpInterruptHandler))    //Parameters valid check.
		return NULL;

	if(ucVector >= MAX_INTERRUPT_VECTOR)                    //Impossible!!!
		return NULL;

	lpInterrupt = (__INTERRUPT_OBJECT*)
		ObjectManager.CreateObject(&ObjectManager,NULL,OBJECT_TYPE_INTERRUPT);
	if(NULL == lpInterrupt)    //Failed to create interrupt object.
		return FALSE;
	if(!lpInterrupt->Initialize((__COMMON_OBJECT*)lpInterrupt))  //Failed to initialize.
		return FALSE;

	lpInterrupt->lpPrevInterruptObject = NULL;
	lpInterrupt->lpNextInterruptObject = NULL;
	lpInterrupt->InterruptHandler      = lpInterruptHandler;
	lpInterrupt->lpHandlerParam        = lpHandlerParam;
	lpInterrupt->ucVector              = ucVector;

	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	lpObjectRoot = lpSystem->lpInterruptVector[ucVector];
	if(NULL == lpObjectRoot)    //If this is the first interrupt object of the vector.
	{
		System.lpInterruptVector[ucVector]  = lpInterrupt;
	}
	else
	{
		lpInterrupt->lpNextInterruptObject  = lpObjectRoot;
		lpObjectRoot->lpPrevInterruptObject = lpInterrupt;
		System.lpInterruptVector[ucVector]  = lpInterrupt;
	}
	//LEAVE_CRITICAL_SECTION();
	__LEAVE_CRITICAL_SECTION(NULL,dwFlags);

	return (__COMMON_OBJECT*)lpInterrupt;
}

//
//The implementation of DisconnectInterrupt.
//

static VOID DisconnectInterrupt(__COMMON_OBJECT* lpThis,
								__COMMON_OBJECT* lpInterrupt)
{
	__INTERRUPT_OBJECT*   lpIntObject    = NULL;
	__SYSTEM*             lpSystem       = NULL;
	UCHAR                 ucVector       = NULL;
	DWORD                 dwFlags        = 0L;

	if((NULL == lpThis) || (NULL == lpInterrupt)) //Parameters check.
		return;

	lpSystem = (__SYSTEM*)lpThis;
	lpIntObject = (__INTERRUPT_OBJECT*)lpInterrupt;
	ucVector    = lpIntObject->ucVector;

	//ENTER_CRITICAL_SECTION();
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	if(NULL == lpIntObject->lpPrevInterruptObject)  //This is the first interrupt object.
	{
		lpSystem->lpInterruptVector[ucVector] = lpIntObject->lpNextInterruptObject;
		if(NULL != lpIntObject->lpNextInterruptObject) //Is not the last object.
		{
			lpIntObject->lpNextInterruptObject->lpPrevInterruptObject = NULL;
		}
	}
	else    //This is not the first object.
	{
		lpIntObject->lpPrevInterruptObject->lpNextInterruptObject = lpIntObject->lpNextInterruptObject;
		if(NULL != lpIntObject->lpNextInterruptObject)
		{
			lpIntObject->lpNextInterruptObject->lpPrevInterruptObject = lpIntObject->lpPrevInterruptObject;
		}
	}
	//LEAVE_CRITICAL_SECTION();
	__LEAVE_CRITICAL_SECTION(NULL,dwFlags);
	return;
}

//
//The implementation of Initialize routine of interrupt object.
//

BOOL InterruptInitialize(__COMMON_OBJECT* lpThis)
{
	__INTERRUPT_OBJECT*    lpInterrupt = NULL;

	if(NULL == lpThis)
		return FALSE;

	lpInterrupt = (__INTERRUPT_OBJECT*)lpThis;
	lpInterrupt->lpPrevInterruptObject = NULL;
	lpInterrupt->lpNextInterruptObject = NULL;
	lpInterrupt->InterruptHandler      = NULL;
	lpInterrupt->lpHandlerParam        = NULL;
	lpInterrupt->ucVector              = 0L;
	return TRUE;
}

//
//The implementation of Uninitialize of interrupt object.
//This routine does nothing.
//

VOID InterruptUninitialize(__COMMON_OBJECT* lpThis)
{
	return;
}


//
//The implementation of timer object.
//

BOOL TimerInitialize(__COMMON_OBJECT* lpThis)    //Initializing routine of timer object.
{
	__TIMER_OBJECT*     lpTimer  = NULL;
	
	if(NULL == lpThis)
		return FALSE;

	lpTimer = (__TIMER_OBJECT*)lpThis;
	lpTimer->dwTimerID    = 0L;
	lpTimer->dwTimeSpan   = 0L;
	lpTimer->lpKernelThread      = NULL;
	lpTimer->lpHandlerParam      = NULL;
	lpTimer->DirectTimerHandler  = NULL;

	return TRUE;
}

//
//Uninitializing routine of timer object.
//

VOID TimerUninitialize(__COMMON_OBJECT* lpThis)
{
	return;
}

//-----------------------------------------------------------------------------------
//
//              The implementation of system object.
//
//------------------------------------------------------------------------------------

//
//Initializing routine of system object.
//The routine do the following:
// 1. Create a priority queue,to be used as lpTimerQueue,countains the timer object;
// 2. Create an interrupt object,as TIMER interrupt object;
// 3. Initialize system level variables,such as dwPhysicalMemorySize,etc.
//

static BOOL SystemInitialize(__COMMON_OBJECT* lpThis)
{
	__SYSTEM*            lpSystem         = NULL;
	__PRIORITY_QUEUE*    lpPriorityQueue  = NULL;
	__INTERRUPT_OBJECT*  lpIntObject      = NULL;
	BOOL                 bResult          = FALSE;
	DWORD                dwFlags          = 0L;

	if(NULL == lpThis)
		return FALSE;

	lpSystem = (__SYSTEM*)lpThis;
	lpPriorityQueue = (__PRIORITY_QUEUE*)ObjectManager.CreateObject(&ObjectManager,
		NULL,
		OBJECT_TYPE_PRIORITY_QUEUE);

	if(NULL == lpPriorityQueue)  //Failed to create priority queue.
		return FALSE;

	if(!lpPriorityQueue->Initialize((__COMMON_OBJECT*)lpPriorityQueue))  //Failed to initialize
		                                                                 //priority queue.
		goto __TERMINAL;
	lpSystem->lpTimerQueue = lpPriorityQueue;

	lpIntObject = (__INTERRUPT_OBJECT*)ObjectManager.CreateObject(
		&ObjectManager,
		NULL,
		OBJECT_TYPE_INTERRUPT);
	if(NULL == lpIntObject)
		goto __TERMINAL;

	bResult = lpIntObject->Initialize((__COMMON_OBJECT*)lpIntObject);
	if(!bResult)
		goto __TERMINAL;

	lpIntObject->ucVector = INTERRUPT_VECTOR_TIMER;
	lpIntObject->lpHandlerParam = NULL;
	lpIntObject->InterruptHandler = TimerInterruptHandler;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精三区欧美精三区| 成人免费一区二区三区在线观看| 精品久久久久一区| 国产精品久久久久久久蜜臀 | 欧美精品一区二区三区在线| 国产日韩v精品一区二区| 无码av免费一区二区三区试看 | 国产日韩欧美制服另类| 一区二区三区精品视频在线| 国模娜娜一区二区三区| 欧美午夜寂寞影院| 亚洲女人****多毛耸耸8| 国产精品123| 91精品国产综合久久香蕉麻豆 | 欧美精品一区二区三区蜜桃 | 亚洲激情成人在线| 国产精品99久久久久久久女警| 欧美男男青年gay1069videost| 国产精品萝li| 国产精品主播直播| 久久色.com| 日韩精品成人一区二区在线| 欧美sm极限捆绑bd| 午夜精品久久久久久久99樱桃| 99亚偷拍自图区亚洲| 国产精品免费视频观看| 国产剧情一区在线| 久久精品亚洲乱码伦伦中文| 国产综合一区二区| 久久久久久99久久久精品网站| 另类中文字幕网| 91精品国产欧美日韩| 日韩电影在线观看一区| 日韩一区二区视频| 日韩精品一卡二卡三卡四卡无卡| 欧美亚洲日本国产| 亚洲国产欧美在线| 欧美丰满高潮xxxx喷水动漫| 日韩国产高清影视| 日韩一区二区麻豆国产| 精品一区二区在线看| 日韩美女在线视频| 国产精品中文字幕日韩精品| 国产日韩综合av| 风流少妇一区二区| 亚洲视频一区二区在线观看| 色天使色偷偷av一区二区| 亚洲一区二区三区在线看| 欧美色综合天天久久综合精品| 亚洲福利国产精品| 日韩写真欧美这视频| 国产精品99久久久| 亚洲三级小视频| 欧美日韩一二三| 美女国产一区二区三区| 欧美精彩视频一区二区三区| 91麻豆6部合集magnet| 日韩激情中文字幕| 久久精品亚洲国产奇米99| 色菇凉天天综合网| 青青草成人在线观看| 中文字幕精品一区二区三区精品| 99综合影院在线| 另类调教123区| 国产精品嫩草影院com| 91精品中文字幕一区二区三区| 国产中文一区二区三区| 亚洲精品免费在线| 欧美久久一区二区| 成人性生交大片免费看中文网站| 亚洲制服丝袜av| 久久亚洲精品小早川怜子| 色狠狠一区二区三区香蕉| 日韩**一区毛片| 亚洲桃色在线一区| 欧美va亚洲va在线观看蝴蝶网| 97精品国产露脸对白| 久久99久久99| 亚洲综合偷拍欧美一区色| 久久―日本道色综合久久| 欧美最新大片在线看| 成人短视频下载| 美脚の诱脚舐め脚责91 | 久久99国产精品麻豆| 一区二区中文字幕在线| 日韩欧美国产综合| 色综合久久九月婷婷色综合| 精品一区二区三区欧美| 极品销魂美女一区二区三区| 亚洲视频一区在线| 精品久久国产字幕高潮| 欧洲视频一区二区| 成人精品一区二区三区四区| 日韩高清在线电影| 亚洲欧美电影一区二区| 久久久久久久网| 日韩欧美自拍偷拍| 亚洲蜜臀av乱码久久精品| 99久久久国产精品免费蜜臀| 尤物av一区二区| 日本一区二区在线不卡| 欧美丰满少妇xxxxx高潮对白| 91免费国产视频网站| 成人av在线网| 国产成人综合在线观看| 激情六月婷婷久久| 老司机精品视频导航| 麻豆成人91精品二区三区| 日韩高清国产一区在线| 亚洲第一久久影院| 亚洲免费大片在线观看| 亚洲人成影院在线观看| 日韩码欧中文字| 亚洲美女视频在线观看| 亚洲精品一卡二卡| 亚洲欧美一区二区三区久本道91| 1024成人网| 亚洲码国产岛国毛片在线| 自拍偷自拍亚洲精品播放| 国产精品久久久久aaaa樱花| 国产精品你懂的在线| 中文字幕成人av| 自拍偷拍亚洲欧美日韩| 亚洲另类在线一区| 亚洲乱码日产精品bd| 天堂精品中文字幕在线| 石原莉奈在线亚洲三区| 另类小说欧美激情| 国产美女视频91| 91一区二区三区在线播放| 日本韩国欧美国产| 在线不卡欧美精品一区二区三区| 欧美日韩大陆一区二区| 精品免费一区二区三区| 久久精品视频网| 亚洲激情男女视频| 免费在线观看一区| 国产乱人伦偷精品视频不卡| av亚洲精华国产精华精| 欧美色图免费看| 精品国产乱码91久久久久久网站| 久久九九久精品国产免费直播| 国产精品剧情在线亚洲| 久久国产精品72免费观看| 国产精品原创巨作av| 91丨porny丨最新| 91麻豆精品国产91久久久使用方法| 亚洲精品在线免费观看视频| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲天堂av老司机| 免费成人你懂的| 亚洲色图在线播放| 91成人网在线| 最新国产の精品合集bt伙计| 蜜桃视频在线观看一区二区| 亚洲h精品动漫在线观看| 在线观看免费亚洲| 一区二区激情小说| 国产偷国产偷精品高清尤物| 国产精品久久久久影院色老大| 一区二区三区在线视频播放| 精油按摩中文字幕久久| av激情综合网| 欧美一级欧美一级在线播放| 亚洲欧美在线视频| 韩国理伦片一区二区三区在线播放| 日本精品一级二级| 国产日产精品1区| 蜜臀av一区二区在线观看| 色综合激情五月| 久久精品网站免费观看| 三级影片在线观看欧美日韩一区二区| 岛国精品在线播放| 日韩视频一区二区三区 | 中文字幕不卡在线观看| 男女激情视频一区| 色诱亚洲精品久久久久久| 日韩一二三区视频| 午夜久久久久久久久久一区二区| 丁香婷婷综合色啪| 国产午夜精品一区二区三区嫩草 | 国产一区二区女| 17c精品麻豆一区二区免费| 91久久精品日日躁夜夜躁欧美| 欧美一区二区人人喊爽| 亚洲欧美日韩国产另类专区| 国产馆精品极品| 欧美大片在线观看一区二区| 亚洲成人在线网站| 欧美午夜精品久久久| 亚洲色图在线看| 99久久综合国产精品| 日本一区二区电影| 精品一区二区久久| 日韩一区二区三区四区| 日本成人在线一区| 欧美一级视频精品观看| 日韩精品一二三四| 日韩欧美中文一区| 免费看欧美女人艹b|