os202

Logo

OS202 - johanessteven19 - Updated Weekly throughout the semester!

View the Project on GitHub johanessteven19/os202

Back to Home


Top 10 List of Week 05

  1. Virtual Memory.
    Virtual Memories are different from physical memory in that the former will abstract the latter into an extremely large uniform array of storage. Virtual Memories allow the user to make space for programs that might be bigger than the physical memory. This is done by utilizing both hardware and software of the computer to compensate for the shortage of physical memory by allowing temporary data transfer from the RAM into the disk storage. Virtual Memories are physically located on the hard drive or other external storage devices.

  2. Usage of Virtual Memories.
    By using Virtual Memories, the user is able to:
    • Allow programs to store only parts of a program in the memory.
    • Allow processes to share memory.
    • Allow processes to be created more efficiently by letting multiple larger programs to run at the same time.
    • Improving system performance, multitaksing, using large programs, and flexibility.
    • Memory allocation is generally cheaper.
    • Virtual Memories cost less than Physical Memory.
  3. How Virtual Memories work.
    Usually, a program will access data of the program being run in the RAM, where they are stored. This allows the data to be accessed quickly by the computer. Due to RAM size limitations, however, there sometimes is a need for more space to run programs. This problem can be solved by transferring some of the data stored in the RAM that is not currently being used by programs into a Virtual Memory. If the transferred data is suddenly needed by another program, the data can be swapped from the disk back into the RAM to be quickly accessed. This swapping process means that only data needed by the currently running program is stored in the RAM, therefore freeing up space for other running programs.

  4. Virtual Memory vs. Physical Memory.
    • The RAM (Physical Memory) is much faster than the Virtual Memory. Therefore, the Virtual Memory is usually used as a last resort when the RAM is filled.
    • RAM is much more expensive to purchase than Virtual Memory.
    • RAM size depends on the RAM chips and the programs installed on the computer, while the size of Virtual Memory depends on the computer’s hard drive.
  5. Demand Paging.
    Demand Paging is a technique commonly used for Virtual Memory managing. It involves the aforementioned swapping process between the RAM and the Virtual Memory. In demand paging, every data stored in the disk is not immediately copied into the RAM, but it waits until the ‘demand’ from a program is produced. If a duplicate data already exists, then it will not be copied. Therefore, only the needed data is being swapped from the Virtual Memory into the RAM to be used. This is in contrast of pure swapping, where every data needed for a process is swapped during its startup.

  6. Page-replacement Algorithm.
    When page fault (a running program accessing a memory page that is already mapped into the virtual address space, but has not been loaded into the RAM. This error will happen since the RAM is much, much smaller than the Virtual Memory. When this happens, the OS has to deal with it by replacing an existing page with the page being demanded by the running program. This is done by using the Page-replacement Algorithm, which have several types:
    • First In First Out (FIFO), the oldest page used will be replaced by the new page.
    • Optimal Page Replacement, the page that will not be used for the longest duration of time in the future will be replaced.
    • Least Recently Used, the page that is least recently used will be replaced.
      There also exists Global Page-replacement Algorithms, where a random page from any process in the system is selected to be replaced. The opposite is the Local Page-replacement algorithm, where only a page from the faulting process is selected to be replaced.
  7. Thrashing.
    Thrashing is a process that will occur when the computer’s Virtual Memory is stuck in a constant state of paging or when it spends more time paging rather than executing. When this happens, the performance of the computer will obviously be reduced until the underlying issue is addressed. This error might occur because there are programs that present insufficient locality (a set of pages actively used together). Since the program has to constantly shift from locality to locality during execution, an insufficient locality will cause the process to be stuck in a constant data swapping process.

  8. Resolving thrashing.
    • Permanently increasing the amount of RAM accessible to the computer.
    • Closing some heavy-load programs to clear up some RAM space.
    • Replacing heavy-load programs with their lighter-load equivalent.
    • Improving spatial locality.
  9. Kernel memory.
    Kernel memory is a specially reserved part of the OS that is off-limits to the other programs. This memory is only allocated when an ordinary process requests additional memory to run. There are two main strategies in managing this free memory, which are:
    • Buddy System, where memory is allocated from a fixed-size segment consisting of physically contiguous pages.
    • Slab Allocation, where a slab (one or more physically contiguous pages) is created and put into a cache (consisting of one or more slabs). These caches will be used to store kernel objects and will then be allocated appropriately.
  10. Disadvantages of Virtual Memory.
    Although Virtual Memory seems very efficient and should be used as much as possible, there are some disadvantages to using them, such as:
    • Offering a lower performance compared to the RAM.
    • May have a negative effect to the performance of the whole system.
    • Will take up storage space that could have been used for data storage.
    • More likely to take more time to switch between applications.