OS U-IV Memory Management
OS U-IV Memory Management
Science
Operating System
By
Prof. A.A.Salunke
M.Tech. Computer
1. Fixed Partitioning:
Main memory (RAM) is divided into a no. of static partitions at system generation
time.
A process may be loaded into a partition of equal or greater size.
Memory Manager will allocate a region to a process that best fits it
Unused memory within an allocated partition called internal fragmentation
Advantages:
1. Simple to implement
2. Little OS overhead
Fixed Partitioning:
1. Simplest technique which can be used to load more than one processes into
the main memory is Fixed partitioning or Contiguous memory allocation.
Internal Fragmentation
Disadvantages:
1. Inefficient use of Memory due to internal fragmentation.
fact that the block of data loaded is smaller than the partition, is referred to
as internal fragmentation.
Dynamic Partitioning
1. Dynamic partitioning tries to overcome the problems caused by fixed
partitioning.
2. In this technique, the partition size is not declared initially.
3. It is declared at the time of process loading.
4. The first partition is reserved for the operating system.
5. The remaining space is divided into parts.
6. The size of each partition will be equal to the size of the process.
7. The partition size varies according to the need of the process so that the
internal fragmentation can be avoided.
8. The partitions are of variable length and number. When a process is brought
into main memory, it is allocated exactly as much memory as it requires and no
more.
Dynamic Partitioning Problem : External fragmentation
The rule says that the process must be contiguously present in the main memory to get executed
Buddy System
The buddy system is a memory allocation and management
algorithm that manages memory in power of two increments
▪ Else: Recursively divide the block equally and test the condition at
each time, when it satisfies, allocate the block and get out the
loop
▪ System also keep the record of all the unallocated blocks each
and can merge these different size blocks to make one big chunk
Buddy System
Example
Q. Consider a system having buddy system with physical address space 128 KB.
Calculate the size of partition for 18 KB process.
Solution – ▪ S=18 KB required
▪ If 2U-1< S <=2U: Allocate the whole block
▪ Else: Recursively divide the block equally and test the condition at each time, when it
satisfies, allocate t he block and get out the loop
memory size is 27
memory size is 26
memory size is 25
So, size of partition for 18 KB process = 32 KB. It divides by 2, till possible to get minimum block to fit 18
KB.
Buddy System
Advantage –
1. Easy to implement a buddy system
2. Allocates block of correct size
3. It is easy to merge adjacent holes
4. Fast to allocate memory and de-allocating memory
Disadvantage –
1. It requires all allocation unit to be powers of two
2. It leads to internal fragmentation
Relocation
1. Relocation Means Moving Program from One Memory Area to
Another Memory Area
1. Relocation Done by
1) Static Relocation
2) Dynamic Relocation
Two Program Loaded into Physical Memory (RAM) same time
Physical Address
•Physical Address Space (represented in words or bytes): The set of all physical
addresses corresponding to the logical addresses
called pages.
▪ Page number(p): Number of bits required to represent the pages in Logical Address Space
or Page number
▪ Page offset(d): Number of bits required to represent particular word in a page or page
size of Logical Address Space or word number of a page or page offset.
▪ Frame number(f): Number of bits required to represent the frame of Physical Address
Space or Frame number.
But the usage of register for the page table is satisfactory only if page table is small.
2. If page table contain large number of entries then we can use TLB (translation Look-
2. It divides all the processes into the form of pages regardless of the fact that a process can
have some relative parts of functions which need to be loaded in the same page.
3. IN PAGING Operating system doesn't care about the User's view of the process.
4. It may divide the same function into different pages and those pages may or may not be
loaded at the same time into the memory. It decreases the efficiency of the system.
5. It is better to have segmentation which divides the process into the segments.
6. Each segment contains the same type of functions such as the main function can be
included in one segment and the library functions can be included in the other
segment.
Segmentation.
Segmentation is a Memory Management Technique in which the
memory is divided into the variable size parts.
▪ main program
▪ procedure
▪ Function
▪ method
▪ object
▪ local variable
▪ global variables.
▪ symbol table
▪ common block
▪ stack
▪ arrays
With the help of segment map tables and hardware assistance (MMU), the
operating system can easily translate a logical address into physical address on
execution of a program.
Segment Table
It maps two-dimensional Logical address into one-dimensional Physical address.
It’s each table entry has : (Base Address, Limit)
1. Base Address: It contains the starting physical address where the segments
reside in memory.
2. Limit: It specifies the length of the segment.
Logical Address Generated by CPU
2. With the help of segment map tables and hardware assistance(MMU), the operating
system can easily translate a logical address into physical address on execution of a
program.
4. The limit of the respective segment is compared with the offset (d) .
5. If the offset is less than the limit (d< limit) then the address is valid otherwise it throws
6. In the case of valid addresses, the Base address of the segment is added to the offset to
get the physical address of the actual word in the Main memory(RAM).
Advantages of Segmentation
1.No internal fragmentation
3.Less overhead
5.The segment table is of lesser size as compared to the page table in paging.
Disadvantages
1. Every computer system must have at least one operating system to run other
programs. Applications like Browsers, MS Office, Notepad Games, etc., need
some environment to run and perform its tasks.
1. An operating system (OS) is the program that, after being initially loaded into the
computer by a boot program, manages all of the other application programs in a
computer.
1. The application programs make use of the operating system by making requests
for services through a defined application program interface (API).
1. It is not possible for the user to use any computer or mobile device without
having an operating system.
Operating System Software
Operating System Software
Following are some of important functions of an operating System.
1. Memory Management
2. Processor Management
3. Device Management
4. File Management
5. Security
6. Control over system performance
7. Job accounting
8. Error detecting aids
9. Coordination between other software and users
Operating System Software
In an operating system software performs each of the function:
1. I/O System Management: One of the main objects of any OS is to hide the peculiarities of
that hardware devices from the user.
Operating System Software
6. Secondary-Storage Management: Systems have several levels of storage which includes primary
storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or
cache so that a running program can reference it.
7. Security: Security module protects the data and information of a computer system against malware
threat and authorized access.
8. Command interpretation: This module is interpreting commands given by the and acting system
resources to process that commands.
9. Networking: A distributed system is a group of processors which do not share memory, hardware
devices, or a clock. The processors communicate with one another through the network.
10. Job accounting: Keeping track of time & resource used by various job and users.
11. Communication management: Coordination and assignment of compilers, interpreters, and another
software resource of the various users of the computer systems.
Operating System Software
Common desktop operating systems include the following:
•Windows is Microsoft's flagship operating system, the de facto standard for home and business
computers. Introduced in 1985, the GUI-based OS has been released in many versions since then.
The user-friendly Windows 95 was largely responsible for the rapid development of personal
computing.
•Mac OS is the operating system for Apple's Macintosh line of PCs and workstations.
•Unix is a multiuser operating system designed for flexibility and adaptability. Originally developed
in the 1970s, Unix was one of the first operating systems to be written in the C language.
•Linux is a Unix-like operating system that was designed to provide PC users a free or low-cost
alternative. Linux has a reputation as an efficient and fast-performing system.
https://www.studytonight.com/operating-system/memory-management-in-os
https://www.cs.jhu.edu/~yairamir/cs418/os5/sld004.htm