⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scheduler.h

📁 LINUX 下的 NACHOS 系统 实现系统调度的算法功能
💻 H
字号:
// scheduler.h //  Data structures for the thread dispatcher and scheduler.//  Primarily, the list of threads that are ready to run.//// 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.#ifndef SCHEDULER_H#define SCHEDULER_H#include "copyright.h"#include "list.h"#include "thread.h"#include "oneshot.h"#include "timer.h"#include "testcase.h"enum SchedPolicy {   SCHED_FCFS,     // First-come first-served scheduling   SCHED_SJF,      // Shortest Job First  SCHED_SRTN,     // Shortest Remaining Time Next  SCHED_PRIO,     // Priority   SCHED_RR,       // Round Robin   SCHED_MQ,       // Multiple Queues };// The following class defines the scheduler/dispatcher abstraction -- // the data structures and operations needed to keep track of which // thread is running, and which threads are ready but not running.class Scheduler{  public:    Scheduler();       // Initialize list of ready threads     ~Scheduler();      // De-allocate ready list    void ReadyToRun(Thread* thread); // Thread can be dispatched.    Thread* FindNextToRun();  // Dequeue first thread on the ready                               // list, if any, and return thread.    bool ShouldISwitch(Thread* oldThread, Thread* newThread);    void Run(Thread* nextThread); // Cause nextThread to start running    void Print();  // Print contents of ready list    void Suspend(Thread *thread);    void Resume(Thread *thread);    void SetSchedPolicy(SchedPolicy pol);    SchedPolicy getSchedPolicy()        // Get the scheduling policy    {      return policy;    }                                   void InterruptHandler( int dummy );  private:    SchedPolicy policy;            // scheduling policy to be used    List<Thread *> *readyList;     // queue of threads that are ready to run,                                   // but not running    List<Thread *> *suspendedList; // List of suspended threads.    Timer * ptimer;    // MP1    int currentRRnum;};#endif // SCHEDULER_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -