cancel
Showing results for 
Search instead for 
Did you mean: 

Read or write process explained

SOLVED
Go to solution
cartman_2
Frequent Advisor

Read or write process explained

Hello,

I was trying to understand, the whole process for a read or write system call, since it is called by the process until it receives it back from disk.

Could you point me to a good doc, or kindly explain it here.


Just to list what more or less I understand, it could be completely wrong

Process read system call read()
the process does a voluntary Context Switch and sleeps until the io returns
Looks in all the levels of CPU cache
Looks in the data buffer cache
if not in buffer cache it goes to the FS
FS(jfs) checks the inode info on the file to read
goes through lvm
multipathing software if exists
fiber channel cards(if san)
and finally to the disk
all the way up the stack again
the read data goes into the buffer cache
and form here :?

thanks!.
4 REPLIES
cartman_2
Frequent Advisor

Re: Read or write process explained

could it be like this?

Process read system call read()
the process does a voluntary Context Switch and sleeps until the io returns
Looks in all the levels of CPU cache
Looks in TLB for the pages
Looks in memory for the pages
If not in memory a Page fault happens
Looks in the data buffer cache
if not in buffer cache it goes to the FS
FS(jfs) checks the inode info on the file to read
goes through lvm
multipathing software if exists
fiber channel cards(if san)
and finally to the disk
all the way up the stack again
the read data goes into the buffer cache
and form here :?
Dennis Handly
Acclaimed Contributor
Solution

Re: Read or write process explained

>Looks in all the levels of CPU cache

Only the CPU looks in its cache and it only would be a side effect of looking in the file cache.

>Looks in TLB for the pages
>Looks in memory for the pages
>If not in memory a Page fault happens

Again a side effect of looking in the file cache.

Basically these 4 areas are used to load data, not directly for read(2)
cartman_2
Frequent Advisor

Re: Read or write process explained

Hi Dennis,

Thnx for the answer, so if I understand you correctly, when you issue a read or a write system call, you bypass all these steps:

Looks in all the levels of CPU cache
Looks in TLB for the pages
Looks in memory for the pages
If not in memory a Page fault happens

And it goes directly to look in the Buffer Cache.


And when the process needs to load into memory program data, then it does all the steps.

So just to resume, as seems logical, all the data that read and write gets from disk never goes into memory.
Dennis Handly
Acclaimed Contributor

Re: Read or write process explained

>you bypass all these steps: ...
>And it goes directly to look in the Buffer Cache.
>And when the process needs to load into memory program data, then it does all the steps.

Yes. But once it looks in the buffer/file cache, it then does those steps.

>all the data that read and write gets from disk never goes into memory.

Sure it goes into memory. It has to go somewhere and that's into memory. Whether into the buffer/file cache or directly into the user's buffer.