Presentation is loading. Please wait.

Presentation is loading. Please wait.

3.0 : Resource Management Part 1 : Memory Management.

Similar presentations


Presentation on theme: "3.0 : Resource Management Part 1 : Memory Management."— Presentation transcript:

1 3.0 : Resource Management Part 1 : Memory Management

2 Learning Outcomes Understand the Memory Management Types of memory allocate scheme Single – User Configuration Fixed – partition memory management Dynamic memory management Paging Segmentation Virtual Memory Dynamic Address Translation

3 Primary Activities Perform in Memory management Keep track of which part of memory are currently being used and by whom. Decide which process to load when memory becomes available Allocate and deal locate memory space as needed

4 Features of Static and Dynamic Memory Allocation Kind of AllocationKey features Static Allocation Allocation before start of execution of program Size should be known before start of execution, else over allocation and wastage of memory will result No allocation during program execution Dynamic Allocation Allocation during execution of program Allocation exactly equal requirement, no wastage of memory Allocation overhead during program execution

5 Types of Memory Allocation Scheme a.Single – User Configuration b.Fixed- Partition c.Dynamic Partition d.Paging/ Paged Memory Allocation e.Segmentation

6 Memory Allocation Scheme: Single – User Configuration Is early memory management schema – seldom use by today OS. This is fundamentals concept that helped memory management evolve Single – User Configuration work like this ; – Each program to be processed was loaded entirely and allocated as must contiguous space in memory as it needed. – If the program too large and didn’t fit the available memory space, it couldn’t be executed – It demonstrates limiting factor of all computer.

7 Memory Allocation Scheme: Single – User Configuration Each user given access all available main memory for each job and job processed sequentially, one after the other For allocate memory OS use this algorithm;

8 Algorithm to load a job in a Single – User Configuration 1.Store first memory location of program into base register (for memory protection) 2.Set program counter (it keeps track of memory space used by the program) equal to address of first memory location 3.Read first instruction of program 4.Increment program counter by number of bytes instruction 5.Has last instruction been reached? 1.If yes, then stop loading 2.If no, then continue with step 6 6.Is program counter greater than memory size? 1.If yes, stop loading 2.If no, then continue step 7 7.Load instruction in memory 8.Read next instruction of program 9.Go to step 4

9 Memory Allocation Scheme: Single – User Configuration Notice amount of work done by operating system using these schema is minimal. The code perform the function is straightforward and logic is quite simple Only two hardware item is needed: – a register (to store the base address ) – a accumulator (to keep track the size of program as it’s being read into memory) Once program is entirely loaded into memory, it remains there until execution is complete, either through normal termination or by intervention of the OS

10 Major problem in Single – User Configuration Scheme The scheme doesn’t support multiprogramming It can only handle one job at a time Commercially in the late 1940s and early 1950s

11 Memory Allocation Scheme: Fixed Partition First attempt to allow multiprogramming – create fixed partition scheme within the main memory (one partition of each job) Also known as static partition This is because the size of partition was designated when the system was powered on. Each partition could only be reconfigured when the computer system was shut down, reconfigured, restart. Once system in operation the partition sized remained static

12 Algorithm to load a job in a Fixed Partition 1.Determine job requested memory size 2.If job_size > size of largest partition Then reject the job 1.Print appropriate message to operator 2.Go to step 1 to handle next job in line Else Continue with step 3 3.Set counter to 1 4.Do while counter <= number of partitions in memory If job_size > memory _partition_size (counter) Then counter = counter +1 Else If memory_partition_status(counter) = free Then load job into memory_partition(counter) change memory_partition_status(counter) to “busy” go to step 1 Else counter = counter +1 End do No partition available at this time, put job in waiting queue, get next job Go to step 1

13 Example of Fixed Partition 2560K Operating System 0 400K 2160K Job Queue Process P1600K P21000K P3300K P4700K P5500K size

14 Example of Fixed Partition

15 Advantages and Disadvantages of Fixed Partition AdvantagesDisadvantages More flexible scheme compare to single – user scheme because allow several program to be in memory at the same time. Internal Fragmentation occur Internal fragmentation is allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. However, it still requires that the entire program be stored contiguously and in memory from the beginning to the end of it’s execution

16 Memory Allocation Scheme : Dynamic Partition Available memory is still kept in contiguous block But jobs are given only as much memory as they request when they are loaded for processing. Improvement over fixed partition because memory isn’t wasted within the partition. Dynamic partition scheme fully utilize memory when the first job loaded. Will use concept first –come first serve priority. External Fragmentation occur– total memory space exists to satisfy a request, but it is not contiguous

17 Memory Allocation Scheme: Paging Is dividing incoming job into pages of equal size Normally OS choose a page size same as memory block size and same size as section of the disk in which the job is stored. – Section of the disk called sector/ block – Section of the main memory are called pages frame The scheme work quite efficiently when the pages, sector and page frame are all the same size.

18 Memory Allocation Scheme: Paging Before execute a program/job, Memory Manager prepares it by : – Determining the number of pages in the program – Locating enough empty pages frames in main memory – Loading all of the program’s pages into pages frames When program/job is initially prepared for loading, pages are in logical sequence (the 1 st page contain the first instructions of the program and last page has the last instructions) Program instruction can be thought as lines of code or bytes.

19 Memory Allocation Scheme: Paging The loading process is different from the previous schemes because the pages do not load in contiguous memory blocks. Each page can be stored in any available page frame. Anywhere in main memory

20 Example 1 Memory Allocation Scheme: Paging

21 Example 2 Memory Allocation Scheme: Paging

22 Memory Allocation Scheme: Paging AdvantagesDisadvantages Is storing program in noncontiguous location is that main memory. Main memory is used more efficiently because an empty page frame can be used by any page of any job Because job pages / program can be located anywhere in main memory, Memory Manager needs mechanism to keep track of them(job pages). Eliminate compaction scheme. Which is used for reloadable partition. This is because of no external fragmentation between pages frames External Fragmentation a situation happened in dynamic allocation scheme. Creates unusable fragment of free memory between blocks of busy, or allocated, memory. Enlarging the size and complexity of the operating system software. Which increase overhead Internal fragmentation is still a problem, although only in the last page of each job

23 Memory Allocation Scheme : Segmentation Concept : based on the common practice by programmers of structuring their program in modules Segmentation scheme : each job is divided into several segment of different sizes. One for each module that contains pieces that perform related function Main memory is no longer divided into page frames because the size of each segment is different (some are large some are small) When a program is compiled the segment are set up according to the program’s structural modules.

24 Memory Allocation Scheme : Segmentation A program is a collection of segments. A segment is a logical unit such as: – Main program,subroutine – Procedure – Function – Method – Object – Local variable, global variable, – Stack, array,symbol table

25 Memory Allocation Scheme : Segmentation Each segment is numbered and a Segment Map Table(SMT) is generated for each job. SMT contains the segment numbers, their lengths, access right, status and when each is loaded into memory and it’s location Memory Manager need to keep track of the segments in memory.

26 Memory Allocation Scheme : Segmentation Each segment is numbered and a Segment Map Table(SMT) is generated for each job. SMT contains the segment numbers, their lengths, access right, status and when each is loaded into memory and it’s location Memory Manager need to keep track of the segments in memory.

27 Memory Allocation Scheme : Segmentation Memory-management scheme that supports user view of memory. User’s View of a Program

28 Memory Allocation Scheme : Segmentation 1 4 2 3 user spacephysical memory space 1 3 2 4

29 Memory Allocation Scheme : Segmentation Before execute the program/job Memory Manager prepare it by : – The job table list every job in process (one for whole system) – The Segment Map Table lists details about each segment (one for each job) – The Memory Map Table monitor the allocation of main memory (one for the whole system) The program’s instructions within each segment are ordered sequentially. The segment don’t need to be stored contiguously in memory The content of the segments themselves are contiguous in this scheme.

30 Example Memory Allocation Scheme : Segmentation To access specific location within a segment we can perform an operation similar to the one used paging scheme. Differences is segment instead of pages. The addressing scheme requires the segment number and the displacement within segment Because the segment are of different sizes, the displacement must be verified to ensure it isn’t outside the segment’s range.

31 Memory Allocation Scheme : Segmentation SMT – map two dimensional physical address; each table has limit : specifies the length(size) of the segment base : contain the starting physical address where the segments reside in memory (memory address)

32 Comparison of memory allocation schemes SchemeProblem SolvedProblem CreatedChanges in Software Single-user contiguous -Job size limited to physical memory size -CPU often idle None Fixed PartitionIdle CPU time-Internal fragmentation occur -Job size limited to partition size -Add Processor Scheduler -Add protection handler Dynamic PartitionsInternal fragmentationExternal FragmentationNone PagingNeed for compaction scheme -Memory needed for tables -Job size limited to physical memory size -Internal fragmentation returns Need algorithm to handle Page Map Tables Segmentation-Internal fragmentation -Sharing of segments Difficulty managing variable-length segments in secondary storage - External fragmentation Two-dimensional addressing scheme

33 Virtual Memory Virtual memory it is a illusion of a memory which is different from a real memory (RAM) existing in a computer system. This memory maybe much larger than the real memory. The basis of VM implementation is noncontiguous memory allocation

34 Cont.. Noncontiguous allocation permit parts of a program to be loaded into two or more non- adjacent areas of memory execution This technique is reduce the problem of memory fragmentation since free area memory can be reused even the size is small than free memory. VM implementation is an arrangement which enable program to execute even when its entire code and data are not present in the memory

35 Cont.. The idea is to load required portion of code /data in memory at any time By this arrangement allow execution of program which size program exceed the size of memory. This strategy increases the number of program which can accommodated in memory. All modern general-purpose computer operating systems use virtual memory techniques for ordinary applications, such as word processors, spreadsheets, multimedia players, accounting, etc

36 Dynamic Address Translation Dynamic address translation (DAT) is the process of translating a virtual address during a storage reference into the corresponding real address.


Download ppt "3.0 : Resource Management Part 1 : Memory Management."

Similar presentations


Ads by Google