📄 mos_sw.cpp
字号:
// Mos_sw.cpp: implementation of the CMos_sw class.
// Code by biti_zx. Released March,2002.
// Copyright (C) 2002 by biti_zx.
// All rights reserved.
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Mos.h"
#include "Mos_sw.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CVCS m_cpu;
extern PCB m_pcb;
CMos_sw::CMos_sw()
{
}
CMos_sw::~CMos_sw()
{
}
void CMos_sw::idle()
{
m_UI.DealWithUI(_T("IDLE"),IDC_STATIC_CPU);
for(;;){
m_cpu.clock();
m_cpu.idletime++;//闲逛计数
if(m_cpu.Test())
return;
}
}
void CMos_sw::run()
{
if(m_pcb.curr_pcb==NULL){
idle();//有中断时返回
m_inth.interrupt_handle();//接着处理中断
}
else{
if(m_pcb.curr_pcb->pid>3)//处理用户进程
{//恢复现场
m_UI.DealWithUI(_T("USER"),IDC_STATIC_CPU);
m_cpu.C = m_pcb.curr_pcb->regc;
m_cpu.PC[0] = m_pcb.curr_pcb->regpc[0];
m_cpu.PC[1] = m_pcb.curr_pcb->regpc[1];
for(int i=0;i<=3;i++)
m_cpu.R[i] = m_pcb.curr_pcb->regr[i];
m_cpu.PTR.op4 = m_pcb.curr_pcb->regptr[3];
m_cpu.PTR.op3 = m_pcb.curr_pcb->regptr[2];
m_cpu.PTR.op2 = m_pcb.curr_pcb->regptr[1];
m_cpu.PTR.op1 = m_pcb.curr_pcb->regptr[0];
}
m_cpu.MODE = m_pcb.curr_pcb->mode;
switch(m_pcb.curr_pcb->pid)
{
case 1:m_UI.DealWithUI(_T("KERNEL"),IDC_STATIC_CPU);m_in.pre_input();break;
case 2:m_UI.DealWithUI(_T("KERNEL"),IDC_STATIC_CPU);m_jsw.jsw();break;
case 3:m_UI.DealWithUI(_T("KERNEL"),IDC_STATIC_CPU);m_out.delay_output();break;
//仅当自己睡眠后函数返回,接着转进程调度
case 4:case 5:case 6:case 7:case 8:
m_cpu.VCS();//有中断时返回
m_inth.interrupt_handle();//接着处理中断
default:break;
}
}//end of else
}
void CMos_sw::swtch()
{
m_UI.DealWithUI(_T(" "),IDC_STATIC_CP);
m_pcb.curr_pcb = mos_proc.GetQueueHead(m_pcb.readypcbhead,m_pcb.readypcbtail,IDC_STATIC_RP);
if(m_pcb.curr_pcb != NULL&&m_pcb.curr_pcb->mode == USERMODE)
m_cpu.time = 10;
if(m_pcb.curr_pcb!=NULL)
{
CString str;
str.Format("->P%d",m_pcb.curr_pcb->pid);
m_UI.DealWithUI(str,IDC_STATIC_CP);
}
else m_UI.DealWithUI(_T(" "),IDC_STATIC_CP);
run();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -