1 / 27

Systems Software

Systems Software. Chapter 2 Memory Management - Early Systems. Operating systems bear the responsibility of managing the memory resource. It would be the rare computer which had more primary memory than it needed. OS Allocates Memory to Tasks

aizza
Télécharger la présentation

Systems Software

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. Systems Software Chapter 2 Memory Management - Early Systems

  2. Operating systems bear the responsibility of managing the memory resource. • It would be the rare computer which had more primary memory than it needed. • OS Allocates Memory to Tasks • Memory is a shared resource, and it is vital that the operating system manage this resource so that each executing task receives the memory that it needs in order to execute successfully • Memory allocation to a job must not interfere with other tasks which also need memory allocations.

  3. Four major Memory Management Schemes • Four major schemes have evolved for allocating and managing memory. • In this chapter we shall consider each of these briefly:

  4. I. Single User Contiguous Memory Allocation

  5. Characteristics of this Algorithm: • a. The program to be executed is loaded entirely and loaded into contiguous memory locations. • It is executed in its entirety and when execution ceases the memory is de-allocated for reuse.

  6. Today's personal computer OS usually work in a way similar to this. • Most PC operating systems (Mac OS, Windows, Unix ) are able to perform multitasking, • However, the mode in which people use them is often single-task-at-time (real time) mode. • Whether the memory allocated to a task in a PC is contiguous depends upon the allocation algorithm in use. Often the memory allocation is contiguous, if possible

  7. This mode of computing was not particularly cost effective, especially when system was expensive. • Today memory is relatively inexpensive so that allocating memory to a single task at one time is not as "expensive" as it once was. • The mode described here does not permit multiprogramming, rather, this mode of computing preceded multiprogramming.

  8. II. Fixed Partition Memory Management • This mode was developed during early attempts at the development of multiprogramming (multitasking). • When an operating system using this strategy was being configured a systems engineer or manager would specify fixed sized partitions of memory.

  9. Fixed partitions, continued • Jobs are then assigned and loaded into fixed partitions. • This system insured against intrusion on one task by another. • The partitions in which the operating system is loaded were considered protected.

  10. Fixed partitions, continued • As with the previous method, tasks are still loaded entirely and into contiguous memory. Each job received one partition. • This may waste space since a very small task may not need all of the memory of the partition to which it is assigned. • Wasted memory within a block is known as Internal Fragmentation • For efficiency, the partitions and their sizes must be “tuned” to the average job mix on the system. See figure 2.1 for an example.

  11. III. Dynamic Partitions Memory Management • The task is still loaded into contiguous memory and loaded entirely, • Here the partition assigned is only as large as requested. • Clearly, this makes much more efficient use of memory.

  12. Dynamic Partitions, continued • This method helps to eliminate fragmentation as jobs are loaded initially, but over time external fragmentation develops and memory use becomes less efficient - Figure 2.2 • External Fragmentation refers to the wasted memory between allocated memory blocks.

  13. Allocation Algorithms • Operating system may use one of several allocation schemes to assign memory to a requesting task • 1. First Fit - use first partition large enough. The operating system keeps a list of available partitions in location order. ( low --> high memory address) • 2. Best Fit - the operating system keeps list of available partitions arranged by size (smallest --> largest) The first partition large enough will be the one used.

  14. First Fit Algorithm • First-Fit is faster allocating but Best-Fit uses memory more efficiently. • -See table 2.2 • In the First-Fit algorithm the operating system keeps two lists: the free list and the busy list.

  15. First Fit, continued • The operating system takes a job from the Entry Queue, looks at the minimum partition size it will need and then examines the Free BlockList until large enough available block is found. • The first one found is then assigned to the job. If no block large enough is found then the operating system will enqueue job in the Waiting Queue.

  16. First Fit, continued • It then takes the next job from Entry Queue and repeats the procedure. • See table 2.4 for a First-Fit example. Assume dynamic partition sizing - and a request for a block of size 200.

  17. Best Fit Algorithm • The operating system takes a job from the Entry Queue, looks at the minimum partition size it will need and then examines the Free Block List until it finds the free block closest in size to the job. • When this block is found, it is then assigned to the job. • If no block large enough is found then the operating system will enqueue job in the Waiting Queue.

  18. Best Fit Algorithm, continued • It then takes the next job from Entry Queue and repeats the procedure. • See table 2.3 and 2.5 for a Best-Fit example.

  19. In a Dynamic Block Size environment the operating system would not keep the Free Block Size list in order (smallest to largest) even for a Best-Fit allocation scheme because the block sizes change constantly and there would be too much overhead. • -See table 2.5. Note the small "sliver" of memory which is useless.

  20. Deallocation of Blocks. • In a Fixed Partition scheme this is very straight forward, simply deallocate the partition and declare it available. • In a Dynamic Partition Size scheme deallocated partitions must be merged with any others they are contiguous to and the new block sizes calculated and entered into the Free Blocks List • -See tables 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13

  21. IV. Relocatable Dynamic Partitions • a. In this scheme the Memory Manager "garbage collects" to reclaim fragments and slivers of unused memory into larger groups of free blocks. • b. In order to accomplish this a very sophisticated "Compaction" algorithm is used which actually relocates the code of tasks in memory in order to push free blocks together.

  22. c. As programs are relocated downwards and all of the free space gets pushed to high end of memory • d. Every reference to a location within a program must be altered in order to be correct relative to the new program location in memory. • Data and references to external locations, however, must not be altered.

  23. e. A relocation register holds information about the “distance” the code is being relocated in memory, • i.e. its new location in relation to its original location.

  24. f. During execution an offset based on the relocation register is added to all necessary values in program. • See Fig. 2.5, 2.6. • The is a very slick method. It essentially eliminates memory waste but clearly there is a lot more overhead.

  25. When should memory compaction occur? • There are a number of strategies in use to decide when to compact. Some of the strategies include: 1. Compact when a certain % memory in is use 2. Compact only at fixed time intervals 3. Compact only when there are jobs waiting to enter. There are advantages and disadvantages to each.

  26. Assignment: • Be ready to discuss problems #4, 5, 10 a, b, c, d at end of Chapter 2. Write the solutions out to turn in next class.

  27. End of Chapter 2

More Related