Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I am working on a project and my project needs to utilize memory as much as possible. I got a confusion at this point. As everyone knows system memory is divided into user space and kernel space. I want to know when I call a read() system call or fread() then whether the kernel creates a buffer in kernel space and fetches the data to it and then transfers data to the buffer in user space or it directly provides a link to copy data to the buffer in user space. In another words, I can say whether a single copy is done or a double copy happens?

Thanks in advance.

Vinay Tiwary
Posted

1 solution

Most drivers read blocks of fixed size from the device and then transfer the specific parts of the requested data to the user. In some cases the driver will need to do multiple reads to get the correct portions of the file. The driver uses kernel memory for the read from (or write to) the device.
 
Share this answer
 
Comments
Vinay Kumar Tiwary 28-Jan-14 5:57am    
Hi Richard thanks for reply. You mean to say, whenever we perform a read operation, first data is transferred to kernel memory and then the kernel transfers it to user space. Is it the same case always or it may differ in different OS?
Richard MacCutchan 28-Jan-14 7:29am    
As far as I know that is the way it works in most operating systems. However I am sure you could ask Google for further information.
Vinay Kumar Tiwary 28-Jan-14 7:42am    
hahaha.. I already asked Google before posting question over here but couldn't find a satisfactory answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900