全球旧事资料 分类
江苏科技大学
操作系统实验报告
(20152016学年第2学期)
课程名称:指导教师:实验地点:学生姓名:学生学号:院专系:业:
操作系统
西校区图书馆计算机机房
计算机科学与工程学院计算机科学与技术
2016年5月15日
f实验一进程调度
一、实验目的多道程序设计中,经常是若干个进程同时处于就绪状态,必须依照某种策略来决定那个进程优先占有处理机。因而引起进程调度。本实验模拟在单处理机情况下的处理机调度问题,加深对进程调度的理解。二、实验内容1.优先权法、轮转法简化假设1)进程为计算型的(无IO)2)进程状态:ready、ru
i
g、fi
ish3)进程需要的CPU时间以时间片为单位确定2.算法描述1)优先权法动态优先权当前运行进程用完时间片后,其优先权减去一个常数。2)轮转法三、实验要求1.产生的各种随机数的取值范围加以限制,如所需的CPU时间限制在120之间。2.进程数
不要太大通常取48个3.使用动态数据结构4.独立编程5.二种调度算法四、实验过程秦魏编写要拷贝使用无(fa)偿ge使ho
g用baoif
defMaxpriority_Hdefi
eMaxpriority_H
defi
earrayLe
th100templateclassTclassMaxheapTheapi
theapsizele
thpublicMaxheapi
t
le
th0heapsize
heap
ewTheapsizeMaxheapTmaxheapi
t
if
0retur
le
th
heapsize
heap
ewTheapsizei
tifori0iheapsizeiheapimaxheapicreateMaxheapdeleteheapi
tPare
ti
tiretur
i121注意地址的转换,最后还要减去1i
tLchildi
tiretur
2i11
fi
tRchildi
tiretur
2i2voidMaxheapifyi
tii
tlrlLchildirRchildii
tlargestiflle
thheaplpriorityheapipriority第一个条件,起到一个判断是否为叶子节点的作用largestlelselargestiifrle
thheaprpriorityheaplargestprioritylargestriflargestiswapheaplargestheapiMaxheapifylargestvoidswapTaTbTstorestoreaabbstorevoidcreatei
tiforile
th21i0iMaxheapifyivoidi
sertTeleme
tle
thheaple
th1eleme
tcreatevoidpri
ti
tifori0ile
thicoutheapipriorityi
theapextractmaxifle
th0retur
1Tmaxmaxheap0heap0heaple
th1le
thMaxheapify0retur
maxtaski
temptyifle
th0retur
1retur
0e
difif
defQue
e_Hdefi
eQue
e_Hdefi
esize1000队列先进先出,从队尾进,从对头出templateclassT
fclassCirque
eTasizei
tfro
trearpublicCirque
efro
trearsize1Cirque
evoidE
que
eTeifrear1sizefro
tthr
好听全球资料 返回顶部