One major problem in multiprogramming is preventing one program from affecting the data and program in the memory space of other users. Some methods to prevent it is:
1) Fence:
- We confine users to inside of the memory and system memory to another side. Each group cannot come to their opposite memory area.
2) Relocation
- Programs are written as if starting from location 0 in the memory.
- But in reality its stored at location n determined by OS.
- Before a user instruction is executed, a relocation factor (i.e. n)is added to it.
3) Base/bounds register
- A program is forced to above a base register & is always checked to be below bounds register.
- Base register A variable fence that determines the lower limit for program address
- Bounds registerdefines the upper limit for program instruction.
4) Segmentation
- A very convenient method where program is divided into logical pieces called segments.
- Consecutive program segments can be stored in non-consecutive locations.
- A data item is addressed as name_of_segment + offset_of_data_inside_segment.
- The segment name and address is stored in Segment translation table(STT)
- Also, Two processes can share a same segment
5) Paging
- Programs are here divided into equal sized pages & memory is also divided into same size page-frames.
- Paging address works similar to segmentation. It has also has a page translation table.(PTT)
- While segments are who block of code (complete function or module), pages are of fixed size and contain part of executing code/data
- They are usually small in size.
6) Paging +segmentation combined
- The principle here used is that “paging offer efficiency” and “segmentation provides logical protection”
- So, here the programmer is given the freedom to define segments on his own and later the OS breaks down these segments into pages.