【大三操作系统实验】作业进程调度算法热1已有49次阅读2010-12-3013:34(1)FCFS算法将用火作业和就绪进程按提交顺序或变为就绪状态的先后排成队列,并按照先来先服务的方式进行调度处理,是一种最普遍和简单的方法。(2)轮转法让每个进程中就绪队列中的等待时间与享受服务时间成比例。轮转法定基本概念是将CPU的处理时间分成固定大小的时间片。如果一个进程中被调度选中后用完系统规定的时间片,但未完成要求的任务,则它自行释放自己所占有的CPU而排到就绪队列的末尾,等待下一次调度。(3)优先级法系统或用户按某种原则为作业或进程指定一个优先级来表示该作业或进程所享有的调度优先权。该算法的核心是确定进程的优先级(4)最短作业优先法选择那些估计需要执行时间最短的作业投入执行(5)HRN是对先来先服务和最短作业优先法定一个综合平衡。HRN调度策略同时考虑每个作业的等待时间的长短和估计需要的执行时间长短,从中选出响应比最高的作业投入执行。代码量过大还没设计完成!!!!部分代码Code:1.//操作系统调度算法Dlg.cpp:implementationfile2.//3.4.#includestdafx.h5.#include操作系统调度算法.h6.#include操作系统调度算法Dlg.h7.8.#ifdef_DEBUG9.#definenewDEBUG_NEW10.#undefTHIS_FILE11.staticcharTHIS_FILE[]=__FILE__;12.#endif13.14./////////////////////////////////////////////////////////////////////////////15.//CAboutDlgdialogusedforAppAbout16.CMyDlg*pDlg;17.intcount_ok;18.int_flag;19.startstar[100];20.voidEnter_Sort(intLength);//进入时间排序21.voidFCFS_0(intLength);//FCFS非抢占22.voidSJF_0(intLength);//SJF非抢占23.voidCheck(int&hours,int&minutes);24.voidFormat(int&hours,int&minutes,CString&cs);25.voidShow_List(int&n,int&m,CMyDlg*pDlg);26.voidOperation_0(CMyDlg*pDlg,int&n);27.voidOperation_1(CMyDlg*pDlg,int&n);28.29.voidSetStyle(CListCtrl&m_listCtrl)30.{31./*//设定窗口风格为Report,如果已经指定好了,此操作可跳过32.LONGlStyle;33.lStyle=::GetWindowLong(m_listCtrl.m_hWnd,GWL_STYLE);34.lStyle|=LVS_REPORT;35.::SetWindowLong(m_listCtrl.m_hWnd,GWL_STYLE,lStyle);36.*/37.38.//增加扩展风格39.DWORDdwStyle=m_listCtrl.GetExtendedStyle();40.dwStyle|=LVS_EX_FULLROWSELECT;//整行高亮所选中的行.只适用ReportStyle41.dwStyle|=LVS_EX_GRIDLINES;//网格线.只适用ReportStyle42.//dwStyle|=LVS_EX_CHECKBOXES;//item前添加CheckBox控件43.m_listCtrl.SetExtendedStyle(dwStyle);44.45.}46.47.classCAboutDlg:publicCDialog48.{49.public:50.CAboutDlg();51.52.//DialogData53.//{{AFX_DATA(CAboutDlg)54.enum{IDD=IDD_ABOUTBOX};55.//}}AFX_DATA56.57.//ClassWizardgeneratedvirtualfunctionoverrides58.//{{AFX_VIRTUAL(CAboutDlg)59.protected:60.virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport61.//}}AFX_VIRTUAL62.63.//Implementation64.protected:65.//{{AFX_MSG(CAboutDlg)66.//}}AFX_MSG67.DECLARE_MESSAGE_MAP()68.};69.70.CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD)71.{72.//{{AFX_DATA_INIT(CAboutDlg)73.//}}AFX_DATA_INIT74.}75.76.voidCAboutDlg::DoDataExchange(CDataExchange*pDX)77.{78.CDialog::DoDataExchange(pDX);79.//{{AFX_DATA_MAP(CAboutDlg)80.//}}AFX_DATA_MAP81.}82.83.BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)84.//{{AFX_MSG_MAP(CAboutDlg)85.//Nomessagehandlers86.//}}AFX_MSG_MAP87.END_MESSAGE_MAP()88.89./////////////////////////////////////////////////////////////////////////////90.//CMyDlgdialog91.92.CMyDlg::CMyDlg(CWnd*pParent/*=NULL*/)93.:CDialog(CMyDlg::IDD,pParent)94.{95.//{{AFX_DATA_INIT(CMyDlg)96.m_seize=-1;97.m_hours=_T();98.m_minutes=_T();99.m_runtime=_T();100.//}}AFX_DATA_INIT101.//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32102.m_hIcon=AfxGetApp()-LoadIcon(IDR_MAINFRAME);103.}104.105.voidCMyDlg::DoDataExchange(CDataExchange*pDX)106.{107.CDialog::DoDataExchange(pDX);108.//{{AFX_DATA_MAP(CMyDlg)109.DDX_Control(pDX,IDC_hours,m_hoursCtrl);110.DDX_Control(pDX,IDC_LIST_complete,m_comle);111.DDX_Control(pDX,IDC_LIST_read,m_read);112.DDX_Control(pDX,IDC_LIST_show,m_show);113.DDX_Control(pDX,IDC_LIST_start,m_start);114.DDX_Control(pDX,IDC_LIST_wait,m_wait);115.DDX_Control(pDX,IDC_TAB1,m_tab);116.DDX_Radio(pDX,IDC_RADIO2,m_seize);117.DDX_Text(pDX,IDC_hours,m_hours);118.DDX_Text(pDX,IDC_minutes,m_minutes);119.DDX_Text(pDX,IDC_runtime,m_runtime);120.//}}AFX_DATA_MAP121.}122.123.BEGIN_MESSAGE_MAP(CMyDlg,CDialog)124.//{{AFX_MSG_MAP(CMyDlg)125.ON_WM_SYSCOMMAND()126.ON_WM_PAINT()127.ON_WM_QUERYDRAGICON()128.ON_BN_CLICKED(IDC_BTN_Test,OnBTNTest)129.ON_BN_CLICKED(IDC_BTN_Info_Test,OnBTNInfoTest)130.ON_BN_CLICKED(IDC_queding,Onqueding)131.//}}AFX_MSG_MAP132.END_MESSAGE_MAP()133.134./////////////////////////////////////////////////////////////////////////////135.//CMyDlgmessagehandlers136.137.BOOLCMyDlg::OnInitDialog()138.{139.CDialog::OnInitDialog();140.141.//AddAbout...menuitemtosystemmenu.142.143.//IDM_ABOUTBOXmustbeinthesystemcommandrange.144.ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);145.ASSERT(IDM_ABOUTBOX0xF000);146.147.CMenu*pSysMenu=GetSystemMenu(FALSE);148.if(pSysMenu!=NULL)149.{150.CStringstrAboutMenu;151.strAboutMenu.LoadString(IDS_ABOUTBOX);152.if(!strAboutMenu.IsEmpty())153.{154.pSysMenu-AppendMenu(MF_SEPARATOR);155.pSysMenu-AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);156.}157.}158.159.//Settheiconforthisdialog.Theframeworkdoesthisautomatically160.//whentheapplication'smainwindowisnotadialog161.SetIcon(m_hIcon,TRUE);//Setbigicon162.SetIcon(m_hIcon,FALSE);//Setsmallicon163.pDlg=this;164.//TODO:Addextrainitializationhere165.//调度类型166.m_tab.InsertItem(0,FCFS);167.m_tab.InsertItem(1,SJF);168.m_tab.InsertItem(2,HRN);169.m_tab.InsertItem(3,静态优先级法);170.m_tab.InsertItem(4,动态优先级法);171.m_tab.InsertItem(5,轮转法);172.173.//初始态174.m_start.InsertColumn(0,初始态,LVCFMT_LEFT,50);175.m_start.InsertColumn(1,进入时间,LVCFMT_LEFT,60);176.m_start.InsertColumn(2,运行时间,LVCFMT_LEFT,60);177.SetStyle(m_start);178.//等