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


Python LinkedList.free方法代码示例

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


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

示例1: test

# 需要导入模块: import LinkedList [as 别名]
# 或者: from LinkedList import free [as 别名]
def test(size, it, ch):

     """ Test of memory management algorithms.
         size: total size of the memory (in number of blocks).
         it: number of operations (insert, delete memory).
         ch: chose type of information to be display. """

     # Create structures
     bf = BitMap(size) # Bit Map for use of fist fit
     bn = BitMap(size) # Bit Map for use of next fit
     bb = BitMap(size) # Bit Map for use of best fit
     bw = BitMap(size) # Bit Map for use of worst fit
     lf = LinkedList(size) # Linked List for use of fist fit
     ln = LinkedList(size) # Linked List for use of next fit
     lb = LinkedList(size) # Linked List for use of best fit
     lw = LinkedList(size) # Linked List for use of worst fit
     qf = QuickFit(size) # Adapted quick fit using fist fit
     qb = QuickFit(size) # Adapted quick fit using best fit
     qw = QuickFit(size) # Adapted quick fit using worst fit
     bs = BuddySystem(size) # Tree for Buddy System

     # Initial information for specific algorithms
     if ch == 'bf':
          print(bf)
     elif ch == 'bn':
          print(bn)
     elif ch == 'bb':
          print(bb)
     elif ch == 'bw':
          print(bw)
     elif ch == 'lf':
          print(lf)
     elif ch == 'ln':
          print(ln)
     elif ch == 'lb':
          print(lb)
     elif ch == 'lw':
          print(lw)
     elif ch == 'qf':
          print(qf)
          print(qb)
          print(qw)
     elif ch == 'bs':
          print(bs)

     # Segmentation table header
     if ch == 'seg':
          print("operacao,bfblock,bnblock,bbblock,bwblock,lfblock,lnblock,lbblock,lwblock,qfblock,qbblock,qwblock,bsblock,bfspaces,bnspaces,bbspaces,bwspaces,lfspaces,lnspaces,lbspaces,lwspaces,qfspaces,qbspaces,qwspaces,bsspaces")
     # Time table header
     if ch == 'time':
          print('operacao,','begbf,','begbn,',"begbb,","begbw,","begqf,","begqb,","begqw,","size,","id,","bftime,","bntime,","bbtime,","bwtime,","lftime,","lntime,","lbtime,","lwtime,","qftime,","qbtime,","qwtime,","bstime")

     on_memory = [] # indicates processes on memory
     for i in range(it):

        # random choice is free memory
        if(ran.random() > 0.5 and on_memory):
               # Chose random process to free from memory
               out = on_memory[ran.randint(0,len(on_memory) - 1)]

               # Row of a time table
               if ch == 'time':
                    times = "free" + 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("free: id",out.id,"beg:",out.begbf,"size:", out.size)
               elif ch == 'bn':
                    print("free: id",out.id,"beg:",out.begbn,"size:", out.size)
               elif ch == 'bb':
                    print("free: id",out.id,"beg:",out.begbb,"size:", out.size)
               elif ch == 'bw':
                    print("free: id",out.id,"beg:",out.begbw,"size:", out.size)
               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)
#.........这里部分代码省略.........
开发者ID:Gabriel-Siqueira,项目名称:MC504,代码行数:103,代码来源:RandomInput.py


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