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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? scheduler.cpp

?? LINUX 下NACHOS 系統(tǒng)的頁(yè)面調(diào)度算法的實(shí)現(xiàn)
?? CPP
字號(hào):
// scheduler.cc //	Routines to choose the next thread to run, and to dispatch to//	that thread.//// 	These routines assume that interrupts are already disabled.//	If interrupts are disabled, we can assume mutual exclusion//	(since we are on a uniprocessor).//// 	NOTE: We can't use Locks to provide mutual exclusion here, since// 	if we needed to wait for a lock, and the lock was busy, we would //	end up calling FindNextToRun(), and that would put us in an //	infinite loop.//// 	Very simple implementation -- no priorities, straight FIFO.//	Might need to be improved in later assignments.//// Copyright (c) 1992-1993 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#include "copyright.h"#include "scheduler.h"#include "system.h"#include <stdio.h>//----------------------------------------------------------------------// Scheduler::Scheduler// 	Initialize the list of ready but not running threads to empty.//----------------------------------------------------------------------Scheduler::Scheduler(){     readyList = new List<Thread *>();     suspendedList = new List<Thread *>();} //----------------------------------------------------------------------// Scheduler::~Scheduler// 	De-allocate the list of ready threads.//----------------------------------------------------------------------Scheduler::~Scheduler(){     delete readyList;     delete suspendedList;} //----------------------------------------------------------------------// Scheduler::ReadyToRun// 	Mark a thread as ready, but not running.//	Put it on the ready list, for later scheduling onto the CPU.////	"thread" is the thread to be put on the ready list.//----------------------------------------------------------------------void Scheduler::ReadyToRun (Thread *thread){  DEBUG('t', "Putting thread %s on ready list.\n", thread->getName());  thread->setStatus(READY);  switch( policy )  {    case SCHED_FCFS:    case SCHED_RR:    case SCHED_PRIO_NP:    case SCHED_PRIO_P:    case SCHED_MLQ:    case SCHED_SJF:    case SCHED_MLFQ:    default:      readyList->Append( thread );      break;  }}//----------------------------------------------------------------------// Scheduler::FindNextToRun//----------------------------------------------------------------------Thread * Scheduler::FindNextToRun (){  return( readyList->Remove() );}//----------------------------------------------------------------------// Scheduler::ShouldISwitch//   This function uses the policy information to tell a thread::fork// to preempt the current thread or to not.  The answer is the domain of// the scheduler, so it is a member function call.//----------------------------------------------------------------------bool Scheduler::ShouldISwitch ( Thread  * oldThread, Thread * newThread ){  bool answer;  switch( policy )  {    case SCHED_FCFS:    case SCHED_PRIO_NP:    case SCHED_RR:    case SCHED_PRIO_P:    case SCHED_MLQ:    case SCHED_SJF:    case SCHED_MLFQ:    default:      answer = false;      break;  }  return answer;}//----------------------------------------------------------------------// Scheduler::Run// 	Dispatch the CPU to nextThread.  Save the state of the old thread,//	and load the state of the new thread, by calling the machine//	dependent context switch routine, SWITCH.////      Note: we assume the state of the previously running thread has//	already been changed from running to blocked or ready (depending).// Side effect://	The global variable currentThread becomes nextThread.////	"nextThread" is the thread to be put into the CPU.//----------------------------------------------------------------------void Scheduler::Run (Thread *nextThread){    Thread *oldThread = currentThread;    #ifdef USER_PROGRAM			// ignore until running user programs     if (currentThread->space != NULL)    {	// if this thread is a user program,      currentThread->SaveUserState(); // save the user's CPU registers      currentThread->space->SaveState();    }#endif        oldThread->CheckOverflow();		    // check if the old thread					    // had an undetected stack overflow    currentThread = nextThread;		    // switch to the next thread    currentThread->setStatus(RUNNING);      // nextThread is now running        DEBUG('t', "Switching from thread \"%s\" to thread \"%s\"\n",	  oldThread->getName(), nextThread->getName());        // This is a machine-dependent assembly language routine defined     // in switch.s.  You may have to think    // a bit to figure out what happens after this, both from the point    // of view of the thread and from the perspective of the "outside world".    SWITCH(oldThread, nextThread);        DEBUG('t', "Now in thread \"%s\"\n", currentThread->getName());    // If the old thread gave up the processor because it was finishing,    // we need to delete its carcass.  Note we cannot delete the thread    // before now (for example, in Thread::Finish()), because up to this    // point, we were still running on the old thread's stack!    if (threadToBeDestroyed != NULL)    {      delete threadToBeDestroyed;      threadToBeDestroyed = NULL;    }    #ifdef USER_PROGRAM    if (currentThread->space != NULL)    {		// if there is an address space      currentThread->RestoreUserState();     // to restore, do it.      currentThread->space->RestoreState();    }#endif}//---------------------------------------------------------------------// Suspends a thread from execution. The suspended thread is removed// from ready list and added to suspended list. The suspended thread // remains there until it is resumed by some other thread. Note that// it is not an error to suspend an thread which is already in the // suspended state.//// NOTE: This method assumes that interrupts have been turned off.//---------------------------------------------------------------------void Scheduler::Suspend(Thread *thread) {  List<Thread *> *tmp = new List<Thread *>();  Thread *t;  // Remove the thread from ready list.  while (!readyList->IsEmpty())  {    t = readyList->Remove();    if (t == thread)      break;    else      tmp->Prepend(t);  }    // Add the suspended thread to the suspended list  if (t == thread)  {    t->setStatus(SUSPENDED);    suspendedList->Append(t);  }  // Now all threads before the suspended thread in the ready list  // are in the suspended list. Add them back to the ready list.  while (!tmp->IsEmpty())  {    t = tmp->Remove();    readyList->Prepend(t);  }}//---------------------------------------------------------------------// Resumes execution of a suspended thread. The thread is removed// from suspended list and added to ready list. Note that it is not an// error to resume a thread which has not been suspended.//// NOTE: This method assumes that interrupts have been turned off.//---------------------------------------------------------------------void Scheduler::Resume(Thread *thread){  List<Thread *> *tmp = new List<Thread *>();  Thread *t;  // Remove the thread from suspended list.  while (!suspendedList->IsEmpty()) {    t = suspendedList->Remove();    if (t == thread)      break;    else      tmp->Prepend(t);  }    // Add the resumed thread to the ready list  if (t == thread) {    t->setStatus(READY);    readyList->Append(t);  }  // Now all threads before the suspended thread in the ready list  // are in the suspended list. Add them back to the ready list.  while (!tmp->IsEmpty()) {    t = tmp->Remove();    suspendedList->Prepend(t);  }}//----------------------------------------------------------------------// Scheduler::Print// 	Print the scheduler state -- in other words, the contents of//	the ready list.  For debugging.//----------------------------------------------------------------------voidScheduler::Print(){    printf("Ready list contents:\n");    readyList->Mapcar((VoidFunctionPtr) ThreadPrint);}//----------------------------------------------------------------------// Scheduler::InterruptHandler//   Handles timer interrupts for Round-robin scheduling.  Since this //   is called while the system is an interrupt handler, use YieldOnReturn.//   Be sure that your scheduling policy is still Round Robin.//----------------------------------------------------------------------void Scheduler::InterruptHandler( int dummy ){  ASSERT( false ); // no RR for me}// THUNKvoid SchedInterruptHandler( int dummy ){  scheduler->InterruptHandler( dummy );}//----------------------------------------------------------------------// Scheduler::SetSchedPolicy//      Set the scheduling policy to one of SCHED_FCFS, SCHED_SJF,//      SCHED_PRIO_P, SCHED_PRIO_NP, SCHED_RR, SCHED_MLQ or SCHED_MLFQ//----------------------------------------------------------------------void Scheduler::SetSchedPolicy(SchedPolicy pol){  SchedPolicy oldPolicy = policy;    policy = pol;    if( oldPolicy == policy )     return;  // No change!    switch (policy)  {    case SCHED_SJF:      printf("Shortest job first scheduling\n");      break;    case SCHED_PRIO_NP:      printf("Nonpreemptive Priority scheduling\n");      break;      case SCHED_PRIO_P:      printf("Preemptive Priority scheduling\n");      break;      case SCHED_RR:      printf("Round robin scheduling\n");      // Start timer.      ptimer = new Timer( SchedInterruptHandler , 0, false );      break;      case SCHED_MLQ:      printf("Multi level queue scheduling\n");      break;      case SCHED_MLFQ:      printf("Multi level feedback queue scheduling\n");      break;      case SCHED_FCFS:      default:      printf("First-come first-served scheduling\n");      break;  }}//----------------------------------------------------------------------// Scheduler::SetNumOfQueues//      Set the number of queues for MLQ - should be called only once//----------------------------------------------------------------------void Scheduler::SetNumOfQueues(int level){  ASSERT( false ); // no MLQ for me}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美成人激情| 欧美性videosxxxxx| 欧美日本精品一区二区三区| 亚洲日本欧美天堂| 国产激情视频一区二区在线观看| 欧美精品第1页| 日本美女视频一区二区| 欧美精品第1页| 99国产精品久久久久| 国产精品色哟哟| 国产伦精一区二区三区| 国产香蕉久久精品综合网| 国产尤物一区二区在线| 亚洲影院免费观看| 欧美日韩中文字幕一区| 午夜精品国产更新| 91麻豆精品国产91久久久资源速度| 日韩av电影免费观看高清完整版在线观看 | 成人丝袜18视频在线观看| 精品99999| 国产一区二区三区免费观看| 亚欧色一区w666天堂| 欧美xxxx在线观看| 成人性生交大合| 精品一区二区免费在线观看| 欧美精品一区二区在线播放| 欧美剧情片在线观看| 欧洲国内综合视频| 狠狠色丁香久久婷婷综合_中| 国产精品三级av| 久久久亚洲精品石原莉奈| 91首页免费视频| 美女网站色91| 亚洲欧美在线高清| 日韩一区二区免费高清| av在线播放不卡| 美女脱光内衣内裤视频久久影院| 亚洲bdsm女犯bdsm网站| 亚洲h动漫在线| 不卡一区二区在线| 日韩国产欧美视频| 亚洲va欧美va国产va天堂影院| 亚洲一级二级在线| 亚洲成在人线免费| 男人的j进女人的j一区| 亚洲欧美日韩一区| 久久一区二区三区国产精品| 91色在线porny| 色综合天天综合在线视频| 亚洲不卡av一区二区三区| 亚洲成人精品一区二区| 日韩中文字幕1| 一区二区三区国产豹纹内裤在线| 久久综合一区二区| 欧美国产禁国产网站cc| 欧美一级xxx| 精品久久久网站| 中文字幕av一区 二区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 在线成人小视频| 欧美精品一区二区三区在线| 国产色综合久久| 亚洲婷婷国产精品电影人久久| 亚洲国产毛片aaaaa无费看| 欧美国产日产图区| 亚洲精品大片www| 最新热久久免费视频| 一区二区三区欧美久久| 老司机免费视频一区二区三区| 亚洲在线视频网站| 蜜桃视频一区二区三区 | 国产精品一区二区三区99| 日韩精品电影在线| 激情久久久久久久久久久久久久久久| 国产福利一区二区三区在线视频| 91蜜桃免费观看视频| 91精品久久久久久久91蜜桃| 国产欧美精品在线观看| 久久久欧美精品sm网站| 亚洲色图欧美激情| 麻豆成人综合网| eeuss鲁片一区二区三区 | 9191精品国产综合久久久久久 | 国产精品国产精品国产专区不蜜 | 久久亚洲一级片| 亚洲女性喷水在线观看一区| 免费观看成人鲁鲁鲁鲁鲁视频| hitomi一区二区三区精品| 欧美一卡二卡三卡| 日韩欧美另类在线| 中文字幕亚洲精品在线观看| 免费欧美日韩国产三级电影| zzijzzij亚洲日本少妇熟睡| 欧美一区二区视频网站| 国产精品免费久久久久| 久久精品99国产精品日本| 91一区二区在线观看| xnxx国产精品| 亚洲成a天堂v人片| av一二三不卡影片| 久久众筹精品私拍模特| 亚洲va欧美va天堂v国产综合| 99在线热播精品免费| 26uuu国产电影一区二区| 日韩高清国产一区在线| 91黄色小视频| 欧美一区二区三区婷婷月色| 亚洲欧美另类综合偷拍| 国产传媒日韩欧美成人| 日韩精品中午字幕| 婷婷综合另类小说色区| 一本到一区二区三区| 欧美肥妇free| 亚洲综合男人的天堂| 成人国产一区二区三区精品| 欧美sm极限捆绑bd| 日本三级韩国三级欧美三级| 欧美中文字幕一区二区三区亚洲| 中文字幕制服丝袜成人av| 国产精品一区二区不卡| 精品黑人一区二区三区久久| 日韩和的一区二区| 欧美绝品在线观看成人午夜影视| 一区二区三区 在线观看视频| 懂色中文一区二区在线播放| 欧美探花视频资源| 亚洲一区欧美一区| 在线精品视频一区二区| 亚洲欧美另类在线| 91视频.com| 一区二区三区不卡视频| 欧美午夜片在线看| 亚洲综合在线免费观看| 一本久久精品一区二区| 一区二区三区欧美| 欧美在线色视频| 亚洲成人免费av| 51精品秘密在线观看| 视频一区二区不卡| 欧美一区二区精品| 韩国女主播成人在线观看| 精品蜜桃在线看| 国产成人亚洲综合色影视| 久久精品在这里| jlzzjlzz欧美大全| 亚洲欧美日韩系列| 欧美日韩国产系列| 麻豆精品视频在线| 2024国产精品| 成人激情动漫在线观看| 亚洲人亚洲人成电影网站色| 91免费国产在线观看| 午夜日韩在线电影| 日韩精品一区二区三区四区视频 | 亚洲日本va在线观看| 欧美综合视频在线观看| 青青青爽久久午夜综合久久午夜| 日韩久久久精品| 成人污视频在线观看| 亚洲综合激情网| 日韩亚洲国产中文字幕欧美| 国产一区二区三区在线观看免费 | 成人动漫在线一区| 一区二区三区精品在线| 在线不卡一区二区| 国产一区三区三区| 亚洲日本欧美天堂| 欧美一级理论片| 成人av在线资源网站| 亚洲国产一区视频| 精品国产乱码久久久久久浪潮| 大白屁股一区二区视频| 亚洲在线一区二区三区| 久久久亚洲午夜电影| 91黄色激情网站| 精品一区二区免费| 一区二区三区四区五区视频在线观看| 制服丝袜中文字幕亚洲| 国产成人99久久亚洲综合精品| 一区二区三区欧美视频| 久久九九久久九九| 欧美日韩国产不卡| 成人美女视频在线观看| 午夜视频一区二区三区| 国产精品狼人久久影院观看方式| 欧美色图在线观看| 国产成人精品亚洲午夜麻豆| 亚洲一区二区三区四区不卡 | 日本最新不卡在线| 国产精品青草久久| 日韩精品专区在线影院观看| 色综合久久久久综合| 国产在线一区观看| 亚洲国产三级在线| 中文字幕成人av| 日韩午夜在线影院| 欧美中文字幕一区二区三区 | 性久久久久久久| 国产精品久久久久影院老司| 欧美一区二区三区啪啪|