⏪Previous Next⏩
Computer memory can be defined as a collection of some data represented in the binary format. On the basis of various functions, memory can be classified into various categories.
Main memory is also known as RAM. The computer is able to change only data that is in main memory. Therefore, every program we execute and every file we access must be copied from a storage device into main memory.
All the programs are loaded in the main memeory for execution. Sometimes complete program is loaded into the memory, but some times a certain part or routine of the program is loaded into the main memory only when it is called by the program, this mechanism is called Dynamic Loading, this enhance the performance.
Requirements of Memory Management System :
These Requirements of memory management are:
- Relocation – The available memory is generally shared among a number of processes in a multiprogramming system, so it is not possible to know in advance which other programs will be resident in main memory at the time of execution of his program. Swapping the active processes in and out of the main memory enables the operating system to have a larger pool of ready-to-execute process.
When a program gets swapped out to a disk memory, then it is not always possible that when it is swapped back into main memory then it occupies the previous memory location, since the location may still be occupied by another process. We may need to relocate the process to a different area of memory. Thus there is a possibility that program may be moved in main memory due to swapping. - Protection – There is always a danger when we have multiple programs at the same time as one program may write to the address space of another program. So every process must be protected against unwanted interference when other process tries to write in a process whether accidental or incidental. Between relocation and protection requirement a trade-off occurs as the satisfaction of relocation requirement increases the difficulty of satisfying the protection requirement.
Prediction of the location of a program in main memory is not possible, that’s why it is impossible to check the absolute address at compile time to assure protection. Most of the programming language allows the dynamic calculation of address at run time. The memory protection requirement must be satisfied by the processor rather than the operating system because the operating system can hardly control a process when it occupies the processor. Thus it is possible to check the validity of memory references. - Sharing – A protection mechanism must have to allow several processes to access the same portion of main memory. Allowing each processes access to the same copy of the program rather than have their own separate copy has an advantage.
For example, multiple processes may use the same system file and it is natural to load one copy of the file in main memory and let it shared by those processes. It is the task of Memory management to allow controlled access to the shared areas of memory without compromising the protection. Mechanisms are used to support relocation supported sharing capabilities. - Logical organization – Main memory is organized as linear or it can be a one-dimensional address space which consists of a sequence of bytes or words. Most of the programs can be organized into modules, some of those are unmodifiable (read-only, execute only) and some of those contain data that can be modified. To effectively deal with a user program, the operating system and computer hardware must support a basic module to provide the required protection and sharing. It has the following advantages:
- Modules are written and compiled independently and all the references from one module to another module are resolved by `the system at run time.
- Different modules are provided with different degrees of protection.
- There are mechanisms by which modules can be shared among processes. Sharing can be provided on a module level that lets the user specify the sharing that is desired.
- Physical organization – The structure of computer memory has two levels referred to as main memory and secondary memory. Main memory is relatively very fast and costly as compared to the secondary memory. Main memory is volatile. Thus secondary memory is provided for storage of data on a long-term basis while the main memory holds currently used programs. The major system concern between main memory and secondary memory is the flow of information and it is impractical for programmers to understand this for two reasons:
- The programmer may engage in a practice known as overlaying when the main memory available for a program and its data may be insufficient. It allows different modules to be assigned to the same region of memory. One disadvantage is that it is time-consuming for the programmer.
- In a multiprogramming environment, the programmer does not know how much space will be available at the time of coding and where that space will be located inside the memory.
Need for Multi programming :
However, The CPU can directly access the main memory, Registers and cache of the system. The program always executes in main memory. The size of main memory affects degree of Multi programming to most of the extant. If the size of the main memory is larger than CPU can load more processes in the main memory at the same time and therefore will increase degree of Multi programming as well as CPU utilization.
Process Size = 4 MB
Main memory size = 4 MB
The process can only reside in the main memory at any time.
If the time for which the process does IO is P,
Then,
CPU utilization = (1-P)
let's say,
P = 70%
CPU utilization = 30 %
Now, increase the memory size, Let's say it is 8 MB.
Process Size = 4 MB
Two processes can reside in the main memory at the same time.
Let's say the time for which, one process does its IO is P,
Then
CPU utilization = (1-P^2)
let's say ,
P = 70 %
CPU utilization = (1-0.49) =0.51 = 51 %
Logical Versus Physical Address
Space
CPU utilization = (1-0.49) =0.51 = 51 %
Therefore, we can state that the CPU utilization will be increased if the memory size gets increased.
Logical Versus Physical Address
Space
·
The concept of a logical address
space that is bound to a separate
physicaladdress space is central to proper memory management.
Logical address – address generated by the CPU; also referred
to as virtual address.
Physical address – address seen by the memory unit.
· The set of all logical addresses generated by a program is a logical
address space; the set of all
physical addresses corresponding to these logical
addresses are a physical address
space.
· Logical and physical addresses are the same
in compile-time and load-time address-binding schemes; logical
(virtual) and physical addresses differ in execution-time address-binding scheme.
· The run-time mapping from virtual to physical addresses
is done by a hardware
device called the memory management unit (MMU).
· This method requires hardware
support slightly different from the hardware
configuration. The base register
is now called a relocation register. The value
in the relocation register is added to every address generated by a user
process at the time it is sent to memory.
· The user program never sees the
real physical addresses. The program can create a pointer to location 346,
store it in memory, manipulate it and compare it to other addresses. The user
program deals with logical addresses. The memory mapping
hardware converts logical
addresses into physical addresses. The final location of a referenced
memory address is not determined until the reference is made.
- What is an Operating System ?
- Discuss the structure off OS ?
- Explain type of OS?
- Explain Function of OS?
- Explain OS Services ?
- What do mean by system call ?List different type ofsystem call available ?
- what is process ? and Characteristics ?
- What is different process state? explain the same in details?
- write short note on user level and kernal level threads?
- explain what is thread and its type ?
- explain scheduler ? (short term,medium term,and long term)
- state and explain scheduling criteria ?
- Explain scheduling algorithm ? [ FCFS,SJF,PRIORITY,ROUND ROBINE.]
- What is process synchronization ? explain critical section problem and race condition ?
- what is Race Condition ?
- what is critical section problem?
- explain classical problem of synchronization?
- explain bounded - buffer problem?
- explain reader - writer problem ?
- explain Dining Philosophers Problem ?
- explain semaphores ? its type ?
- What is deadlock ?
- What are the 4 condition to produce deadlock ?
- explain methods of handling deadlock ?
- explain in detail deadlock prevention ?
- write short note on deadlock avoidance ?
- explain deadlock detection ?
- explain Banker algorithm with example ?
- What are memory management ?
- what is contiguous memory allocation and non - contiguous memory allocation ?
- explain concept of paging with neat diagram?
- differentiate contiguous and non - contiguous memory allocation ?
- explain in details various partitioning memory management?
- explain the concept of Segmentation ?
- what is Thrashing explain in details ?
0 Comments