4.3调度进程:
4.4显示调用后的进程:
11
4.5地址转换: 4.5.1输入进程p1:
4.5.2输入段号:
4.5.3输入偏移地址(未超出范围):
12
4.5.4输入偏移地址(超出范围)的情况:
4.6结束:
5程序源代码:
#include
13
#include \#include\#include
long capacity;//该段的长度 long addr;//起始逻辑地址
long realaddr;//该段实际起始地址 };
struct duanbiao {
duan duans[10];
char processname[20]; // 进程的名字 int Isdiaoyong; //是否被调用 int num; //段的数目
long total; //该进程的总占用量 };
long neicun=0;
int duanbiaonum=0; //段表的数目 long zhanyong=0; // 占用的内存 long baseaddr=0; duanbiao duanbiaos[10];
void show1(int ); void show();
void diaodu() {
cout<<\您要调度的进程是:p\ int n; cin>>n;
if(n>duanbiaonum)
cout<<\段表不存在!\
else if(duanbiaos[n-1].Isdiaoyong==1)
cout<<\操作错误,该进程已经被调入到内存!\
14
else if(duanbiaos[n-1].total>neicun-zhanyong) cout<<\内存空间不足,调度不成功!\ else {
cout<<\下面对进程\进行地址转化:\
for(int j=0;j cout<<\正在进行第\段的地址转换,请稍后......\ duanbiaos[n-1].duans[j].realaddr=duanbiaos[n-1].duans[j].addr+zhanyong; cout<<\第\段的地址转换成功!\ } zhanyong=zhanyong+duanbiaos[n-1].total; duanbiaos[n-1].Isdiaoyong =1; cout<<\调度后的结果是:\ show1(n-1); } } void zhuanhuan() { int n,i,j; cout<<\请输入进程:p\ cin>>n; if(n>duanbiaonum) cout<<\进程不存在或没被调度!\ else if(duanbiaos[n-1].Isdiaoyong==1) { cout<<\请输入段号:\ cin>>i; cout<<\输入偏移地址:\ cin>>j; if(i>duanbiaos[n-1].num) 15 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库模拟设计段式存储管理中地址转换(3)在线全文阅读。
相关推荐: