- Memory Manager
- Process Manager
- Device Manager
- File Manager
- User Command Interface
- Network Manager
- Receives requests for memory storage from other services.
- Checks validity of each request and manages allocation and release of RAM.
- Protects allocated RAM from corruption.
- single-user systems
- fixed partitions
- dynamic partitions
- Relocatable dynamic partitions.
- A program being executed is called a process.
- It allocates some RAM for the program
- The process manager allocates the CPU to each process using a Scheduler
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:
- command.com
- Unix Shell
- Graphical user interface (GUI)
The cooperation of the above sub-components is as follows.
When a user executes a command:
- User Interface Manager: accepts a request from the user to run a program
- User Interface Manager:
- Identifies the required program
- Invokes the Process Manager to run it
- Process Manager
- Loads the program via the File Manager into the memory allocated by the Memory Manager
- As the program runs it may use the File Manager and Device Manager to display output and read/write data
- When the program is complete, the Processor Manager signals all the other service managers to release their resources.
Instructions consist of:
- an Operation Code (OpCode)
- e.g. MOV bx ax, INC cx, HLT
- what action you want to do
- Zero of more operands
- what items you want perform the action on
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
- First fit: find the first hole that is big enough
- Maintain hole list in ascending order of memory address
- Best fit: find the smallest hole that is big enough
- Maintain hole list in ascending order of hole size.
- Worst fit: find the largest hole that is big enough
- Maintain hole list in descending order of hole size.
There are two type of fragmentation of memory.
Internal Fragmentation (fixed or static partitions)
- Partition is larger than job needs
- 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.
- As memory is allocated, it leaves many small holes
- Memory holes are non-contiguous
- 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
- previous techniques required contiguous blocks of memory
- PAGING allows program to use non-contiguous memory
- no longer needs a single contiguous area of RAM
- Breaks physical memory into Frames
- Breaks logical memory into Pages of same size
- Use a Page Table to link Pages to Frames
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
- McHoes, A., & Flynn, I.M. (2008). Understanding operating systems (5th ed.). CENGAGE Learning.
- Melbourne Institute of Technology (Semester 1, 2012). BN104 Operating Systems Lecture Notes.
No comments:
Post a Comment