Sie sind auf Seite 1von 10

109074026

CHUKWUMA FELIX IKENNA MIT 1

Assignment on Operating System Memory Allocation Method

MIT 822 30th June, 2011


B E R A TE N D E IN G E N IE U R E

ORIGINAL

109074026

C O N S U LT IN G E N G IN E E R S IN G E N IE U R S C O N S E I L S

Lecturer: Dr Mrs. F. A. Oladeji

Operating System Computer Memory Allocation Methods MIT 822

109074026

TABLE OF CONTENT
1.0 1.1 INTRODUCTION ................................................................................................3 MEMORY MANAGEMENT REQUIREMENTS .......................................3

1.1.1 Relocation ...................................................................................................3 1.1.2 Protection 1.1.3 Sharing ...............................................................................................3 ...............................................................................................3

1.1.4 Local Organization ....................................................................................3 1.1.5 Physical Organization 2.0 .........................................................................4 ..................................................4

SIMPLE MANAGEMENT TECHNIQUES 2.1

FIXED PARTITIONING ........................................................................4 2.1.1 Placement Algorithm with Partitions 2.1.2 Dynamic of Fixed Partitioning ......................................4

.................................................4

2.2

DYNAMIC PARTITIONING

.............................................................5

2.2.1 The process ....................................................................................5 2.2.2 Internal/External Fragmentation 2.2.3 Dynamics of Variable Partitioning .......................................6 ......................................6

2.2.4 Dynamic Storage-Allocation Problem ......................................6 2.2.5 Placement Algorithm 2.2.6 Replacement Algorithm 2.3 2.4 3.0 Simple Paging .............................................................6 .............................................................7

....................................................................................8 .............................................................9

SIMPLE SEGMENTATION

REFERENCES

.............................................................................................10

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

2/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

1.0

INTRODUCTION

Memory management is the act of managing computer memory. It is the task carried out by the Operating system and hardware to accommodate multiple processes in main memory. It is one of the most fundamental areas of computer programming. The management of main memory is critical to the computer system If only a few processes can be kept in main memory, then much of the time all processes will be waiting for I/O and the CPU will be idle. Hence, memory needs to be allocated efficiently in order to pack as many processes into memory as possible In most schemes, the kernel occupies some fixed portion of main memory and the rest is shared by multiple processes. Physical and Virtual Memory Memory management utilizes the concept of virtual memory. Each process on the computer believes that it has access to all the physical memory. Apparently, since there are multiple programs at the same time, each process cannot own all the memory. The concept of virtual memory is utilized. This concepts implements the virtual address spaces provided to each process. A virtual address space is implemented by the Memory Management Unit (MMU) of the CPU and can always map process to physical memory address. 1.1 MEMORY MANAGEMENT REQUIREMENTS

Management of memory required the following concepts. 1.1.1 Relocation: This is the ability of the memory management in the operating system to relocate programs in memory and handle memory references and addresses to be able to spot the right location in the memory when the need arises. Ordinarily, a programmer cannot know where the program will be placed in memory when it is executed. A process may often be relocated in main memory due to swapping. Swapping enables the operating system to have a larger pool of ready to execute processes. Relocation enables memory references in code to be translated to actual physical memory address. 1.1.2 Protection: Memory management required a sort of protection in which a process referencing a memory of another process should be sought with permission. It is way to control memory access right on a computer. Memory protection prevents a process from accessing memory that has not been allocated to it. 1.1.3 Sharing: Sharing is a basic requirement that enable different processes to communicate with one another and share resources from same part of memory. This achieves its goal without compromising protection. It allows each process to access the same copy of the program rather than their own separate copy. 1.1.4 Local Organization: Programmers write programs in modules with different characteristic. Some of these modules are execute only while others could be shared between different programs, some are read only and some contain data that can be modified. The memory management is responsible for handling this logical organization that is different from the physical

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

3/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

linear address space and supporting a basic form of module to provide the required protection and sharing. 1.1.5 Physical Organization: Processes can be stored in the primary memory which is very fast or secondary memory that is relatively slow. Moving information between these two levels of memory is a major concern of memory management in operating system. 2.0 2.1 SIMPLE MANAGEMENT TECHNIQUES FIXED PARTITIONING

This involves the partitioning of main memory into a set of non overlapping regions called partitions. The partitions can be of equal or unequal sizes. As shown below
Operating system 8M Operating system 8M

8m 8M 8M 8M

5M 13M 14M 2M Unequal size partitioning

Equal size Partitioning

With this management technique, any process whose size is less than or equal to a partition size can be loaded into the partition. If all partitions are occupied, the operating system can swap a process out of a partition. Leftover space in partition, after program assignment, is called internal fragmentation. Also, a program may be too large to fit in a partition, the programmer must then design the program with overlays. 2.1.1 Placement Algorithm with Partitions: For an equal size partition, If there is an available partition, a process can be loaded into that partition, because all partitions are of equal size, it does not matter which partition is used. If all partitions are occupied by blocked processes, choose one process to swap out to make room for the new process. Unequal size partition make use of multiple queues. Each process is assign to the smallest partition within which it will fit. A queue exists for each partition size. The algorithm tries to minimize internal fragmentation. The challenge is that some queues might be empty while some might be loaded. When it is time to load a process into memory, the smallest available partition that will hold the process is selected. 2.1.2 Dynamic of Fixed Partitioning Any process whose size is less than or equal to a partition size can be loaded into the partition. If all partitions are occupied, the OS can swap a process out of a partition. A program may be too large to fit in a partition. The programmer must design the program with overlays
/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011 4/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This can cause internal fragmentation. Unequal-size partitions lessens these problems but they still remain 2.2 DYNAMIC PARTITIONING Dynamic partitions are defined by the operating system. They are defined out of unallocated drive space and, as such, are not known at boot time. They cannot generally be shared between different installations. Also, unless the operating system using dynamic partitions makes at least its allocations known to the boot record, any attempt to manage disc space using both techniques is dangerous 2.2.1 The process When a process arrives, it is allocated memory from a hole large enough to accommodate it. Hole block of available memory; holes of various sizes are scattered throughout memory. Operating system maintains information about: a) allocated partitions b) free partitions (holes

Simple paging Simple segmentation Managing allocated and free partitions Example: memory with 5 processes and 3 holes: tick marks show memory allocation units. shaded regions (0 in the bitmap) are free.

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

5/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

Memory Management with Linked Lists

2.2.2 Internal/External Fragmentation There are really two types of fragmentation: Internal Fragmentation: Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.
/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011 6/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

External Fragmentation: Total memory space exists to satisfy a size n request, but that memory is not contiguous Reducing External Fragmentation Reduce external fragmentation by doing compaction: This will shuffle memory contents to place all free memory together in one large block (or possibly a few large ones). Compaction is possible only if relocation is dynamic, and is done at execution time. The I/O challenges may include locking job in memory while it is involved in I/O. 2.2.3 Dynamics of Variable Partitioning Partitions are of variable length and number. Each process is allocated exactly as much memory as it requires. Eventually holes are formed in main memory. This can cause external fragmentation. Compaction must be used to shift processes so they are contiguous; all free memory is in one block 2.2.4 Dynamic Storage-Allocation Problem The request of size n from list of free holes are satisfied Four basic methods are utilized: First-fit: Allocate the first hole that is big enough. Next-fit: Same logic as first-fit but starts search always from the last allocated hole (need to keep a pointer to this) in a wraparound fashion. Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. This produces the smallest leftover hole. Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole 2.2.5 Placement Algorithm This is used to decide which free block to allocate to a process. The aim is to reduce usage of compaction procedure due to its time consuming nature Example algorithms are: First-fit Next-fit Best-fit Comments on Placement Algorithm First-fit favours allocation near the beginning: tends to create less fragmentation then Nextfit. Next-fit often leads to allocation of the largest block at the end of memory. Best-fit searches for smallest block: the fragment left behind is small as possible Main memory quickly forms holes too small to hold any process: compaction generally needs to be done more often. First/Next-fit and Best-fit better than Worst-fit (name is fitting) in terms of speed and storage utilization
/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011 7/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

2.2.6 Replacement Algorithm When all processes in main memory are blocked, the OS must choose which process to replace: A process must be swapped out (to a Blocked-Suspend state) and be replaced by a process from the Ready-Suspend queue or a new process 2.3 Simple Paging In Paging, mechanism, main memory is partition into equal fixed-sized chunks of relatively small size The trick is that each process is also divided into chunks of the same size called pages. The process pages can thus be assigned to the available chunks in main memory called frames (or page frames) Consequence: a process does not need to occupy a contiguous portion of memory. Example of process loading

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

8/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

The OS now needs to maintain (in main memory) a page table for each process. Each entry of a page table consists of the frame number where the corresponding page is physically located. The page table is indexed by the page number to obtain the frame number. A free frame list, available for pages, is maintained

2.4

SIMPLE SEGMENTATION

Each program is subdivided into blocks of non-equal size called segments. When a process gets loaded into main memory, its different segments can be located anywhere. Each segment is fully packed with instructs/data: no internal fragmentation. There is external fragmentation; it is reduced when using small segments. In contrast with paging, segmentation is visible to the programmer. Provided as a convenience to organize logically programs (i.e.: data in one segment, code in another segment). The limit of the segment size limit must be known. The OS maintains a segment table for each process. Each entry contains the starting physical addresses of that segment and the length of that segment for protection Logical address used in segmentation

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

9/10

Operating System Computer Memory Allocation Methods MIT 822

109074026

When a process enters the Running state, a CPU register gets loaded with the starting address of the processs segment table. Presented with a logical address (segment number, offset) = (n, m), the CPU indexes (with n) the segment table to obtain the starting physical address k and the length l of that segment. The physical address is obtained by adding m to k (in contrast with paging). The hardware also compares the offset m with the length l of that segment to determine if the address is valid Segmentation requires more complicated hardware for address translation. It suffers from external fragmentation. Paging only yields a small internal fragmentation. Segmentation is visible to the programmer whereas paging is transparent. Segmentation can be viewed as commodity offered to the programmer to organize logically a program into segments and using different kinds of protection (ex: execute-only for code but read-write for data), for this we need to use protection bits in segment table entries

3.0

REFERENCES

www.en.wikipedia.org/memory_management www.en.wikipedia.org/wiki/Virtual_memory the memory management Reference beginners Guide: Overview: www.memorymanagment.com. www.wiki.answers.com www.cs.jhu.edu/fixed partitioning www.acm.uva.es www.csd.uoc.gr/~hy345/notes/4.ppt

/opt/scribd/conversion/tmp/scratch28765/65182097.doc 30.06.2011

10/10

Das könnte Ihnen auch gefallen