os202

OS202

View on GitHub

HOME


Top 10 List of Week 04

  1. Hardware Address Protection
    Harware Address Protection
    The hardware implements the protection by having separate memory space. This is implemented by using a base register and a limit register for each process. Every memory access made by the user is checked againts these registers. This can prevents the user program from modifying the code of either the OS or other users.

  2. Address Binding
    Address Binding
    Address binding is the process of mapping from one address space to another address space. It can be done in several stages:
    • Compile Time
      If it is known at compile time where a program will reside in physical memory, then absolute code can be generated by the compiler, containing actual physical addresses. However if the load address changes at some later time, then the program will have to be recompiled. DOS .COM programs use compile time binding.
    • Load Time
      If the location at which a program will be loaded is not known at compile time, then the compiler must generate relocatable code, which references addresses relative to the start of the program. If that starting address changes, then the program must be reloaded but not recompiled.
    • Execution Time
      If a program can be moved around in memory during the course of its execution, then binding must be delayed until execution time. This requires special hardware, and is the method implemented by most modern OSes.
  3. Logical vs Physical Address Space
    • The address generated by the CPU is a logical address, whereas the address actually seen by the memory hardware is a physical address.
    • The set of all logical addresses used by a program composes the logical address space, and the set of all corresponding physical addresses composes the physical address space.
    • The logical address does not exist physically in the memory whereas physical address is a location in the memory that can be accessed physically.
    • Identical logical and physical addresses are generated by Compile-time and Load time address binding schemes, whereas they differs from each other in execution-time address binding scheme.
    • The logical address is generated by the CPU while the program is running whereas the physical address is computed by the Memory Management Unit (MMU).
  4. Dynamic & Static Linking
    Static Linking:
    • In static linking, the necessary library functions are embedded directly in the programs executable binary file.
    • Use more disk space and memory usage.
      Dynamic Linking:
    • System libraries re linked to user programs when the programs are run.
    • Can be shared among multiple processes.
    • Save more memory space, because the library routines do not need to be fully included in the executable modules, only the stubs.
  5. Memory Allocation
    Memory allocation is a process by which computer programs are assigned memory or space. There are three commonly used approach:
    • First Fit: In the first fit, the partition is allocated which is first sufficient block from the top of Main Memory. It scans memory from beginning and chooses the first available block that is large enough . Thus it allocate the first hole that is large enough.
    • Best Fit: Allocate the process to the partition which is the first smallest sufficient partition among the free available partition. It search the entire list of holes to find the smallest hole whose size is greater than or equal to size of process.
    • Worst Fit: Allocate the process to the partition which is the largest sufficient among the freely available partitions available in the main memory. It is opposite to the best fit algorithm. It search the entire list of hole to find the largest hole and allocate it to process.
  6. Fragmentation
    Fragmentation occurs in a dynamic memory allocation system when most of the free blocks are too small to satisfy any request. It is generally termed as inability to use the available memory. Fragmentation is of two types:
    • External fragmentation
      Total memory space is enough to satisfy a request or to reside a process in it, but it is not contiguous, so it cannot be used.
    • Internal fragmentation
      Memory block assigned to process is bigger. Some portion of memory is left unused, as it cannot be used by another process.
  7. Paging
    Paging is a memory management technique in which process address space is broken into blocks of the same size called pages size is power of 2, between 512 bytes and 8192 bytes). The size of the process is measured in the number of pages. Similarly, main memory is divided into small fixed-sized blocks of (physical) memory called frames and the size of a frame is kept the same as that of a page to have optimum utilization of the main memory and to avoid external fragmentation.
    Here is the link for a fun explanation of paging. Paging Game

  8. Page Table Entries
    Page table has page table entries where each page table entry stores a frame number and optional status bits. The most important thing in PTE is frame Number.
    • Frame Number
      It gives the frame number in which the current page we are looking for is present. The number of bits required depends on the number of frames.Frame bit is also known as address translation bit.
    • Present/Absent bit
      Present or absent bit says whether a particular page we are looking for is present or absent. In case if it is not present, that is called Page Fault. It is set to 0 if the corresponding page is not in memory. Used to control page fault by the operating system to support virtual memory. Sometimes this bit is also known as valid/invalid bits.
    • Protection bit
      Protection bit says that what kind of protection we want on that page. So, these bit for the protection of the page frame (read, write etc).
    • Referenced bit
      Referenced bit will say whether this page has been referred in the last clock cycle or not. It is set to 1 by hardware when the page is accessed.
    • Caching enabled/disabled
      This bit enables or disable caching of the page.
    • Modified bit
      Modified bit says whether the page has been modified or not. Sometimes this modified bit is also called as the Dirty bit.
  9. Swapping
    Swapping is a memory management scheme in which any process can be temporarily swapped from main memory to secondary memory so that the main memory can be made available for other processes. It is used to improve main memory utilization. In secondary memory, the place where the swapped-out process is stored is called swap space.

  10. Hierarchical Paging
    Hierarchical Paging AKA Multilevel Paging is a paging scheme which consist of two or more levels of page tables in a hierarchical manner. The entries of the level 1 page table are pointers to a level 2 page table and entries of the level 2 page tables are pointers to a level 3 page table and so on. The entries of the last level page table are stores actual frame information. Level 1 contain single page table and address of that table is stored in PTBR (Page Table Base Register). In multilevel paging whatever may be levels of paging all the page tables will be stored in main memory. So it requires more than one memory access to get the physical address of page frame. One access for each level needed. Each page table entry except the last level page table entry contains base address of the next level page table.