当前位置: 首页>>代码示例>>Python>>正文


Python LinkedList.next_fit方法代码示例

本文整理汇总了Python中LinkedList.next_fit方法的典型用法代码示例。如果您正苦于以下问题:Python LinkedList.next_fit方法的具体用法?Python LinkedList.next_fit怎么用?Python LinkedList.next_fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedList的用法示例。


在下文中一共展示了LinkedList.next_fit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import next_fit [as 别名]

#.........这里部分代码省略.........
                    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)
               bs.buddy_system(new.id, new.size)

               # Add new process to the list of process
               on_memory.append(new)

               # Row of a time table
               if ch == 'time':
                    times = "alloc" + 21 * ",{:d}"
                    print(times.format(new.begbf,new.begbn,new.begbb,new.begbw,new.begqf,new.begqb,new.begqw,new.size,new.id,bf.time,bn.time,bb.time,bw.time,lf.time,ln.time,lb.time,lw.time,qf.time,qb.time,qw.time,bs.time))

               # Information for specific algorithms
               elif ch == 'bf':
                    print("alloc: id",new.id,"beg:",new.begbf,"size:", new.size)
               elif ch == 'bn':
                    print("alloc: id",new.id,"beg:",new.begbn,"size:", new.size)
               elif ch == 'bb':
                    print("alloc: id",new.id,"beg:",new.begbb,"size:", new.size)
               elif ch == 'bw':
                    print("alloc: id",new.id,"beg:",new.begbw,"size:", new.size)
               elif ch == 'qf':
                    print("alloc: id",new.id,"beg:",new.begqf,"size:", new.size)
                    print("alloc: id",new.id,"beg:",new.begqb,"size:", new.size)
                    print("alloc: id",new.id,"beg:",new.begqw,"size:", new.size)
开发者ID:Gabriel-Siqueira,项目名称:MC504,代码行数:70,代码来源:RandomInput.py


注:本文中的LinkedList.next_fit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。