Professional Documents
Culture Documents
Topics
Memory management Resident and transient routines Related terminologies Dynamic address translation Virtual memory Processor management Control blocks and interrupts Types of scheduling processes Scheduling algorithms Queuing routine and scheduler Multiprogramming and time sharing Deadlock
the more programs in memory, the greater the utilization of the processor.
Memory Management
Memory management is done by memory manager.
Main tasks are to: Keep track of which parts of memory are in use and which parts are not in use Allocate memory to processes when they need it and deallocate it when they are done Manage swapping between main memory and disk when main memory is too small to hold all the processes
memory. Key control information comes first followed by the various resident operating system routines. The transient area, is where application programs and transient operating system routines are loaded.
Transient Area
Fetch
To load an instruction or piece of data from memory
into a CPU's register. All instructions must be fetched before they can be executed.
The time it takes to fetch an item is known as the
Paging
Fixed Partition
Dynamic
Segmentation
Paging
length) partition each of which holds one program Partition sizes are set when the system is initially started So the memory allocation decision is made before the actual amount of space needed by a given program is known
for the smallest partition large enough to hold it. Since a partition is fixed in this scheme, any space in a partition not used by a job is lost (internal fragmentation)
separate queues is when the queue for a large partition is empty but the queue of a small partition is full(Refer figure a) Small jobs have to wait to get into memory, even though plenty of memory is free Alternative of separate queues is to maintain a single queue(Refer figure b)
the front of the queue that fits in could be loaded into the empty partition and run Small partition is usually used to allow small jobs to run without having to allocate large partition for them which will cause waste of partition space
800K
Partition 4
700K
Partition 3
Partition 2
400K
200K 100K
0K
800K
700K
200K 100K
0K
space. When the system loads a particular program, a region of memory just sufficient to hold the program is allocated from the pool. Because a program gets only the space it needs, relatively little space is wasted
finished executing. If there are no 640K programs available, the system might load a 250K and a 300K programs, but note that 90K remains unallocated. If there are no 90K or smaller programs available, the space will not be used. This will lead to external fragmentation .
250K Region
Segmentation: Figure d
Programs are divided
Operating Systems Other Programs Program A, segment 0 Other Programs Program A, segment 1 Other Programs Program A, segment 2 Other Programs
into independently addressed segments and stored in noncontiguous memory (Refer Figure d)
Segmentation:
Different segments may and usually do have different
Segmentation:
requires adding a step to the address translation
process. When a program is loaded into memory, the operating system builds a segment table listing the (absolute) entry point address of each of the programs segments (Refer figure e)
Segmentation:
When the operating system starts a given program, it
loads the address of that programs segment table into a special register. As the program runs, addresses must be translated from relative to absolute form because programmers still write the same code and compilers still generate base-plus-displacement addresses.
Segmentation
After fetching an instruction, the instruction control
unit expands each operand address by adding the base register and the displacement. Traditionally, the expanded address was an absolute address.
Segmentation
The expanded address consists of two parts: a segment number a displacement Dynamic Address Translation will convert the
Absolute Address.
The term absolute distinguishes it from a relative
address, which indicates a location by specifying a distance from another location. Absolute addresses are also called real addresses and machine addresses.
Segmentation: Figure e
Base Displacement
Expand
Segment
Displacement
Segment 0
Segment
Start address
Segment 1
0
1 2
Aaa
Bbb Ccc Segment 2
Paging
a program is broken into fixed-length pages
Page size is generally small (perhaps 2K to 4K) Like segments, a programs pages are loaded into
noncontiguous memory.
Paging
Addresses consist of two parts : a page number in the high-order positions a displacement in the low-order bits. Addresses are dynamically translated as the program
runs.
Paging
When an instruction is fetched, its base-plus
displacement addresses are expanded to absolute addresses by hardware. Then the pages base address is looked up in a program page table (like the segment table, maintained by the operating system) and added to the displacement.
Paging: Figure f
Base Displacement
Expand
Page
Displacement
Page 0
Page 0 1 2
Page 1
Page 2
instruction located at a particular virtual address, or fetches data from a specific virtual address or stores data to a particular virtual address, the virtual address must be translated to the corresponding physical address. This is done by a hardware component, sometimes called a memory management unit, which looks up the real address (from the page table) corresponding to a virtual address and passes the real address to the parts of the CPU which execute instructions. If the page tables indicate that the virtual memory page is not currently in real memory, the hardware raises a page fault exception (special internal signal) which invokes the paging supervisor component of the operating system.
2.
3.
checks the special register to find the programs segment table, extracts the segment number from the expanded address, uses the segment number to search the programs segment table,
finds the segments absolute entry point address, and adds the displacement to the entry point address to get an absolute address
Virtual Memory
splits up a program into small modular pieces
a technique that allows the execution of processes that
Virtual Memory
Advantage : the program can be larger than the physical memory. You can run more applications at once. You can run larger applications with less real RAM. Applications may launch faster because of File Mapping. You don't have to buy more memory(RAM).
Virtual Memory
Applications run slower. It takes more time to switch between applications. Less hard drive space for your use. Reduced system stability.
Virtual Memory
It shows three levels of storagevirtual memory, the
external paging device, and real memory. Real memory is good, old-fashioned main memory, directly addressable by the processor.
Virtual Memory
The external paging device is usually disk, model
that simplifies address translation. Virtual memory is a model that simplifies address translation. It contains the operating system and all the application programs, but it does not physically exist anywhere
Virtual Memory
A computer system
technique, which gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage.
Virtual Memory
Consists of 3 main parts : Main memory (RAM) Secondary memory(disk) Page Table
Virtual Memory
Main Memory(RAM)
Store the more recently used pages. Each page is stored into subdivisions of memory
0x00000000 to 0x00000FFF. The second frame will take up address 0x00001000 to 0x00001FFF. Etc. If physical memory is 256 megabytes, the last page would be from 0x0FFFF000 to 0x0FFFFFFF. Notice that the range of addresses covers 4096 bytes.
Virtual Memory
Disk
currently in use. When a page needs to be brought to memory, the appropriate page is found and transferred to main memory. Whenever a page that has been modified during its time in main memory, it is written to disk. Think of the pages on the disk as being in long term storage.
Virtual Memory
Page Table keeps track of where pages are, and what their properties are. The system updates the page table as changes in the state of the system warrant. It makes sense that there are as many entries in the page table as there are pages in our virtual address space. Therefore, in a virtual address space addressed by 32 bits, at 4K per page that's 220 pages, and hence 220 entries in the page table. The first entry in the page table contains information about the first page. The second entry contains information about the second page. Etc. If we have a virtual address with virtual page number 56 (and hence is the 57th page), we can find information about that page in the 57th entry in the page table.