Reasons for a buffer or RAM



**** Post for FREE via your newsreader at post.usenet.com ****

On page 82 of "Programming from the Ground Up" we're in the midst of a program
that will convert all the lowercase letters from a file into uppercase letters.
Specifically the buffer section that assignes memory for the buffer looks like
this:

..section .bss
#Buffer - this is where the data is loaded into
# from the data file and written from
# into the output file. This should
# never exceed 16,000 for various
# reasons.
.equ BUFFER_SIZE, 500
.lcomm BUFFER_DATA, BUFFER_SIZE

Previously it was explained that we didn't know how big the first line would
be, and that we needed to put it into a buffer. Consequently, we might
unexpectedly run out of space. However, doesn't the file itself already exist
somewhere in memory or disk space? It must needs be so, because if our programs
cannot access memory directy, but only thru the kernel, how much more will a
random input from a user be incapable of using up all the memory without the
kernel knowing about it? So my question is: if the kernel already knows the
size of the file, why can't it pass this information on to the program, so
that it can set its memory requirements?



--
"The world of existence is an emanation of the merciful attribute of God."
Abdul-Baha
http://www.costarricense.cr/pagina/ernobe

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
.



Relevant Pages

  • CONFIG_PACKET_MMAP revisited
    ... I've been looking into faster ways to do packet captures and I stumbled on ... In that discussion Jamie Lokier suggested having a memory buffer that's ... shared between user and kernel space and having the NIC do DMA transfers ...
    (Linux-Kernel)
  • Re: contigmalloc() and mmap()
    ... there seems no big differences between the kernel ... > to the card on another node, it will be DMAed to memory too. ... The buffer is mmaped to user process space, ... > mmap driver's buffer (allocated by contigmalloc()) and is killed, ...
    (freebsd-hackers)
  • Re: [2.4] heavy-load under swap space shortage
    ... > This file controls the operation of the bdflush kernel ... > -to a clean buffer, which can just be forgotten about). ... > -value can lead to memory shortage when bdflush isn't woken ... > Kswapd is the kernel swapout daemon. ...
    (Linux-Kernel)
  • Re: contigmalloc() and mmap()
    ... there seems no big differences between the kernel ... > to the card on another node, it will be DMAed to memory too. ... The buffer is mmaped to user process space, ... > mmap driver's buffer (allocated by contigmalloc()) and is killed, ...
    (freebsd-hackers)
  • Re: read vs. mmap (or io vs. page faults)
    ... :with the possible madvise) provides the kernel with more information ... L2 cache, and that is precisely what is happening when you readinto ... a fixed buffer in a loop in a C program... ... and 3 GBytes/sec uncached to main memory. ...
    (freebsd-current)