91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

大學操作系統課程 綜合實驗 單處理器系統的時間片輪轉進程調度 算法,使用python實現。帶注釋。

資源截圖

代碼片段和文件信息

#coding=utf-8

N?=?0?#進程的數目
finish?=?None
ready??=?None
tail???=?None
run????=?None

class?PCB:
name??=?‘‘
prio??=?0? #進程優先級
q? ??=?0 #時間片大小
time??=?0???#剩余時間
count?=?0 #循環論轉法一個時間片內進程運行時間
state?=?‘W‘ #狀態標識:‘R‘:運行,?’W‘:等待,?‘F‘:結束
next??=?None?#指向下一個進程


def?insert(e):?#插入元素到tail
global?tail
tail.next?=?e
tail?=?e
e.next?=?None

def?inQueue():?#調度就緒隊列的第一個進程投入運行
global?ready?run
if?ready?is?not?None:
run?=?ready
ready?=?ready.next
run.state?=?‘R‘
run.next?=?None

else:
run?=?None

def?printtitle(chose):?#打印表頭
if?chose??in?{‘p‘?‘P‘}:
print?‘name?time?priority?state‘
else:
print?‘name????time???count????q?????state?‘

def?printInfo(chose?pcb):?#打印每一行的狀態信息
if?chose?in?{‘p‘?‘P‘}:
print?‘%s\t%d\t%d\t\t%c\n‘%(pcb.name?pcb.time?pcb.state)
else:
print?‘%s\t%d\t%d\t%d\t%c\n‘%(pcb.name?pcb.time?pcb.count?pcb.q?pcb.state)

def?printAll(chose):#打印每一次執行完的所有進程狀態
global?run?ready
printtitle(chose)

if?run?is?not?None:
printInfo(chose?run)

pcb?=?ready
while?pcb?is?not?None:
printInfo(chose?pcb)
pcb?=?pcb.next

pcb?=?finish
while?pcb?is?not?None:
printInfo(chose?pcb)
pcb?=?pcb.next

def?roundRunInit(chose):#隊列初始化
global?N?run?ready?finish?tail
print?‘>>>>>>>>

評論

共有 條評論