Operating Systems Memory Management Memory Management Memory Management Organization Operating System Functions

Operating Systems Memory Management Memory Management Memory Management Organization Operating System Functions

Memory Management Organization Memory management depends on: Operating Systems p structure of address field of instruction arguments, Memory Management p position of address field in instruction word, p hardware capabilities of address field transformation. dr. Tomasz Jordan Kruk [email protected] Depending on the length of the address field the address space may be the same in size, smaller or bigger than the scope of operating memory addresses. Institute of Control & Computation Engineering Warsaw University of Technology Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 1/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 3/59 Memory Management Operating System Functions What is expected by programmers from the system memory: Functions of the operating systems from the point of view of memory management: p to be huge, address space management through address translation mechanisms, p to be fast, p memory contents protection, p to be nonvolatile. p p shared areas access control, Memory hierarchy: p effective organization of operating memory management. p small fast expensive memory (e.g. cache), The size of the operating memory for operating system code is usually fixed, p average in size, speed and expense memory (e.g. operating memory), but the allocation process for user processes is usually much more p huge, slow and cheap memory (e.g. disk/tape memory). complicated. Memory Management (MM) type on the level of operating system is dictated by the computer system architecture. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 2/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 4/59 Memory Allocation Methods M.A.M. With Division Methods of memory allocation to user processes: The goals of the memory division: 1. without division, all the memory allocated to one process. p better utilization of hardware elements of the system, mainly processor Multiprogramming may be implemented by swapping, and memory, 2. memory division, free operating memory divided into blocks allocated p enabling fast context switching. to particular user processes, The following types of systems with memory division may be distinguished: 3. usage of virtual memory, there exist one or more virtual address spaces allocated to user processes and without any direct obvious p systems with static division - either fixed partitions with different mapping to the physical address space. length or blocks with fixed length called frames. p systems with dynamic division - implemented by structures describing free blocks of memory with variable length and by swapping mechanism. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 5/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 7/59 M.A.M. Without Division Static Division Based on Constant Size Partitions Multiple input queues 0xFFF … 800K Operating Device Partition 4 Partition 4 700K system in drivers in ROM ROM User Partition 3 Single Partition 3 input queue program User program 400K User program Partition 2 Partition 2 Operating Operating 200K system in system in Partition 1 Partition 1 RAM RAM 100K Operating Operating 0 0 0 system system 0 (a) (b) (c) (a) (b) Three simple ways of organizing memory for an operating system with one user process. a. fixed memory partitions with separate input queues for each partition, b. fixed memory partitions with a single input queue. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 6/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 8/59 Dynamic Division Multiprogramming Modelling For implementation of dynamic memory allocation the following hypothetical 20% I/O wait functions: 100 50% I/O wait p allocate( size, address ) 80 ? choosing from the list of free blocks that one which covers demand, 60 80% I/O wait ? returning the address of the chosen block and removing allocated block from the free block lists as a result of allocation, 40 ? malloc( size ), calloc( n, size ), realloc( ptr, size ). 20 p free( address ) - adding pointed block to the free block list, e.g. free( CPU utilization (in percent) ptr ), 0 1 2 3 4 5 6 7 8 9 10 p msize() - return the size of the biggest currently available free block, Degree of multiprogramming msize() (but: races possible). CPU utilization as a function of number of processes in memory (ignoring operating system overhead). Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 9/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 11/59 MM in Multiprogramming Context Multiprogramming Effectiveness Analisys Multiprogramming has introduced two essential problems to be solved: CPU Arrival minutes # Processes Job time needed 1 2 3 4 1 10:00 4 CPU idle .80 .64 .51 .41 p relocation service - cannot be sure where program will be loaded in 2 10:10 3 CPU busy .20 .36 .49 .59 memory, 3 10:15 2 CPU/process .20 .18 .16 .15 4 10:20 2 p mutual memory protection. (a) (b) 2.0 .9 .8 .3 Job 1 finishes Possible solution: use of base and limit values: 1 Job 2 starts .9 .8 .3 .9 .1 2 .8 .3 .9 p address locations added to base value to map to physical address, 3 .3 .9 .1 .7 p address locations larger than limit value treated as an error. 4 0 0 10 15 20 22 27.6 28.2 31.7 Time (relative to job 1's arrival) (c) a. arrival and work requirements of 4 jobs, b. CPU utilization for 1{4 jobs with 80% I/O wait, c. sequence of events as jobs arrive and finish, numbers show amout of CPU time jobs get in each interval. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 10/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 12/59 Swapping Allocation Algorithms Time The role of the allocation algorithm is to chose appropriate free block in order to allocate it to some user process. C C C C C Some allocation algorithms: B B B B A p First Fit algorithm, first which matches from the list, A A A D D D p Best Fit algorithm, the optimal in size from the list, Operating Operating Operating Operating Operating Operating Operating system system system system system system system p Worst Fit algorithm, the biggest from the list, (a) (b) (c) (d) (e) (f) (g) p Buddies algorithm, memory (with size 2k) division into two equal in size blocks; dividing by two till obtaining minimal yet big enough block. Memory allocation changes as processes come into memory and leave memory. Shaded regions are unused memory. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 13/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 15/59 Fragmentation Anti-fragmentation Countermeasure Choosing allocation algorithm the following aspects should be considered: In the system there may be defined value ∆n as a minimal allowed size of allocated block, which makes easier management and improves effectiveness p effectiveness (speed), but may lead into fragmentation. p simplicity, Methods of countermeasure against fragmentation: p fragmentation effect. p deallocation and merging, Internal fragmentation - situation when some pieces of memory although allocated as part of some bigger structure (partition, frame) are not to p rellocation and compaction, be used by user processes. p paging mechanism. External fragmentation - situation when some pieces of memory although unallocated cannot be allocated for some reason (e.g. are too small) for user processes. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 14/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 16/59 Memory Management - Bitmaps and Lists Virtual Memory Virtual memory memory system consisting of at least two memory types: A B C D E 8 16 24 small and fast (e.g. operating memory) and big but slow (e.g. disk (a) memory), and moreover of additional hardware and software which 1 1 1 1 1 0 0 0 P 0 5 H 5 3 P 8 6 P 14 4 enable automatic moving of memory pieces between those memory 1 1 1 1 1 1 1 1 types. 1 1 0 0 1 1 1 1 H 18 2 P 20 6 P 26 3 H 29 3 X 1 1 1 1 1 0 0 0 Virtual memory should be almost as fast as the faster from above-mentioned Hole Starts Length Process memories and almost as huge as the bigger from the above-mentioned at 18 2 (b) (c) memories. a. part of memory with 5 processes and 3 holes, Methods of virtual memory implementation: ? tick marks show allocation units, p paging, ? shaded regions are free, p segmentation, ? the smaller the allocation unit, the larger the bitmap. p paging with segmentation. b. corresponding bitmap, c. same information as a list. Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 17/59 Faculty of E&IT, Warsaw University of Technology Operating Systems / Memory Management { p. 19/59 Dynamic Allocation Problem Memory Management Unit Role ¡ ¡ B-Stack The CPU sends virtual Room for growth addresses to the MMU Room for growth CPU ¡ ¡ B-Data ¡ package B Actually in use B-Program CPU Memory Disk Memory A-Stack management controller Room for growth unit Room for growth A-Data A Actually in use A-Program Bus Operating Operating system system The MMU sends physical (a) (b) addresses to the memory MMU (ang.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us