From: ralf@uni-koblenz.de
To: Amol Mohite <amol@m-net.arbornet.org>, linux-mm@kvack.org
Subject: Re: Somw questions [ MAYBE OFFTOPIC ]
Date: Fri, 2 Apr 1999 11:35:55 +0200 [thread overview]
Message-ID: <19990402113555.F9584@uni-koblenz.de> (raw)
In-Reply-To: <Pine.BSI.3.96.990401041607.28014A-100000@m-net.arbornet.org>; from Amol Mohite on Thu, Apr 01, 1999 at 04:16:51AM -0500
On Thu, Apr 01, 1999 at 04:16:51AM -0500, Amol Mohite wrote:
> 1) How does the processor notify the OS of a pagefault ? or a null pointer
> exception ?
> Now null pointer exception I know, is done using the expand down
> attribute in descriptor. However, when the processor gp faults, how does
> it know it is a null pointer exception ?
A NULL pointer is just yet another invalid address. There is no special
test for a NULL pointer. Most probably for example (char *)0x12345678 will
be invalid as a pointer as well and treated the same. The CPU detects this
when the TLB doesn't have a translation valid for the access being attempted.
> Where does it store the program counter ?
On the stack.
> 2) How are the following exceptions handled ;
> TLB Refill
> TLB Invalid
> TLB Modify ?
Not all architectures do provide these exceptions at all. MIPS for
example does:
- TLB Refill will just reload the entry from the page table into the TLB.
- TLB Invalid checks if reading is allowed, then marks the entry in the
page tables and TLB accessed. If the access is not allowed the
do_page_fault() is being called to do whatever is necessary.
- TLB Invalid checks if writing is allowed, then marks the entry in the
page tables and TLB accessed/dirty. If the access is not allowed the
do_page_fault() is being called to do whatever is necessary.
Some architectures like m68k or Intel do most of this in hardware.
> 3) How does the processor differentiate between entries (PTE) in the TLB
> belonging to different processes ? Is it a bit in this ?
Again that's architecture specific. The simplemost way to deal with this
problem is to just flush the entire TLB on context switch. More advanced
TLB architectures additionally can tag each TLB entry with an Address Space
ID (ASID) or Process ID (PID). A search in the TLB only hits if the current
process has the same ASID/PID as the searched TLB entry. Using this
architectural feature the number of TLB flushes can be greatly reduced.
> 4) Why is the vm_area_structs maintained as a circular list, AVL tree and
> as a doubly linked list ?
> Why an AVL tree ? Any specific reason ?
Certain applications like debugging with Electric Fence result in a large
number of exceptions that is searches in the vm_area_structs. Not using
efficient data structures results in a dramatic slowdown of these. It
makes little difference for the average case.
The list structures are also available since for certain cases the kernel
has to iterate through all the VMAs.
> 5) What is the difference between SIGSEGV and a SIGBUS ?
SIGSEGV is being sent for accesses to memory using bad addresses, that is
for example where nothing has been mapped. SIGBUS is for cases like
using an address outside of the allowable address range, that is for
example kernel addresses, when the hardware signals trouble with a physical
address, there is no more physical memory available to handle a fault or
similar.
> 6) How does the processor signal memory access inan illegal way (i.e.
> trying write access to memory when this is not allowed )
See above.
> 7) How does linux handle malloc function ?
Not at all. Malloc(3) is part of libc. It's implemented using brk(2)
and mmap(2) of /dev/zero.
Ralf
--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org. For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/
next prev parent reply other threads:[~1999-04-02 13:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-01 9:16 Somw questions [ MAYBE OFFTOPIC ] Amol Mohite
1999-04-02 9:35 ` ralf [this message]
1999-04-02 18:56 ` Chris Atenasio
1999-04-05 9:12 ` Amol Mohite
1999-04-06 10:55 ` ralf
1999-04-06 22:51 ` Stephen C. Tweedie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19990402113555.F9584@uni-koblenz.de \
--to=ralf@uni-koblenz.de \
--cc=amol@m-net.arbornet.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox