Wednesday, April 11, 2012

Operating Systems Day 03

Every Operating System has sub-system components.
  1. Memory Manager
  2. Process Manager
  3. Device Manager
  4. File Manager
  5. User Command Interface
  6. Network Manager
The roles of Memory Manager are
  1. Receives requests for memory storage from other services. 
  2. Checks validity of each request and manages allocation and release of RAM. 
  3. Protects allocated RAM from corruption.
Memory Manager employs four types of memory allocation schemes as follows.
  1. single-user systems
  2. fixed partitions
  3. dynamic partitions
  4. Relocatable dynamic partitions.
The roles of Process Manager are
  1. A program being executed is called a process.
  2. It allocates some RAM for the program
  3. The process manager allocates the CPU to each process using a Scheduler
Device Manager: monitors every device and control unit so that it can most effectively manage the device


File Manager: keeps track of every file in the system. It enforces access control policies and optimises access to improve overall performance.


User Command Interface: provides a standard set of interfaces for use by applications and an operational environment for users:
  1.  command.com
  2.  Unix Shell
  3.  Graphical user interface (GUI)
Network Manager: More advanced systems will also provide network management services


The cooperation of the above sub-components is as follows.
When a user executes a command:
  1. User Interface Manager: accepts a request from the user to run a program
  2. User Interface Manager:
    1. Identifies the required program
    2. Invokes the Process Manager to run it
  3. Process Manager
    1.  Loads the program via the File Manager into the memory allocated by the Memory Manager
  4. As the program runs it may use the File Manager and Device Manager to display output and read/write data
  5. When the program is complete, the Processor Manager signals all the other service managers to release their resources.
The amount of memory that can be addressed (used) is determined by the size of the address register.


Instructions consist of:
  1. an Operation Code (OpCode)
    1. e.g. MOV  bx  ax,    INC  cx,  HLT
    2. what action you want to do
  2. Zero of more operands
    1. what items you want perform the action on
Multiprogramming systems divide the memory into PARTITIONS so that several independent programs can be in memory at the same time.



Programs that don’t fill a partition will waste the unused space. This was common in early computer operating systems.


Dynamic partitions allocate memory on the basis of program size.


Different algorithms exist for selecting jobs:

Memory consists of “holes” (ie. unused space). Therefore, we need a method to keep track of hole sizes and locations


Policies
  1. First fitfind the first hole that is big enough
    1. Maintain hole list in ascending order of memory address
  2. Best fitfind the smallest hole that is big enough
    1. Maintain hole list in ascending order of hole size.
  3. Worst fitfind the largest hole that is big enough
    1. Maintain hole list in descending order of hole size.
Fragmentation of memory is the breaking up of memory into multiple “chunks”.  



There are two type of fragmentation of memory.
Internal Fragmentation (fixed or static partitions)
  1. Partition is larger than job needs
  2. Excess unused memory fragment cannot be used for anything else
Internal fragmentation: a situation in which a fixed partition is only partially used by the program; the remaining space within the partition is unavailable to any other job and is therefore wasted.

External Fragmentation (dynamic partitions)
  1. As memory is allocated, it leaves many small holes
  2. Memory holes are non-contiguous
  3. Sufficient memory may be available but it cannot be used.
External fragmentation: a situation in which the dynamic allocation of memory creates unusable fragments of free memory between blocks of busy, or allocated, memory.

Relocation register: a register that contains the value that must be added to each address referenced in the program so that it will be able to access the correct memory addresses after relocation.

We first need to make sure that each process has a separate memory space.

The BASE register holds the smallest legal physical memory address; the LIMIT register specifies the size of the range.

Main memory and registers are only storage CPU can access directly.


Cache sits between main memory and CPU registers.

A pair of base and limit registers define the logical address space.

Logical address–generated by the CPU; also referred to as virtual address.

The user program deals with logical addresses; it never sees the real physical addresses.

Physical memory address = logical address + relocation register

Relocation registers used to protect user processes from each other, and from changing operating-system code and data.

Limit register contains range of logical addresses–each logical address must be less than the limit register.



PAGING: A technique for memory organisation
  1. previous techniques required contiguous blocks of memory
  2. PAGING allows program to use non-contiguous memory
    1. no longer needs a single contiguous area of RAM
To use paging, the memory manager:
  1. Breaks physical memory into Frames
  2. Breaks logical memory into Pages of same size
    1. Use a Page Table to link Pages to Frames
Each process has its own page table.
Instead of loading all of program into memory frames, only load pages needed for execution.
Most programs only use a small area of code at any one time, so the number of frames used is often a lot less than the total size of the program.


Related to the idea of Virtual Memory, using disk space as an extension of memory.


Paging and the Page Table




Address translation



Thrashing: the system spends all the time swapping pages in and out of memory. It happens when a page fault causes a frame to be replaced, which must then be reloaded again straight away.








Memory management checks that computed physical address does not exceed the size of the partition.


little-endian format


References

  1. McHoes, A., & Flynn, I.M. (2008). Understanding operating systems (5th ed.). CENGAGE Learning.
  2. Melbourne Institute of Technology (Semester 1, 2012). BN104 Operating Systems Lecture Notes.

No comments:

Post a Comment

Mounting USB drives in Windows Subsystem for Linux

Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...