12/7/2019 Memory Management In Unix Operating System Computer Science Essay
/ Essays / Computer Science
Print
Disclaimer: This work has been submitted by a student. This is not an example of the work produced by our Essay Writing Service. You can v
Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the
Introduction to UNIX
According to Leon, 2007, UNIX is an operating system (OS) is software that manages hardware and software resources of a computer. UNIX wa
UNIX is one of the most widely used operating systems in industry, government and education. It is a stable, multi-user, multi-tasking system fo
UNIX Memory Management
Memory is an important resource in computer. Memory management is the process of managing the computer memory which consists of prim
keep track of which parts of memory are in use and which parts are not in use, to allocate memory to processes when they need it and de-alloc
swapping and demand paging.
Memory Partitioning
The simplest form of memory management is splitting up the main memory into multiple logical spaces called partition. Each partition is used f
Single Partition Allocation
Single partition allocation only separates the main memory into operating system and one user process area. Operating system will not able to
ineffective because it only allows one process to run in the memory at one time.
C:UsersEricDesktophssn picsingle partition.jpg
Figure 1.1: Single Partitioning
Multiple Partition Allocation
Most of the operating system nowadays is using multiple partitions because it is more flexible. Multiple partition allocation enabled multiple pr
There are two different forms of multiple partition allocation, which is fixed partitioning and variable partitioning. Fixed partitioning divides me
partitioning is more flexible because the partitions vary dynamically in the later as processes come and go. Variable partitioning (Variable mem
C:UsersEricDesktophssn picfix variable partition.jpg
Figure 1.2: Fixed Partitioning and Variable Partitioning
UNIX Memory Management Strategies
Overlays
Program will be place into memory during execution. However, a large program will divide into small pieces and loading the pieces as they nee
UNIX is using this technique to run a new program by fork the running process which is also known as fork-exec. The overlays technique is illus
C:UsersEricDesktophssn picoverlay.jpg
Figure 1.3: Overlay Process
Swapping
Swapping consists of bringing in each process in physical memory entirely and running it. When the process is no longer in use, the process wi
The procedure of swapping is illustrated in figure 1.3 below.
C:UsersEricDesktophssn picswapping.jpg
Figure 1.4: Swapping
Initially only process A is in memory. Then process B is swapped into memory from disk. After that, process A terminates or swapped out to dis
External Fragmentation Problem
The size of each process is different, therefore when the processes is been swapped in and out, there will be a multiple holes in the memory be
https://www.ukessays.com/essays/computer-science/memory-management-in-unix-operating-system-computer-science-essay.php 1/4
12/7/2019 Memory Management In Unix Operating System Computer Science Essay
C:UsersEricDesktophssn picholes.jpg
Figure 1.5: External Fragmentation
Solution
There are two techniques to solve this problem, which are memory compaction and fit in the process using algorithms
Compaction
C:UsersEricDesktophssn piccompaction.jpg
Figure 1.6: Compaction
Memory compaction moves all the processes upward as far as possible, so that all the free memory is placed in one large block. However, it is n
Most processes will grow as they run, and the processes data segments can grow, as in many programming languages, the process will grow. If
allowed to grow into the hole. Therefore it is good to allocate some extra memory whenever a process is swapped in or out.
Figure 1.7: Allocating Space for Growing Data (Extracted from http://www.cs.rpi.edu/~hollingd/opsys-fall2006/notes/Chapter4/Chapter4.pdf , 2
Algorithms
There are three different types of algorithm can be used to loads the program wherever the memory space is unused, which is first fit, best fit a
Algorithms
Descriptions
First Fit
The memory manager scans along the list and allocates the first space to fit the process. First fit is a fast algorithm because it searches as little a
Best Fit
The memory manager scans the whole list and takes the smallest hole that will fit the process. Best fit is slower than first fit because it must sea
Worst Fit
The memory manager scans the whole list and takes the largest available hole, so that the hole broken will be big enough to be useful.
Virtual Memory
UNIX operating system allows user to fully utilize the physical memory installed in the system as well as part of the hard disk called swap space
insufficient to handle the tasks.
Virtual memory managers will create a virtual address space in secondary memory (hard disk) and it will determine the part of address space to
memory relies on separation of logical and physical memory.
C:UsersEricDesktophssn picVR.jpg
Figure 1.8: Logical Memory and Physical Memory
Demand Paging
Paging is a memory allocation strategy by transferring a fixed-sized unit of the virtual address space called virtual page whenever the page is n
logical page can be placed in any physical frame of memory.
Every processes will be logical divided and allocate in the virtual address space. There is a page table in the virtual memory to allocate and keep
C:UsersEricDesktophssn picpaging pic.jpg
Figure 1.9: The relation between virtual addresses and physical memory addresses is given by the page table
UNIX will perform page swapping only when the program needs a certain page. This procedure is called demand paging. The page will be page
not be paged into the memory, only the pages needed are swapped in.
Demand paging decreases the paging time and physical memory needed because only the needed pages will be paged and the reading time o
C:UsersEricDesktophssn picdeand paging.jpg
Figure 1.10: Demand paging
https://www.ukessays.com/essays/computer-science/memory-management-in-unix-operating-system-computer-science-essay.php 2/4
12/7/2019 Memory Management In Unix Operating System Computer Science Essay
As the example in the figure, only page 6, 7, 8 and 9 is needed in Process A. Therefore, only pages 6, 7, 8 and 9 will be paged into the memory.
Page Fault Problem
A page fault occurs when a program try to use a page that is not in the memory, due to demand paging will only paged the pages into the me
Page 1 for Process A in memory, the operating system will interrupt occurs as a result of trying access a missing page because Page 1 is not pa
Solution for Page Fault
C:UsersEricDesktophssn picPage Fault Handling.jpg
Figure 1.11: Page Fault Handling (Retrieved from Slides Material: Chapter 17 slides 6)
The diagram above illustrated the steps in handling page fault. When page fault occurs during program execution, the kernel will first locate th
free memory frame in the physical memory and copy into it. The page table will be reset after that and the instruction will be restart.
Problem- No Free Frames
When all the frames in the memory is been used, the other problem will occurs. This will cause the pages is unable to paged into the memory.
Solution- Page Replacement Algorithms
Solution for no free frames problem is to find a memory frame that is idle and free the frame using a page replacement algorithm. There are th
(FIFO), Optimal and Least Recently Used (LRU).
UNIX is using least recently used algorithm for page replacement. The least recently used algorithm replaces the page that has not been used f
The page table will record every time the page being referenced, and when page replacement is needed, every page will be checked to find the
Conclusion
Every operating system has different memory management. UNIX also has their exclusive memory management strategies to manage the mem
the memory can be stored and use more flexible.
UNIX uses overlays and swapping to replace the unused program. However, it is facing external fragmentation problem and solve by loading th
Besides, UNIX also fully utilized the virtual memory (physical memory and swap space) by using demand paging. It allows user to store physical
Frequently Ask Question (FAQ)
What is a Kernel Memory?
Kernel Memory
UNIX owns a (semi-)private memory space called Kernel memory. Kernel uses RAM to keep itself memory resident to ensure that user program
protection is implemented in kernel memory management to keep users from corrupting the system area.
C:UsersEricDesktopkernel.jpg
Figure 1.12: Kernel memory
What is fork in UNIX?
Fork is a function used to duplicate a process. The newly created process is called “Child” and the original process called “Parent”.
What is the difference between Swapping and Paging?
Swapping
Paging
– Bringing in each process in physical memory entirely and running it.
– Only the needed pages to execute the program will be swapped in.
– Not using Virtual Memory.
– Use advantage on Virtual Memory.
– Process size must be equal or less than main memory.
https://www.ukessays.com/essays/computer-science/memory-management-in-unix-operating-system-computer-science-essay.php 3/4
12/7/2019 Memory Management In Unix Operating System Computer Science Essay
– Process size can be greater than main memory.
– Less flexible in handling memory.
– More flexible in handling memory.
Limitations
Appendices
Layered Architecture of the UNIX system(Extracted from Fundamentals of Computer Technology, 2007 by LEON.A. and LEON. M.)
Text Segment
Initialized Part of Data Segment
Uninitialized Part of Data Segment
Heap Storage
Stack Segment
Environment Variables, etc
Low Address
High Address
The UNIX-style Memory layout(Extracted from Operations Systems by Gary Nutt 1997, Chapter 11: Memory Management)
/ Essays / Computer Science
https://www.ukessays.com/essays/computer-science/memory-management-in-unix-operating-system-computer-science-essay.php 4/4