1 / 13

Storage Management in Program Execution

This chapter discusses the different aspects of storage management during program execution, including the allocation and deallocation of memory, management of system data, and various storage operations. It also explores different storage management techniques such as stack-based and heap-based approaches, as well as recovery techniques like reference counting and garbage collection.

Télécharger la présentation

Storage Management in Program Execution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter Ten Storage Management

  2. Storage Management * program has little control over storage * always machine dependent *data elements requiring storage during program execution include : 1.code segments: major block of storage 2.system run-time program: supporting program execution e.g., library run-time storage management 3. user defined data structures & constants 4. sub program return point : internally generated sequence control information ( as subprogram may be invoked from different parts of program)

  3. Storage Management (Cont’d) 5. Referencing environment :e.g., identifier association in LISP. 6.  Temporaries in experimental evaluation : deep area for calculations 7.  Temporaries in parameter transmission : storage for evaluation of value parameter before they are passed 8.  I/O Buffers: for fetching date 9. Miscellaneous system data: status information etc. * Operations that require storage include: 1. storage for activation records (for subprogram => operations)   2.  data structure creation & destruction operation: (e.g., new & malloc, dispose & free) 3. component insertion & deletion operation (e.g. insert into the LISP list)

  4. Storage Management (Cont’d) * Should program be given direct control of storage management - C gives control in the form of malloc & free - other HLL don’t  Two issues 1.   place responsibility on programmer - programmer has to allocate and de-allocate internal and temporary structure - may lead to errors 2.  may interfere with the system controlled storage area but if given control, programmer knows best when to create & destroy structure, system may not.

  5. Storage Management (Cont’d) • Storage management phases 1.  initial allocation : allocate free blocks for program execution 2.  recovery : recover de-allocated storage for reuse 3.  compaction & reuse: form large blocks from smaller ones • Static storage management • -  allocation for the code segments constants, data & system run-time • routines is done statistically at translation time • -   no runtime storage management is needed • -   fast & quite efficient • -   lacks flexibility ( can’t create dynamic structure ) & can’t do • recursion ! • -   used by FORTRAN & COBOL

  6. Storage Management (Cont’d) • Stack-based storage management -    Simple form -Leap a pointer that separate allocated and de-allocated storage Stack point -    when storage allocated move pointer up -    when storage de-allocated move pointer down -compaction occurs during de-allocation -    used in Pascal free

  7. Storage Management (Cont’d) • Heap Storage Management: Fixed-Size Elements - blocks of storage allocated & deallocted ad- hocly -  difficult storage management -    used by dynamic language

  8. Recovery Techniques (Heap) 1.  Explicit return by program or system • -  simple identification • -  explicit call to free or dispose • -  two potential problems: • A. dangling reference: objects destroyed but • access paths for it still exist B. garbage collection : object exists but no access path to it

  9. Recovery Techniques 2.   Reference counts: -   maintain extra space in heap for it -   indicates the numbers of pointers to the element that exist -   upon allocating element initially from free space list , set count to 1 -   each new pointer added, increment by 1 -   each new pointer dropped , decrement by 1 -   when count = 0 , return to free space list -  advantage : get rids of dangling reference & garbage collection -  disadvantage: extra storage & execution inefficiency (testing the counter)

  10. Recovery Techniques 3. Garbage collection: - accumulate garbage -  when free-space list is used up, invoke a special process, garbage collector that reclaim storage -  to do this, each element is marked either on or active ,or off and not used -  when garbage collector runs, it search for off elements & reclaim then -  used in LISP

  11. Storage Management (Cont’d) • Heap Storage Management: Variable–Size Elements: -   difficult especially when it comes to recovery -   maintain free-space in blocks of as large a size as possible - reference pointer is used for initial allocation -    when space is used, advance heap pointer & the original heap pointer is used as the pointer for the newly allocated elements

  12. Heap Storage Management (Cont’d) -   when end of heap is reached, reuse space: 1. use free-space list directly: When a request comes for N word block, search free list for block that has at least N-word in it , allocate N-word and return rest to free list 2. compact free space to one end and leave free space as a single large block - for recovery => reference count (need a field to indicate length of element) and garbage collection may be used

  13. Heap Storage Management (Cont’d) * Two problems: Memory fragmentation use compaction in to ways A.partial compaction: if blocks can not be shifted, compact adjacent blocks. B. full compaction: move blocks to one end and compact require readjusting pointer for active blocks.

More Related