Few days back my brother asked me a question very casually, "What's the difference between Paging and Segmentation in Operating Systems ?", and here is my version of answer to the question :

Paging is a virtual memory management scheme where the physical memory is divided into fixed sized blocks called frames and the virtual memory is divided into fixed sized blocks as well called as pages. Whenever a program has to be loaded into the memory, pages are loaded into the frames.

Segmentation is another scheme of implementing virtual memory. Here the logical address space is collection of segments. If you've done some coding in assembly then there is a provision of different segments like CODE Segment, DATA Segment, STACK etc. Now these segments aren't fixed sized blocks like pages and aren't necessarily contiguously allocated. Such a scheme is much more preferred by programmers as they can put in any amount of code in CODE Segment, declare any number of variables in DATA Segment and like that. If a reference is required then all that needs to be done is to find the offset and SEGMENT name.

e.g.

DATA
var1 db //offset 0
var2 db //offset 1

var3 db //offset 2

CODE

mov var1,ax //offset 0

mov var2,bx //offset 1
add ax,bx //offset 2
mov ax,var3 //offset 3


Now this sample (might be incorrect aswell :) code will partition memory logically into two units called segments. One segment will be referred to as CODE segment while another one as DATA segment. To access any code all we require is offset and segment name. For e.g. to access var3 we require name of segment i.e. DATA and offset that is 2. What happens internally is that a base address is assigned to each segment name so if a base address 1000 was assigned to segment name DATA then reference to var3 refers to memory location 1000 + offset(var3) = 1000 + 2 =1002.

Hope you got the overview of difference :)

Categories:

5 Responses so far.

  1. Anonymous says:

    Thank you very much.
    Now I know the difference.
    Good Explanation man ;)

  2. veer says:

    hey, thank u.. now i realise what actually d diff is..
    and that is good exmple..

  3. Anonymous says:

    i definitely adore your own writing choice, very remarkable,
    don't give up and also keep creating due to the fact that it simply just nicely to follow it,
    impatient to looked over additional of your current content, have a good one!

  4. Anonymous says:

    Hi


    This is the big one. Finding http://www.BuySellDirect.net is going to change the way I do business, selling FREE in an advance ebay like will never be the same again.


    Use http://www.BuySellDirect.net FREE service to make a second income.

  5. veenu says:

    you have done a fabulous job i really appreciate the way you explain paging and segmentation.
    THANKS DUDE