Re: data + pendrive + memory

From: Linus Torvalds
Date: Mon Jul 25 2005 - 16:24:12 EST

On Mon, 25 Jul 2005, Rodrigo Ramos wrote:
> IMHO, if a lack of memory happens the Linux will start using swap, then
> the file will end in the hard drive. When I am working with a file in a
> pendrive any information of it is sent to the hard drive ? If it happens
> what is/are the reason(s).

If you always access the file only with mmap(..MAP_SHARED..) (or
MAP_PRIVATE in a read-only manner), or if you always make sure that any
programs that access the data use mlock() to protect it, you'll never hit
the regular disk.

mmap() is generally the better option, since locking down memory may not
be available to normal users.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at