-init -cr <name> <priority>(=1 or 2) // create process -de <name> // delete process -req <resource name> <# of units> // request resource -rel <resource name> <# of units> // release resource -to // time out 查看进程状态和资源状态的命令 -list ready //list all processes in the ready queue -list block // list all processes in the block queue -list res //list all available resources -pr <name> //print pcb information about a given process.
defkillTree(p,pid):#要删除的PCB和pid dict = {} dict.update(ready) dict.update(block)#维护存储所有进程记录 for childPid in p.child:#遍历要删除的进程的子进程 killTree(dict[childPid],childPid)#递归删除 if pid in ready.keys():#如果该进程在readylist里 for rid in ready[pid].res.keys():#释放该进程占用的资源 if ready[pid].res[rid]!=0: release(rid,ready[pid].res[rid],pid) ready.pop(pid)#将该进程从readylist中删除 else:#如果该进程在blocklist中 temp = block[pid].res#找到该进程在blocklist中存储的pcb for rid in temp.keys():#遍历该进程占用的资源进行释放 if pid in block.keys() and temp[rid]!=0: release(rid,block[pid].res[rid],pid)#释放资源 for rid in temp.keys():#在rcb的waitlist中移除该进程 if pid in res[rid].waitList: res[rid].waitList.remove(pid) block.pop(pid)#把该进程从blocklist中删除