Вы находитесь на странице: 1из 26

Program must be brought into memory and placed within a process for it to be executed.

Input queue collection of processes on the disk

that are waiting to be brought into memory for execution. Select one process from input queue to load it into memory for execution. After execution (terminates) memory space becomes available.

Address binding of instructions and data to memory addresses can happen at three different stages:
Compile time: If memory location known a priori,

absolute code can be generated. Since it starts from that location. Load time: Must generate reloadable code if memory location is not known at compile time. Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers).

Multistep processing of a user program

The concept of a logical address space that is bound to a separate physical address space is central to proper memory management.
Logical address : Generated by the CPU; also referred to as

virtual address. Physical address: Address seen by the memory unit.

Logical and physical addresses are the same in compiletime and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme. The set of all logical address generated by a program.

The run-time mapping from virtual to physical addresses is done by the memory management unit (MMU), which is a hardware device. The user program deals with logical addresses; it never sees the real physical addresses.
Two different types of addresses:
Logical: range 0 to max. Physical: range R+0 to R+max; where R is a base value.

The user generates only logical addresses and thinks that the process runs in locations 0 to max.

In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. Example: Dynamic relocation using a relocation register.

Dynamic loading is used to obtain better memory space. An unused routine will never been used.
It is particularly useful when large amount of code. It does not requires any special support from the OS.

It is similar to Dynamic loading.


Here linking is postponed until the time of execution. It avoids to copy the whole language libraries included in the executable image.

A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution. Take Round robin scheduler as example, when time quantum expires the memory swap out the process and swap in another process. Roll out, roll in In priority-based scheduling algorithms; lower-priority process is swapped out if higher-priority process arrives and wants service, can be loaded and executed.

A process that is swapped out will be swapped back into the same memory space that it occupied previously. Normally CPU maintains the ready queue for the backing store.
When CPU needs it calls the dispatcher. If we want to swap, it should be completely idle.
Like without any pending i/o requests.

Main memory usually is divided into two partitions:


For the resident operating system
For the user processes.

The issues of memory protection is


Protecting OS from user processes. Protecting user processes from another process.

Relocation register: It contains the value of the smallest physical address.


Limit register: It contains the range of the logical address. Each logical address must be less than the Limit register and is dynamically adding the relocation register. This mapped address is sent to the memory.

The memory can be divided into several fixed sized components is called Partitions.
The block of available memory called as Hole. This may be at various sizes scattered throughout the memory.

To satisfy the request of size n from a list of free holes. There are three approaches.

First fit: Allocates the first hole that is big enough. Best fit: Allocates the smallest hole that is big enough, but it searches the entire list. It produces the smallest leftover hole. Worst fit: Allocates the largest hole, it also searches the whole list. It produces the largest leftover hole.

Simply wasting of the memory. Memory that is internal to the partition but is not used called Internal fragmentation. Memory that is outside to the partition and is too small to used by any process is called External Fragmentation.

Divide physical memory into fixed-sized blocks called frames (typically between 512 bytes and 8192 bytes).
Paging is a memory management technique where Division of logical memory into blocks of same size called pages.
i.e., divide each process into same size of frames.

Operating system maintains a page table for each process.


Page table contains the frame location for each process

page. memory address = page number + offset

Here the logical address is divided into two components.


1. Page number (p) 2. Page offset(d)

Page number p is an index into a page table that contains base address of each page in physical memory.

Page offset d is a displacement, combined with base address to define the physical memory address that is sent to the memory unit.

Page table is kept in main memory.


Page-table base register (PTBR) points to the page table. Page-table length register (PRLR) indicates size of the page table. In this scheme every data/instruction access requires two memory accesses. One for the page table and another for the data/instruction. The two memory access problem can be solved by the use of a special fast-lookup hardware cache called associative memory or Translation Look-aside Buffers (TLBs)

Associative Lookup = time unit


Assume time to access memory is 1 microsecond

Hit ratio percentage of times that a page number is found in the TLB.
Hit ratio =

Effective Access Time (EAT)


EAT = (1 + ) + (2 + )(1 ) = 2 +

Memory protection implemented by associating protection bit with each frame Valid-invalid bit attached to each entry in the page table:
valid indicates that the associated page is in the

process logical address space, and is thus a legal page. invalid indicates that the page is not in the process logical address space

V valid bit. I invalid bit.

Вам также может понравиться