Here are my thoughts. Plz correct me if I am wrong.

In the given example 5000 is the offset within the file and not the address.
Given, the offset 5000, kernel anyway could allocate a physical page and
place the contents from the starting of the page and map it to the virtual
address.
For E.g. it could allocate a physical page of base address 0x2abd1000 and
copy the 1000 bytes of contents from the offset 5000 and map the physical
address to some virtual address say 0x08054000.

Q. How does the offset not being page aligned affect the execution ?

The 2nd point wrt fragmentation is convincing.

Regards,
Prabhu


On Mon, Sep 20, 2010 at 10:27 PM, Mulyadi Santosa <[email protected]
> wrote:

> hi..
>
> On Mon, Sep 20, 2010 at 19:30, mohit verma <[email protected]> wrote:
> > thanks guys,
> >  but the problem is :
> >  what is  the need of page aligned address? as we have given starting
> > address 5000 and the length 1000 ( in the example by prabhu) so it should
> > start from that location.
>
> I think it is due to two reasons:
>
> 1. on some architecture, non page aligned access could mean
> trap/exception. Well, x86 is immune in this case...but if you wanna
> make your code safely portable, I think it's a must.
>
> 2. By making it page aligned, at least you reduce fragmentation.
>
> How come? Let's assume you just have 8K address space. You allocate a
> memory starting at 3K as large as 4K. That means you occupy 3K up to
> 7K address. What's left? 0-1 K and 7-8 K, right?
>
> And what if you wanna allocate another 4K? Yes, a page can fit
> that...but not mapping. We can't split below page granularity, so at
> least we need two page. one is mapped to 0-1 K, the other is for 7-8K.
> It's 2 page vs 3 page case.
>
> Yes, there's slab...but if we can allocate straight in page size
> granularity, things would be simpler, right?
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [email protected]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

Reply via email to