Skip to main content

3.1.1 Identify Between Resident And Transient Routines

Memory Management

  • Memory management is concerned with managing:
  • The computer’s available pool of memory
  • Allocating space to application routines and making sure that they do not interfere with each other.

3.1.1 Identify between resident and transient routines

  • The operating system is a collection of software routines.



Resident routines
Transient routines
Routines that directly
support application
programs as they run
Stored on disk and read
into memory only when
needed
Example: routine that control physical I/O
Example: routine that formats disks

  • The operating system occupies low memory beginning with address 0. Key control information comes first followed by the various resident operating system routines.
  • The remaining memory, called the transient area, is where application programs and transient operating system routines are loaded.
Resident & transient routines structure

3.1.2 Explain the following related to memory management terminologies

a. Fixed – partition memory management

  • The simplest approach to managing memory for multiple, concurrent programs.
On many systems, multiple programs are loaded into memory and executed concurrently


  • Divides the available space into fixed-length partitions, each of which holds one program.
  • Partition sizes are generally set when the system is initially started, so the memory allocation decision is made before the actual amount of space needed by a given program is known


Fixed-partition memory management structure diagram
  • Fixed-partition memory management divides the available space into fixed length partitions each of which holds one program. 

Advantages
Disadvantages
-Its major advantage is simplicity
- Because the size of a partition must be big enough to hold the largest program that is likely to be loaded
-Fixed-partition memory management wastes space
 
b. Dynamic memory management


  • The transient area is treated as a pool of unstructured free space.
  • The system decides to load a particular program, a region of memory just sufficient to hold the program is allocated from the pool.


Advantages:
- Because a program gets only the space it needs relatively little is wasted.



  • Dynamic memory management does not completely solve the wasted space problem.
  • Fragmentation (bits of unused space spread throughout memory) is a possible problem


3 algorithm for searching free block for a specific amount of memory:

  1. First fit
  • Allocate the first free block that is large enough for the new process.
    This a fast algorithm.
      2. Best fit
  • Allocate the smallest block among those that are large enough for the new process.
  • OS search entire list, or it can keep it sorted and stop it when it has an entry which has a size larger than the size of process.
  • This algorithm produces the smallest left over block.
      3. Worst fit
  • Allocate the largest block among those that are large enough for the new process.
  • Search or sorting of the entire list is needed.
  • This algorithm produces the largest  left over block.

Compaction:

  • Method to overcome the external fragmentation problem.
  • All free blocks are brought together as one large block of free space.
  • For example, that a 640K program has just finished executing.If there are no 640K programs available, the system might load a 250K program and a 300K program, but note that 90K remains unallocated.If there are no 90K or smaller programs available, the space will simply not be used. The little chunks of unused space will be spread throughout memory, creating a fragmentation problem. 



c. Segmentation



  • With segmentation, programs are divided into variable size segments, instead of fixed size pages.
  • Every logical address is formed of a segment name and an offset within that segment.
  • Segments are numbered. Programs are segmented automatically by compiler or assembler.

  • For logical to physical address mapping, a segment table is used. When a logical address <s, d> is generated by processor:


  • Base and limit values corresponding to segment s are determined using the segment table. The OS checks whether d is in the limit. ( 0=<limit), then the physical address is calculated as ( based + d), and the memory is accessed. 

d. Paging


  • A programs segments can vary in length. Under paging, a program is broken into fixed-length pages. Page size is generally small (perhaps 2K to 4K), and chosen with hardware efficiency in mind.
  • Like segments, a program’s pages are loaded into noncontiguous memory.
  • Addresses consist of two parts , a page number in the high-order positions and a displacement in the low-order bits.
  • Addresses are dynamically translated as the program runs. When an instruction is fetched, its base-plus displacement addresses are expanded to absolute addresses by hardware.
  • Then the page’s base address is looked up in a program page table (like the segment table, maintained by the operating system) and added to the displacement.  

Advantages:
Address translation: each task has the same virtual address
Address translation: turns fragmented physical addresses into contiguous virtual addresses
Memory protection (buggy or malicious tasks can't harm each other or the kernel)
Demand loading (prevents big load on CPU when a task first starts running, conserves memory)
Memory mapped files. Virtual memory swapping (lets system degrade gracefully when memory required exceeds RAM size)

Segmentation and Paging

Process of segmentation and paging

  • With segmentation and paging, addresses are divided into a segment number, a page number within that segment, and a displacement within that page.
  • After the instruction control unit expands the relative address, dynamic address translation begins.
  • First, the program’s segment table is searched for the segment number, which yields the address of the segment’s page table. 
  • The page table is then searched for the page’s base address, which is added to the displacement to get an absolute address.

3.2 Understand Virtual Memory Management 

  • The word virtual means “not in actual fact.” To the programmer or user, virtual memory acts just like real memory, but it isn’t real memory.
  • Virtual memory is a model that holds space for the operating system and several application programs.
  • The operating system and selected pages occupy real memory. Application programs are stored on an external paging device. 


Virtual memory structure
  • Virtual memory is a model that simplifies address translation. It “contains” the operating system and all the application programs, but it does not physically exist anywhere. Its contents are physically stored in real memory and on the external paging device.
  • Divided into two components.
       - First components
  • The first is exactly equal to the amount of real memory on the system and is physically stored in real memory.
  • It contains the resident operating system and the transient program area (called the page pool).
      - Second components
  • The second component of virtual memory consists of space over and above real memory capacity.
  • It is physically stored on the external paging device and contains the application programs. The operating system is loaded into real memory.
  • Application programs are loaded onto the external paging device. Selected pages are then swapped between the real memory page pool and the external paging device.

3.2.1 Explain a Model of Virtual Memory

a. Demand Paging
  • In virtual memory systems, demand paging is a type of swapping in which pages of data are not copied from disk to RAM until they are needed.
b. Swapping
  • When the physical memory in the system runs out and a process needs to bring a page into memory then the operating system must decide what to do. 
  • Share the physical pages in the system between the processes running in the system, therefore it may need to remove one or more pages from the system to make room for the new page to be brought into memory. How virtual pages are selected for removal from physical memory affects the efficiency of the system.
c. Shared Virtual Memory
  • When programs are written, programmers take great care to make sure that code is not needlessly repeated. 
  • Subroutines to handle particular functions are written and used wherever possible. Subroutines that are useful to many programs are gathered together into libraries. 
  • These libraries are shareable so that running programs do not load several copies of the same code into memory. Instead only one copy of the code is loaded and all of the programs share that copy.
    Virtual memory makes it easy for processes to share memory as all memory accesses are decoded using page tables. 
  • For processes to share the same virtual memory, the same physical pages are referenced by many processes. 
  • The page tables for each process contain the Page Table Entries that have the same physical PFN.
Sharing Physical Memory Between Processes
  • Figure gif shows two processes that each have physical PFN 1 in their virtual memory map. 

3.2.2 Describe Paged Virtual Memory

a. Page Tables
  • A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses. 
  • Virtual addresses are used by the accessing process, while physical addresses are used by the hardware or more specifically to the RAM.
b. Dynamic Address Translation
  • Dynamic address translation, or DAT, is the process of translating a virtual address during a storage reference into the corresponding real address.
c. Paging Supervisor
  • In a VS operating system, all non-resident programs exist in complete form only on auxiliary storage, which is where the OS loads them first. and the total virtual storage size of all executing programs usually exceeds the size of the real storage of the computer.
  • In OS/390, both virtual and real storage are divided into 4096-byte chunks. The chunks are called pages on auxiliary storage, and page frames in real RAM. 
  • Paging is the name of the mechanism used to maintain the contents of real memory:
  • When a program is first loaded, it is copied into contiguous virtual storage pages on auxiliary storage, not into real storage page frames in RAM.
  • From that initial DASD storage location, a page is copied as needed into a real storage page frame by the OS/390 Paging Supervisor. 
Page Frame Table
  • The Page Frame Table contains lists, AKA "queues", of non-empty page frames. The actual number of the Active Queues is determined by the systems programmers and operators responsible for generating and running the system efficiently.

Comments

Post a Comment

Popular posts from this blog

Operating Systems Definition and the Classification of OS

             OPERATING SYSTEMS ( OS ) What is an operating system? An operating system (sometimes abbreviated as "OS") is the program that, after being initially loaded into the computer by a boot program, manages all the other programs in a computer. The other programs are called applications or application programs. The application programs make use of the operating system by making requests for services through a defined application program interface (API). In addition, users can interact directly with the operating system through a user interface such as a command language or a graphical user interface (GUI). An operating system performs these services for applications:     In a multitasking operating system where multiple programs can be running at the same time, the operating system determines which applications should run in what order and how much time should be allowed for each application before giving another application a turn.     It manages the sharing of

2.1.4 Distinguish between logical I/O and physical I/O

2.1.4 Distinguish between logical I/O and physical I/O logical input relate to hard disk Logical I/O an Physical I/O Physical" I/O is an actual fetch of data from a storage device such as a disk. Logical" I/O is a programmatic request for data satisfied by a memory (block, buffer) access. A logical I/O may cause a physical I/O in the first place, or a logical I/O may retrieve a part of a block (buffer) of data from memory. 2.1.5 Distinguish between directory management and disk space management. Directory management A directory is a hierarchical collection of directories and files.  The only constraint on the number of files that can be contained in a single directory is the physical size of the disk on which the directory is located. Disk management A hard disk is a rigid disk inside a computer that stores and provides relatively quick access to large amounts of data. It is the type of storage most often used with Windows. The system also supp