Quote:
Originally Posted by
Krothos
read():
You have a library function
and here a system call
Quote:
that has as it's first parameter (what the open file to read from is)
a file descriptor
Quote:
second parameter( a pointer to a buffer (is this the location of a buffer in the user area or the controller buffer in the kernel?)
no kernel buffer but userland (virtual memory)
Quote:
and a third parameter(# of bytes to read).
So, once the controller stores words from disk into its own buffer
read isn't necessarily retrieving data from a disk through a controller. What is done depends on what the file descriptor points to. Might be a file, a raw device, the network, a serial port, a virtual device, ...
Quote:
, the DMA then transfers the data to the main memory and the CPU gains control. My question is, what now? The purpose was to read a certain amount of words.
These aren't words but bytes.
Quote:
So, are those words being returned to the caller once they are in the main memory or is an address returned of where in the main memory those words are located?
If by main memory you mean kernel memory, no. A process has no access to the kernel memory.
If you are asking if data is copied twice, then that depends on the kernel implementation. Generally, it is true but some OSes allow direct I/O from the driver to the user supplied buffer.
See for example Solaris directio function:
directio(3C) provide advice to file system (man pages section 3: Basic Library Functions) - Sun Microsystems
Quote:
write():
First param(which file to write to), second param (again, unsure. Is this pointing to a buffer in the user area already filled in with the new words to modify the file with?),
Yes (bytes)
Quote:
third parameter (how much you replace)
Main question entails how this even works as opposed to the read. Does the controller still need to store a certain amount of words from the disk into its own internal buffer?
Same as read.
Quote:
I understood it like this: Controller's own hardware buffer somehow stores the words to modify the file. The DMA then uses the new block within the controller buffer to modify a file within the main memory.
I don't get what you mean here.