Posted at 10.28.2018
According to Leon, 2007, UNIX can be an operating-system (Operating-system) is software that manages hardware and software sources of a pc. UNIX was first developed in the 1960s and has been frequent development ever since. UNIX is one of the most widely used os's in industry, government and education. It is a stable, multi-user, multi-tasking system for servers, desktops and notebook computers.
Memory can be an important reference in computer. Memory management is the process of managing the computer recollection which contains primary recollection and secondary ram. The target for storage management is to keep an eye on which parts of memory are in use and which parts are not used, to allocate ram to processes when they want it and de-allocate it when they are done. UNIX memory management plan includes swapping and demand paging.
The simplest form of storage management is divorce the main ram into multiple reasonable areas called partition. Each partition can be used for individual program. You can find 2 types of memory space partitioning:-
Single partition allocation only separates the main memory into operating-system and one individual process area. Operating-system will not in a position to have virtual memory using solo partition. Using sole partition is very ineffective since it only allows one process to perform in the memory at onetime.
C:\Users\Eric\Desktop\hssn pic\single partition. jpg
Figure 1. 1: Solitary Partitioning
Most of the operating-system nowadays is using multiple partitions because it is more versatile. Multiple partition allocation empowered multiple programs run in the primary memory simultaneously. Each partition is used for one process.
There are two different forms of multiple partition allocation, which is fixed partitioning and variable partitioning. Fixed partitioning divides memory up into many set partitions which cannot be change. However, varying partitioning is more flexible because the partitions change dynamically in the later as functions come and go. Adjustable partitioning (Varying ram) has been used in UNIX.
C:\Users\Eric\Desktop\hssn pic\fix varying partition. jpg
Figure 1. 2: Fixed Partitioning and Variable Partitioning
Program will be place into recollection during execution. However, a sizable program will split into small portions and loading the items as they needed. Overlays will replace the new pieces with the program which is unused. UNIX is using this technique to run a new program by fork the running process which is also known as fork-exec. The overlays strategy is illustrated below.
C:\Users\Eric\Desktop\hssn pic\overlay. jpg
Figure 1. 3: Overlay Process
Swapping consists of bringing in each process in physical recollection entirely and working it. When the procedure is no longer in use, the procedure will be terminated or is swapped to disk.
The technique of swapping is illustrated in number 1. 3 below.
C:\Users\Eric\Desktop\hssn pic\swapping. jpg
Figure 1. 4: Swapping
Initially only process A is in storage area. Then process B is swapped into storage area from disk. After that, process A terminates or swapped out to drive. Then process C is swapped into the free space.
The size of every process is different, therefore when the operations is been swapped in and out, there will be a multiple holes in the recollection because UNIX is using adjustable partitioning.
C:\Users\Eric\Desktop\hssn pic\holes. jpg
Figure 1. 5: Exterior Fragmentation
There are two techniques to solve this problem, which are storage compaction and fit in the process using algorithms
C:\Users\Eric\Desktop\hssn pic\compaction. jpg
Figure 1. 6: Compaction
Memory compaction steps all the procedures upward as far as possible, so that all the free ram is placed in a single large block. However, it isn't a good notion because it requires a plenty of CPU time.
Most functions will develop as they run, and the techniques data sections can grow, as in many programming dialects, the process will grow. When there is a hole is next to the procedure, it can be allocated and the procedure is allowed to grow into the hole. It is therefore 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, 22 April 2011)
There are three different types of algorithm can be used to loads this program wherever the storage is unused, which is first fit, best fit and worst fit.
The memory director scans across the list and allocates the first space to match the process. First fit is a fast algorithm because it searches as little as possible.
The memory supervisor scans the complete list and calls for the smallest opening that will fit the procedure. Best fit is slower than first fit since it must search the complete list each time it is named.
The memory manager scans the whole list and takes the major available hole, so that the hole destroyed will be big enough to be useful.
UNIX operating system allows user to totally make use of the physical memory space installed in the system as well within the hard disk called swap space which have been designated for use by the kernel while the physical memory is insufficient to take care of the jobs.
Virtual memory managers will generate a exclusive address space in secondary memory (hard disk drive) and it'll determine the part of address space to be filled into physical storage area at any given time. The benefit for virtual memory relies on separation of rational and physical memory.
C:\Users\Eric\Desktop\hssn pic\VR. jpg
Figure 1. 8: Logical Ram and Physical Memory
Paging is a recollection allocation strategy by moving a fixed-sized unit of the electronic address space called digital webpage whenever the webpage is needed to execute a program. As the size of frames and pages are the same, any reasonable page can be placed in any physical shape of storage.
Every processes will be reasonable divided and allocate in the electronic address space. There's a page desk in the virtual recollection to allocate and keep tracking of the pages to map in to the frames.
C:\Users\Eric\Desktop\hssn pic\paging pic. jpg
Figure 1. 9: The relationship between electronic addresses and physical memory addresses is distributed by the site table
UNIX will perform site swapping only once the program requires a certain page. This process is named demand paging. The web page will be paged in to the memory only when it is required to execute. The complete process will never be paged in to the ram, only the web pages needed are swapped in.
Demand paging reduces the paging time and physical storage area needed because only the needed pages will be paged and the reading time of the unused internet pages can be averted.
C:\Users\Eric\Desktop\hssn pic\deand paging. jpg
Figure 1. 10: Demand paging
As the example in the shape, only page 6, 7, 8 and 9 is needed in Process A. Therefore, only webpages 6, 7, 8 and 9 will be paged in to the memory.
A page mistake occurs whenever a program try to use a page that's not in the storage, scheduled to demand paging is only going to paged the webpages into the recollection when it is needed. For instance in physique 1. 9, if this program make an effort to use Web page 1 for Process A in recollection, the operating system will interrupt occurs because of this of trying gain access to a missing webpage because Site 1 is not paged in the memory.
C:\Users\Eric\Desktop\hssn pic\Webpage Problem Handling. jpg
Figure 1. 11: Site Mistake Handling (Retrieved from Slides Materials: Section 17 slides 6)
The diagram above illustrated the steps in handling page fault. When page problem occurs during program execution, the kernel will first find the missing site on the backing store (disk). After located the web page, it'll find a free memory body in the physical ram and copy into it. The page stand will be reset from then on and the instruction will be restart.
When all the casings in the memory space is been used, the other problem will occurs. This may cause the pages struggles to paged into the memory.
Solution for no free structures problem is to find a memory body that is idle and free the body using a web page replacement algorithm. You can find three common types of web page replacement algorithm such as First in First out (FIFO), Optimal and A minimum of Just lately Used (LRU).
UNIX is using least recently used algorithm for page replacement. The least lately used algorithm replaces the page that has not been used for the longest time, on the assumption that the webpage will not be needed again. The page table will record whenever the webpage being referenced, and when page replacement is needed, every site will be checked out to find the oldest saved time.
Every operating system has different memory space management. UNIX also offers their exclusive storage area management ways of manage the ram learning resource optimally. UNIX is using multiple and changing partitioning so that the recollection can be stored and use more adaptable.
UNIX uses overlays and swapping to replace the unused program. However, it is facing exterior fragmentation problem and solve by launching the program into memory space by using best fit algorithm.
Besides, UNIX also fully utilized the digital memory (physical memory and swap space) by using demand paging. It allows consumer to store physical ram in the hard disk because the Memory storage area was always inadequate.
UNIX possesses a (semi-)private memory space called Kernel storage. Kernel uses Memory to keep itself recollection resident to ensure that individual programs do not overwrite or corrupt the kernel /user's data set ups. Strong memory safety is integrated in kernel memory space management to keep users from corrupting the system area.
Figure 1. 12: Kernel memory
Fork is a function used to duplicate a process. The recently created process is called "Child" and the initial process called "Parent".
- Attracting each process in physical storage area entirely and running it.
- Only the needed web pages to execute the program will be swapped in.
- Not using Virtual Memory space.
- Use edge on Virtual Storage area.
- Process size must be equivalent or significantly less than main storage area.
- Process size can be higher than main ram.
- Less flexible in handling recollection.
- More adaptable in handling storage.
Layered Architecture of the UNIX system(Extracted from Basic principles of Computer Technology, 2007 by LEON. A. and LEON. M. )
Initialized Part of Data Segment
Uninitialized Portion of Data Segment
Environment Parameters, etc
The UNIX-style Memory layout(Extracted from Operations Systems by Gary Nutt 1997, Chapter 11: Ram Management)