本文整理汇总了Python中LinkedList.segmentation方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.segmentation方法的具体用法?Python LinkedList.segmentation怎么用?Python LinkedList.segmentation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.segmentation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import segmentation [as 别名]
#.........这里部分代码省略.........
elif ch == 'qf':
print("free: id",out.id,"beg:",out.begqf,"size:", out.size)
print("free: id",out.id,"beg:",out.begqb,"size:", out.size)
print("free: id",out.id,"beg:",out.begqw,"size:", out.size)
elif ch == "bs":
print("free: id",out.id,"size:", out.size)
# free memory in all structures where this process is allocate
if out.begbf >= 0:
bf.free(out.begbf,out.size)
if out.begbn >= 0:
bn.free(out.begbn,out.size)
if out.begbb >= 0:
bb.free(out.begbb,out.size)
if out.begbf >= 0:
bw.free(out.begbw,out.size)
lf.free(out.id)
ln.free(out.id)
lb.free(out.id)
lw.free(out.id)
if out.begqf != -1:
qf.free(out.begqf, out.size)
if out.begqb != -1:
qb.free(out.begqb, out.size)
if out.begqw != -1:
qw.free(out.begqw, out.size)
bs.free(out.id)
# Remove process from process list
on_memory.remove(out)
# Row of a segmentation table
if ch == 'seg':
(bfblock,bfspaces) = bf.segmentation()
(bnblock,bnspaces) = bn.segmentation()
(bbblock,bbspaces) = bb.segmentation()
(bwblock,bwspaces) = bw.segmentation()
(lfblock,lfspaces) = lf.segmentation()
(lnblock,lnspaces) = ln.segmentation()
(lbblock,lbspaces) = lb.segmentation()
(lwblock,lwspaces) = lw.segmentation()
(qfblock,qfspaces) = qf.segmentation()
(qbblock,qbspaces) = qb.segmentation()
(qwblock,qwspaces) = qw.segmentation()
(bsblock,bsspaces) = bs.segmentation()
print("free",",",bfblock,",",bnblock,",",bbblock,",",bwblock,",",lfblock,",",lnblock,",",lbblock,",",lwblock,",",qfblock,",",qbblock,",",qwblock,",",bsblock,",",bfspaces,",",bnspaces,",",bbspaces,",",bwspaces,",",lfspaces,",",lnspaces,",",lbspaces,",",lwspaces,",",qfspaces,",",qbspaces,",",qwspaces,",",bsspaces)
# random choice is allocate memory
else:
# Chose random size to be allocate
alloc_size = ran.randint(0,20)
# Create new Process representation
new = Process(alloc_size)
# Allocate process memory using all the algorithms
new.begbf = bf.first_fit(new.size)
new.begbn = bn.next_fit(new.size)
new.begbb = bb.best_fit(new.size)
new.begbw = bw.worst_fit(new.size)
lf.first_fit(new.id, new.size)
ln.next_fit(new.id, new.size)
lb.best_fit(new.id, new.size)
lw.worst_fit(new.id, new.size)
new.begqf = qf.first_fit(new.size)
new.begqb = qb.best_fit(new.size)
new.begqw = qw.worst_fit(new.size)