Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"
I was not able to find the answer from web. So posting here.
thanks,
srinivas
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment
0?"
I was not able to find the answer from web. So posting here.
thanks,
srinivas
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
As a guess,
Linux kernel developers leverage the fact that low address values are illegal, thus a pointer handling error that generates a low address value triggers a trap which allows the programmer to know he screwed up.
Using virtual memory segment zero makes those valid addresses and thus programming errors are more likely to slip through un-noticed.
HTH
Greg
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
On Mon, Aug 27, 2012 at 3:31 AM, Srinivas Ramanan
[off-list ref] wrote:
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"
segment 0? or mapping zero page?
If it is indeed zero page, well, it's to trigger page fault later and
do actual page allocation when the variables (or structure etc) at BSS
is actually accessed.
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
On Mon, Aug 27, 2012 at 2:01 AM, Srinivas Ramanan <
srinivas.ramanan@gmail.com> wrote:
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"
I was not able to find the answer from web. So posting here.
thanks,
srinivas
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi,
The bss section typically includes all uninitialized variables declared
with the static keyword.
The zero page which is a copy-on-write page that reads as zero is used to
map the BSS segment. Any process referencing the zero page sees the page
filled with zeos and if it tries to writes to the page, it ends up
modifying a private copy. (LDD ch15. page 429)
Mulyadi,
Why it will generate a page fault later when process will tries to
reference it, while it already has mapped with the zero page?
Sorry if i am wrong anywhere.
Ritesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120902/b18f7568/attachment.html
Hi... :)
On Sun, Sep 2, 2012 at 2:23 AM, Ritesh Harjani [off-list ref] wrote:
Mulyadi,
Why it will generate a page fault later when process will tries to reference
it, while it already has mapped with the zero page?
Hopefully I interpret it correctly that this question is for me :)
Sorry, maybe I am not clear, by reference, I meant "updating " or
"writing" new value.
Since this zero page is mapped as read only, when writing to this zero
page, page fault is triggered. Then page fault handler conclude that
this is actually a write toward zero page from valid address, so it
will allocate page(s).
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com