StudentShare
Contact Us
Sign In / Sign Up for FREE
Search
Go to advanced search...
Free

Operating System Memory Management - Essay Example

Cite this document
Summary
This essay "Operating System Memory Management" focuses on memory management that is necessary for the execution of any program. To execute a program first of all the program must be prepared for execution. For accomplishing this certain activities are performed…
Download full paper File format: .doc, available for editing
GRAB THE BEST PAPER97.4% of users find it useful
Operating System Memory Management
Read Text Preview

Extract of sample "Operating System Memory Management"

MEMORY MANAGEMENT Introduction: "Programs expand to fill the memory that holds them."(Stallings,2005) Memory management is necessary for the execution of any program. To execute a program first of all the program must be prepared for execution. For accomplishing this the following activities are performed. 1. Development of program: Here the source program must be written first which would be in any language such as c, c++, java etc. Next the program must be compiled using the respective compilers which would produce the machine readable code i.e. the object code. Then the object code must be linked with a standard library and must be loaded into the computer's memory. Here the concept of memory management starts. The memory basically consists of a large array of words or bytes. Each word has it's own unique address that specifies it's location. CPU fetches these words from main memory and stores into memory address. The execution takes place through the instruction execution cycle. It takes place in the following steps: Fetch an instruction (opcode) from memory Decode instruction Fetch operands from memory, if needed Execute instruction Store results into memory, if necessary Also to be noted is that memory unit sees only the addresses and not how they are generated. 2. Address binding The mapping from one address space to another is termed as binding. For a program to execute it must be copied into main memory at a particular location. Many instructions use "fixed" addresses these must be bound to "fixed" locations in the memory. This binding of instructions and data to memory addresses may occur at: compile time, load time, or execution time. Dynamic Loading Memory Management Dynamic loading involves loading routines into memory only when required. This is done during execution. Dynamic loading reduces the memory requirements of large programs. This is especially the case if there is a large set of infrequently used routines. Help from the operating system is not essential for dynamic loading to take place although, the operating system may provide library routines to aid dynamic loading. Dynamic Linking Memory Management Dynamic linking is often used for libraries. Only a "stub" of the library is kept in the programs image. When a program calls one of these routines, the routine is loaded and linked into memory. All programs share the one copy of the same library routine. Dynamic linking requires the operating systems intervention as sharing between processes is required. 3. Implementation of Memory Management Implementation is done through memory tables to keep track of both main memory i.e. real memory as well as virtual memory. Also there is a unit MMU(Memory management unit) that performs the following tasks: Identifies a memory location in ROM, RAM, or i/o memory given a physical address Does not translate physical address Physical address is provided by an address bus to initiate the movement of code or data from one platform device to another Physical address is generated by devices that act as bus masters on the address buses (such as cpu) Frame buffers and simple serial ports are slave devices that respond to the addresses. Simple memory management scheme Sometimes there may be a shortage of main memory due to the size of various applications and also in some cases several active processes may need to share memory at the same time. In such cases partitioning of memory is done. Partitioning refers to systematic division of memory into blocks so that a process may be allocated to a block. This is of various types: 1. Fixed partition memory management: This is the simplest memory management scheme for multiprogrammed system. Here the memory is divided into fixed partitions. This is done when the system is initialized and won't be changed during the system operation. This again of two types: Single partition allocation: Here the user is provided with a bare machine and has full control of entire memory space. It's advantages are: Maximum flexibility to the user User controls the use of memory as per his own desire Maximum possible simplicity Minimum cost No need for special hardware No need for operating system software It's disadvantages are: No services OS has no control over interrupts No mechanism to process system calls and errors No space to provide multiprogramming 2. Two partition allocation: Here memory is divided into two partitions: Resident operating area and user memory area. O.S. is placed in low memory or high memory depending upon the location of interrupt vector. There is a need to protect O.S. code and data from changes by user processes i.e. protection must be provided by hardware that can be implemented by using base register and limit register. Loading of user process: First of all address of user space i.e. the space in which user performs operations must be beyond the base register, This is because any change in the base address requires recompilation of code. This can be avoided by having relocatable code from the compiler. The base value must be static during program execution. Handling transient code: Here user processes are loaded into high memory down to base register and allows the use of all available memory. Also address binding is delayed until execution time. Base register is known as relocation register. Value in base register is added to every address reference. User program never sees the real physical address but deals with only the logical. 3. Multiple partition algorithm. This scheme is necessary for multi programmed systems. Here memory is allocated to various processes in the wait queue to be brought into memory. The simplest scheme is as follows: Divide memory into a large number of fixed-size partitions One process to each partition Degree of multiprogramming bound by the number of partitions Partitions allocated to processes and released upon process termination Originally used by IBM OS/360 (MFT) Primarily useful in a batch environment For variable size partitions the features are as follows: Keep a table indicating the availability of various memory partitions Any large block of available memory is called a hole Initially the entire memory is identified as a large hole When a process arrives allocation table is searched and the hole is allocated Dynamic storage allocation problem Selects a hole to which a process should be allocated First-fit strategy Allocate first hole that is big enough Stop searching as soon as first hole large enough to hold the process is found Best-fit strategy Allocate the smallest hole that is big enough Entire list of holes is to be searched Search of entire list can be avoided by keeping the list of holes sorted by size Worst-fit strategy Allocate the largest available hole Similar problems as the best-fit approach (Stallings,2005) Memory management in Windows 2000 and Unix Windows 2000: The Windows 2000 virtual memory manager controls how memory is allocated and how paging is performed. The memory manager is designed to operate over a variety of platforms and uses page size varying from 4 kilobytes to 64 kilobytes. Basically virtual memory is a memory management technique where non-contigous memory is presented to a process as contigous memory. This memory is referred to as virtual address space. This concept is mainly used in paged memory systems like Windows. Technically speaking virtual memory allows software to be run in a memory address space whose size and addressing are not tied to computers physical memory.(Virtual memory-wikipedia) Windows 2000 virtual address map Each W2k user process sees a separate 32-bit address space allowing 4GB of memory per process. By default a portion of this memory is reserved for the O.S., hence each user has 2 GB of available virtual address space and all processes share the same 2GB of system space. There an option that allows user space to be increased to 3 Gbytes, leaving 1 Gbyte for system space. The W2K documentation indicates that this feature is intended to support large memory intensive applications on servers with multiple gigabytes of RAM, and that the use of the larger address space can dramatically improve performance for applications such as decision support or data mining. W2k paging: A page can be in one of three states: Available: Pages not currently used by the process. Reserved: A set contigous pages that the virtual memory manager sets aside for a process but doesn't count against the process's memory quota until used. When a process needs to write to memory some of the reserved memory is committed to the process. Committed: Pages for which the virtual memory manager has set aside space in it's paging file. The distinction between reserved and committed is useful because it (1) minimizes the amount of disk space set aside for a particular process, keeping that disk space free for other processes; and (2) enables a thread or process to declare an amount of memory that can be quickly allocated as needed. Hence it can be observed that the memory management in Windows 2000 is mainly based on the concept of virtual memory. Unix: Unix, like other advanced operating systems, allows you to use all of the physical memory installed in your system as well as area(s) of the disk (called swap space) which have been designated for use by the kernel in case the physical memory is insufficient for the tasks at hand. Virtual memory is simply the sum of the physical memory (RAM) and the total swap space assigned by the system administrator at the system installation time. Mathematically, Virtual Memory (VM) = Physical RAM + Swap space The Unix kernel divides the memory into manageable chunks called pages. A single page of memory is usually 4096 or 8192 bytes (4 or 8KB). Memory pages are laid down contiguously across the physical and virtual memory. Cache Memory: With increasing clock speeds for modern CPUs, the disparity between the CPU speed and the access speed for RAM has grown substantially. The RAM cache is simply a small amount of very fast (and thus expensive) memory which is placed between the CPU and the (slower) RAM. When the kernel loads a page from RAM for use by the CPU, it also prefetches a number of adjacent pages and stores them in the cache. Since programs typically use sequential memory access, the next page needed by the CPU can now be supplied very rapidly from the cache Dividing the RAM: When the kernel is first loaded into memory (at boot time), it sets aside a certain amount of RAM for itself as well as for all system and user processes: Main categories in which RAM is divided are: Text: to hold the text segments of running processes. Data: to hold the data segments of running processes. Stack: to hold the stack segments of running processes. Shared Memory: This is an area of memory which is available to running programs if they need it. Consider a common use of shared memory: Let assume you have a program which has been compiled using a shared library (the C-library is a good example - all programs need it). Assume that five of these programs are running simultaneously. At run-time, the code they seek is made resident in the shared memory area. This way, a single copy of the library needs to be in memory, resulting in increased efficiency and major cost savings. Buffer Cache: All reads and writes to the filesystem are cached here first. You may have experienced situations where a program that is writing to a file doesn't seem to work (nothing is written to the file). You wait a while, then a sync occurs, and the buffer cache is dumped to disk and you see the file size increase. The system and user areas When the kernel loads, it uses RAM to keep itself memory resident. Consequently, it has to ensure that user programs do not overwrite/corrupt the kernel data structures (or overwrite/corrupt other users' data structures). It does so by designating part of RAM as kernel or system pages (which hold kernel text and data segments) and user pages (which hold user stacks, data, and text segments). Strong memory protection is implemented in the kernel memory management code to keep the users from corrupting the system area. For example, only the kernel is allowed to switch from the user to the system area. During the normal execution of a Unix process, both system and user areas are used. Paging vs. Swapping: Paging: When a process starts in Unix, not all its memory pages are read in from the disk at once. Instead, the kernel loads into RAM only a few pages at a time. After the CPU digests these, the next page is requested. If it is not found in RAM, a page fault occurs, signaling the kernel to load the next few pages from disk into RAM. This is called demand paging and is a perfectly normal system activity in Unix. (Just so you know, it is possible for you, as a programmer, to read in entire processes if there is enough memory available to do so.) Swapping: When the kernel cannot find enough RAM to fit things in, it makes use of the available virtual memory by a process known as swapping. It selects the least busy process and moves it in its entirety (meaning the program's in-RAM text, stack, and data segments) to disk. As more RAM becomes available, it swaps the process back in from disk into RAM. Hence it can be observed that earlier versions simply used partitioning but the current versions are using Virtual memory as well. Bibliography: 1. Stallings, William (2005), Memory management- Operating systems internals and design principles 4th edition 2. Virtual memory, (Dec 2006) retrieved from http://en.wikipedia.org/wiki/Virtual_memory 3. Memory management in Unix,(Dec 2006) retrieved from http://www.uwsg.iu.edu/UAU/memory/physvir.html Read More
Cite this document
  • APA
  • MLA
  • CHICAGO
(“Operating system memory management Essay Example | Topics and Well Written Essays - 2500 words”, n.d.)
Operating system memory management Essay Example | Topics and Well Written Essays - 2500 words. Retrieved from https://studentshare.org/miscellaneous/1500692-operating-system-memory-management
(Operating System Memory Management Essay Example | Topics and Well Written Essays - 2500 Words)
Operating System Memory Management Essay Example | Topics and Well Written Essays - 2500 Words. https://studentshare.org/miscellaneous/1500692-operating-system-memory-management.
“Operating System Memory Management Essay Example | Topics and Well Written Essays - 2500 Words”, n.d. https://studentshare.org/miscellaneous/1500692-operating-system-memory-management.
  • Cited: 0 times

CHECK THESE SAMPLES OF Operating System Memory Management

Memory Management

Operating System Memory Management, 2.... From the paper "memory management" it is clear that memory organization needs to be done in order to allocate memory slots to the ever emerging processes.... Swapping is used as a memory management technique for a multiprogramming environment.... Swapping is used as a memory management technique for multiprogramming environment.... Discuss the main function(s) of each of the following operating system parts: a) memory management Unit The memory management Unit is said to serve as a buffering agent between the Central Processing Unit and the memory of the system....
6 Pages (1500 words) Essay

Memory Management

The paper "memory management" explains the programmer needs to address memory space where various variables will be stored and the intermediate results of execution.... In execution of programs, the operating system sees instructions as either processes or threads.... A system there has to be developed that will define a standard way in which a programmer accesses memory for storage purposes.... The computer memory is an essential component without which a computer would not be able to execute any instructions/processes....
8 Pages (2000 words) Lab Report

Analysis of Operating Systems

Name Institution: Tutor: Course: Date: Operating Systems Introduction An operating system is an integral part of a computer system.... All these resources need to be managed and that is where the operating system comes in.... The operating system sits between these peripheral components and the central hardware (the processing unit) and regulates the way these units access and use the operating system.... The operating system manages the application systems as well and acts as the intermediary between the applications which are not able to communicate directly with the computer hardware....
4 Pages (1000 words) Essay

Memory Management Paper

Once allocated, a process cannot hold memory indefinitely memory management refers to how a computer's memory is allocated between the.... memory management is essential for the proper resource allocation and functioning of a computer and it must essentially satisfy the following four requirements (Ramesh, 2010; Isrd, 2006); ... s a number of programs are usually present in the memory management Requirements By Introduction In order for a program to execute, it is brought into the main memory (swap in)....
2 Pages (500 words) Essay

The Operation of Java Applications in the Context of Operating Systems

Java is widely accepted as its memory management model enables programmers to evade the time-consuming job of physical memory management by implementing 'automatic garbage collection.... An operating system (OS) is a compilation of software that manages computer hardware and services for computer programs.... Application programs frequently necessitate an operating system in order to run.... An operating system (OS) is a compilation of software that manages computer hardware and services for computer programs....
6 Pages (1500 words) Term Paper

Applying Information Technology Systems in Manging a Sports Club

In this paper "Applying Information Technology Systems in Manging a Sports Club", an understanding of the utilization of IT for the improvement of a business system towards the advancement that they would likely want to garner from the market that they are trying to serve shall be discussed.... It could be observed that through this particular improving agent, many institutions today including profit-based organizations are already able to take considerable control of the market and the system operations that they using to manage their business....
14 Pages (3500 words) Case Study

Process Management in Operating Systems

The paper "Process Management in Operating Systems" explains how the operating system has a role to play in the allocation of resources to processes in a system, enable the processes to exchange and share information and protect the resources of each process for those of other processes.... Input and output management is mapped in the operating system through the use of input-output algorithms.... An operating system refers to a collection of software that manages the hardware resources within a computer (Gorman, 2000)....
9 Pages (2250 words) Coursework

Operating System - Case of Windows 7

The paper "operating system - Case of Windows 7" tells that Windows 7 plays a significant role in enhancing the experience of the users.... The management of the network is a concept that is well taken care of by the operating system.... It is therefore essential to note that the windows operating system has experienced a lot of changes and hence its ability to meet the requirements of the users.... On the other hand, the management of the secondary memory is vital in terms of ensuring proper storage of data....
10 Pages (2500 words) Case Study
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.
Contact Us