You are on page 1of 7

Memory Management:

y y

Differentiate between logical and physical memory addresses.  Logical address generated by the CPU; also referred to as virtual address.  Physical address address seen by the memory unit. What benefit does dynamic linking provide, in terms of applications using system libraries? Dynamic linking is particularly useful for libraries, which may be loaded in advance, or on demand  Also known as shared libraries  Permits update of system libraries without relinking What basic task does the memory management unit hardware perform for an operating system. Hardware device that maps virtual to physical address Explain how base and limit registers are used to provide memory protection when contiguous memory allocation is used.  Relocation register contains value of smallest physical address; limit register contains range of logical addresses each logical address must be less than the limit register.

y y

Explain how relocation and limit registers implement execution time address binding and memory protection, when contiguous memory allocation is used. Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data. Briefly describe the first-fit, best-fit, and worst-fit approaches to contiguous memory allocation. Best Fit The allocator places a process in the smallest block of unallocated memory in which it will fit. Problems:
 It requires an expensive search of the entire free list to find the best hole.  More importantly, it leads to the creation of lots of little holes that are not big enough to

satisfy any requests. This situation is called fragmentation, and is a problem for all memory-management strategies, although it is particularly bad for best-fit. Solution:One way to avoid making little holes is to give the client a bigger block than it asked for. For example, we might round all requests up to the next larger multiple of 64 bytes. That doesn't make the fragmentation go away, it just hides it.

 Unusable space in the form of holes is called external fragmentation  Unusable space in the form of holes is called external fragmentation

Worst Fit The memory manager places process in the largest block of unallocated memory available. The ides is that this placement will create the largest hole after the allocations, thus increasing the possibility that, compared to best fit, another process can use the hole created as a result of external fragmentation. First Fit Another strategy is first fit, which simply scans the free list until a large enough hole is found. Despite the name, first-fit is generally better than best-fit because it leads to less fragmentation. Problems:
 Small holes tend to accumulate near the beginning of the free list, making the memory

allocator search farther and farther each time. Solution:


 Next Fit

Given the following sequence of memory requests in an operating system that uses a nonpreemptive contiguous memory allocation scheme, give the time and memory layout as each request is satisfied. The computer hasMegaBytes of memory. [Some sequence of requests, make up your own]

Explain why memory might not be used efficiently when contiguous memory allocation is used in a multi-tasking operating system. Due to wastage of memory when process leave memory and an other process of relatively big size com then memory become useless
y

What is the difference between internal and external memory fragmentation? y Internal fragmentation occurs when more storage is allocated than is actually requested. This left over space, known as slack space, causes a degradation of system performance. For example, space can be left over between the last byte of the file and the first byte of the next sector. This slack space can add up and eventually cause system performance to degrade. y External fragmentation occurs when free memory becomes divided into several small blocks over time. For example, this can cause problems when an application requests a block of memory of 1000bytes, but the largest contiguous block of memory is only 300bytes. Even if ten blocks of 300 bytes are found, the allocation request will fail because they are not contiguous. This can be caused by an excessive amount of clutter on a system. Explain what "compaction" is used for in memory management. Compaction attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes. Aside from the obvious cost of all that copying, there is an important limitation to compaction: Any pointers to a block need to be updated when the block is moved. Unless it is possible to find all such pointers, compaction is not possible. Pointers can stored

in the allocated blocks themselves as well as other places in the client of the memory manager. In some situations, pointers can point not only to the start of blocks but also into their bodies. For example, if a block contains executable code, a branch instruction might be a pointer to another location in the same block. Compaction is performed in three phases. First, the new location of each block is calculated to determine the distance the block will be moved. Then each pointer is updated by adding to it the amount that the block it is pointing (in)to will be moved. Finally, the data is actually moved. There are various clever tricks possible to combine these operations.

Work out the optimal (minimal movement) compaction of the following fragmented memory. What is "swapping", in the context of memory management? y If a disk is available, we can also swap blocked jobs out to disk. Swapping out a job involves copying all memory containing data (and program code if it has changed) onto the disk, and releasing the main memory that it was using. The process is then suspended until there is an opportunity to swap it back in again. All data and program code is restored from the copy on disk, allowing the process to continue running in main memory from the point before it was swapped out. y When a job finishes, we first swap back jobs from disk before allowing new jobs to start. When a job is blocked (either because it wants to do I/O or because our short-term scheduling algorithm says to switch to another job), we have a choice of leaving it in memory or swapping it out. One way of looking at this scheme is that it increases the multiprogramming level (the number of jobs ``in memory'') at the cost of making it (much) more expensive to switch jobs. y A variant of the MLFQ (multi-level feedback queues) selection algorithm is particularly attractive for this situation. The queues are numbered from 0 up to some maximum. When a job becomes ready, it enters queue zero. The CPU scheduler always runs a job from the lowest-numbered nonempty queue (i.e., the priority is the negative of the queue number). It runs a job from queue i for a maximum of i quanta. If the job does not block or complete within that time limit, it is added to the next higher queue. Jobs with short quanta in that short bursts get high priority, but does not incur the overhead of frequent swaps between jobs with long bursts.

How might swapping interfere with DMA? An apparatus and method for performing byte swapping using a direct memory access (DMA) controller is provided. In a computer system, a DMA controller for a peripheral component is coupled to system memory via a bus. The DMA controller receives a command pointer to initiate a memory access operation. The command pointer specifies the location of the first DMA command in a command list to be executed by the DMA controller

What are the two components of a logical address in a segmented memory environment?

In the given the following segment table, and a logical addressing scheme that uses the first 5 bits of a 16 bit logical address to specify the segment table offset, what is the physical address

that corresponds to the following logical address? [Segment table, logical address, make up your own] What information do a Segment Table Base Register and Segment Table Limit Register hold? Explain the basic principal of paging in memory management (without virtual memory management, i.e., no demand paging).

The main functions of paging are performed when a program tries to access pages that are not currently mapped to physical memory (RAM). This situation is known as a page fault. The operating system must then take control and handle the page fault, in a manner invisible to the program. Therefore, the operating system must: 1. 2. 3. 4. 5.
y

Determine the location of the data in auxiliary storage. Obtain an empty page frame in RAM to use as a container for the data. Load the requested data into the available page frame. Update the page table to show the new data. Return control to the program, transparently retrying the instruction that caused the page fault.

What is a page table used for? The page number of an address is usually found from the most significant bits of the address; the remaining bits yield the offset of the location within the page. The page table is normally indexed by page number and contains information on whether the page is currently in main memory, and where it is in main memory or on disk.

http://en.wikipedia.org/wiki/Paging
y

Explain how a logical memory address is transformed into a physical memory address in a paged memory system.
y

In a paging system, the process space is divided into consecutive pages of fixed length: Page 0, Page 1, Page 2, etc. As such, a logical address (also called a virtual address) consists of:  A page number  An offset within that page In a paging system, main memory is divided into consecutive frames of fixed length (same length as the pages): Frame 0, Frame 1, Frame 2, etc. Some of the logical pages are placed in the physical frames. For example, pages 3, 8 and 10 might be placed in frames 104, 87 and 378, respectively, with the other pages of the process in virtual memory, i.e., on disk (or other form of secondary memory). The goal of this exercise is to help you understand 4 approaches to converting a logical address (page number + offset) to a physical address (frame number + offset, or a page fault if the page is not in main memory):  Simple indexing  Multi-level indexing  Hashing into an inverted page table  Associative lookup in a cache called the translation lookaside buffer (TLB)

http://www.rose-hulman.edu/class/csse/csse332/200920/Homework/hw29Files/VirtualMemory.pdf
y

Explain how paging implicitly implement memory protection.

What information do the Page Table Base Register and Page Table Limit Register hold?
y

In a paged memory system, why is the number of pages and each frame size typically a power of 2? Paging is implemented by breaking up an address into a page and offset number. It is most efficient to break the address into X page bits and Y offset bits, rather than perform arithmetic on the address to calculate the page number and offset. Because each bit position represents a power of 2, splitting an address between bits results in a page size that is a power of 2

In a computer system with 64KB memory divided into 2KB frames, and with the following page table, what is the final physical address computed for the following logical address? [Page table, physical address, make up your own].

y y

How does a TLB improve the performance of a paged memory system? If the memory cycle time of a computer is 1microsecond, and the TLB look-up time is 0.15microsecond, what is the effective memory access time if the TLB hit rate is 98%? Give two factors that suggest increasing the page size and two factors the suggest decreasing the page size, in a paged memory system. How may page tables be extended to provide various forms of memory protection? Give an example. Explain how swapping is easily implemented in a paged memory system.

y y

What is the motivation for using multi-level paging? In a two level paged memory system, explain the components of a logical memory address.

y y y

What information does each entry of an inverted page table contain? Explain the format of a logical address in a memory management system that uses an inverted page table, and explaion how such an address is converted into a physical address. Explain how shared memory is easily implemented in a paged memory system.

Why is a segmented memory management system potentially more effective than a paged system?

What is a drawback of segmentation compared to paging? Because segments are of unequal size, this is similar to dynamic partitioning (at the segment level).so segmentation is more effective. Segmentation has no internal fragmentation
y

Can segmentation and paging be effectively combined?  Several combinations of segmentation and paging exist. Example: o Each process has:  one segment table  one page table per segment o Virtual address consists of:  segment number: index the segment table to get starting address of the page table for that segment  page number: index that page table to obtain the physical frame number  offset: to locate the word within the frame  Segment and page tables can themselves be paged Describe the three components of a logical address for a paged-segmented memory system. What is the valid-invalid bit used for in a virtual memory system? Explain the steps that need to be taken when a page fault occurs in a paged virtual memory system (assume there is a free frame available). Explain the steps that need to be taken when a page fault occurs in a paged virtual memory system (assume there is no free frame available). How can a "dirty bit" improve the performance of a virtual memory system? What is the difference between global and local replacement in a paged virtual memory system? In a paged virtual memory system, with N frames of memory, and the following sequence of page references, show which pages are in which frames after each memory reference, using the {optimal,FIFO,LRU,second chance,enhanced second chance} page replacement algorithm. Give the total number of page faults. [Make up your own example] What is Belady's anomaly? Describe two ways of implementing the LRU page replacement algorithm for a paged virtual memory system. Describe the four categories of pages used to determine replacement in the enhanced second chance replacement algorithm. Given the following processes' claims for pages of memory in a system that has N frames, how many pages are allocated to each process using {equal,proportional} allocation? [List of processes and claims] In a system that has a memory cycle time of 1microsecond and a page transfer time of 5000microseconds, what is the effective memory access time if the page fault rate is 0.5%? Define "thrashing" in the context of paged memory management. How may long-term CPU scheduling be a cause of thrashing? Explain a possible conflict between paging and DMA. Explain how paging can make process start-up efficient, using the copy-on-write technique.

y y y y y y y

y y y y

y y y y y

You might also like