Download presentation
Presentation is loading. Please wait.
Published byWilla James Modified over 8 years ago
1
Division of a process into Pages public class Misc { public static int add(int a, int b) {return a+b; } public static int fact(int x) {int f= 1; if (x == 0) f = 1; else f = x* fact(x-1); return f; } public static double smaller(double d1, double d2, double d3, double d4) { double sm = d1; if(d2 < sm) sm = d2; if(d3 < sm) sm = d3; if(d4 < sm) sm = d4; return sm; } public static char smallest(char c1, char c2, char c3) {char s =c1; if (c2 < s) s = c2; if (c3 < s) s = c3; return s; } Advantages: Division is easy Page handling is simple Disadvantage: The division of the process is not according to the logical structure of the process
2
Segmentation In paging, the division of a process is not according to the logical structure of the process. If a process is divided according to its logical structure then the blocks of the process are of different sizes called segments and the corresponding mm scheme is called segmentation. A segment can be of any length determined by the OS. The logical address a in segmentation, like paging, is also two dimensional: a = ( s, d) where s is segment number and d is displacement within the segment and is also called offset. A segment table is maintained for each process; this contains information about where a segment has been loaded in the main memory. –Each entry into the segment table has two components: limit and base; the base is the starting address of the segment in the RAM and limit is the length of the segment.
3
Division of a Process into Segments public class Misc { public static int add(int a, int b) {return a+b; } public static int fact(int x) {int f= 1; if (x == 0) f = 1; else f = x* fact(x-1); return f; } public static double smaller(double d1, double d2, double d3, double d4) { double sm = d1; if(d2 < sm) sm = d2; if(d3 < sm) sm = d3; if(d4 < sm) sm = d4; return sm; } public static char smallest (char c1, char c2) {char s =c1; if (c2 < s) s = c2; return s; } Advantage: The division of the process is according to the logical structure of the process
4
Segment Number & Offset / Displacement Displacement d 0 1 2 3 Process P 786 a=(1, 786) Logical address Segment Number s Seg.#
5
Loading Segments into the RAM Process A s 0 0 1 1 2 A1 A2 A0 Process B B0 B1 Limit Base OS 0 2048 0 1 2 6002048 A0 2648 1000 4002648 3048 B0 3048 4048 A1 3022 20004048 6048 B1 6048 A2 Seg. Table for Process A Seg. Table for Process B 9070 RAM
6
Relocation / Address Mapping Converting the logical address into the real address in the RAM is called Relocation / Address translation / Address Mapping and is done is done as follows: 1.Segment number is used to index the segment table; look into slot no. s of the segment table for the given process. This gives limit and base. 2.The displacement d is then compared with the limit. i.If d > limit then this is addressing error; trap it. ii.If d < limit then real address: r = Base +d EX. Using the given segment table convert the logical address (3, 657) into real address. Limit Base 1000 1400 1000 4700 1100 3200 400 4300 400 6300
7
Relocation / Address Mapping CPU................ Limit Base S d S < + Base + d No yes Trap; addressing error r r RAM Address Translation in Segmentation
8
Combined Paging & Segmentation The respective advantages of paging and segmentation are combined into a paged segmented system. In this system: 1.Main memory is divided into blocks of equal sizes called page frames. 2.The process is divided into segments. 3.The segments are divided into pages. A logical address a is now three dimensional: a = ( s, p, d), where: s is segment number p is page number within segment s d is offset within page p (1,2,345) 0 0 1 1 1 0 2 3 0 2 s p 1 2 345 s p d
9
Assignment 3 Marks = 3, Last Date for submission:15-01-2010 Q. Demonstrate page loading and address mapping in a paged segmented system.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.