Professional Documents
Culture Documents
Resource Management
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 the act of managing computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. The management of main memory is critical to the computer system.
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 Management
The allocation of computer storage in a multiprogramming system so as to maximize processing efficiency. The collection of routines for placing, fetching, and removing pages or segments into or out of the main memory of a computer system.
Memory Management
Memory management systems on multitasking operating systems usually deal with the following issues:
Relocation Protection Sharing Logical organization Physical Organization
Relocation
In systems with virtual memory, programs in memory must be able to reside in different parts of the memory at different times.
The program is swapped back into memory after being swapped out for a while it can not always be placed in the same location.
Memory management in the operating system should therefore be able to relocate programs in memory and handle memory references and addresses in the code of the program so that they always point to the right location in memory.
Protection
Processes should not be able to reference the memory for another process without permission. This is called memory protection, and prevents malicious or malfunctioning code in one program from interfering with the operation of other running programs
Sharing
Even though the memory for different processes is normally protected from each other, different processes sometimes need to be able to share information and therefore access the same part of memory. Shared memory is one of the fastest techniques for Inter-process communication.
Logical organization
Programs are often organized in modules. Some of these modules 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 linear address space. One way to arrange this organization is segmentation.
Physical Organization
Memory is usually divided into fast primary storage and slow secondary storage. Memory management in the operating system handles moving information between these two levels of memory.
Memory Allocation in a PC
Resident Routines
OS is a collection of software routines Resident routines (Rutin Tetap)
The part of a program that must remain in memory at all times. Instructions and data that remain in memory can be accessed instantly. A routine that stays in the memory eg routines that control physical I/O and directly support application programs as they run
In computing, a resident module or resident program stays in memory throughout the lifetime of a computing session.
One such program might be an anti-virus program. This has given rise to the term resident protection.
Transient Routines
Transient routines (Rutin Sementara) A routine that is stored on disk loaded as needed
routines that format disks
Transient Area
Partition 4
700K
Partition 3
Partition 2
400K
200K 100K
0K
Partition 4
700K
Partition 3
200K 100K
0K
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 into independently addressed segments and stored in noncontiguous memory (Refer Figure d)
Operating Systems Other Programs Program A, segment 0 Other Programs Program A, segment 1 Other Programs Program A, segment 2 Other Programs
Segmentation:
Different segments may and usually do have different lengths Segments length may changed during execution
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-plusdisplacement 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 segment/displacement address to an absolute address.
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.
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
Virtual Memory
splits up a program into small modular pieces a technique that allows the execution of processes that may not be completely in memory.
ie, the process can start executing with only part of the process image in the memory.
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 called "frames." A frame size is the same as page size.
If we have a 4096 byte page size, then each frame will hold 4096 bytes to accommodate the pages.
The first frame will take up actual addresses 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
The disk memory is a repository for pages not 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.