Re: internel implemention of file operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Default read/write inerfaces does not move file's data to process address space ?
Yes it does, in either case, user space memory has to be in process address space. But Difference is in the access pattern. With read/write, you demand for it explicitly through a system call, hence application is more involved here. While for mmap access, all transfer happens in application-unaware mechanism, with page-fault handlers inside kernel. Application just access mapped buffers like memory array and magic happens inside kernel as you keep on accessing bytes.

Best way to find out difference is to try out writing a simple mmap program.

-Rajat


On Fri, Jan 11, 2013 at 3:31 AM, horseriver <horserivers@xxxxxxxxx> wrote:
On Fri, Jan 11, 2013 at 12:39:26PM +0530, Rajat Sharma wrote:

> Default read/write inerfaces are better suited for sequential read/write
> within your program. Although you can seek to any location within the file,
> you still have overhead to issue system calls to get data. However mmap
> allows you to map a section of file into program address space.

  Default read/write inerfaces does not move file's data to process address space ?

  when  r/w a file descript which returnd by open() , how do the file data move from one place to another place ?

  For each time the write function being  called  , will kernel  call filesystem's driver's write  to respond  ??
  In my opinion,kernel will passed a  buffer's head address  which is passed form user-layer into driver,then driver will fill this buffer with file's
  data which is got by filesystem's read operation ?

  Am I right?

  Thanks!
>
>
> -Rajat
>
>
> On Fri, Jan 11, 2013 at 2:44 AM, horseriver <horserivers@xxxxxxxxx> wrote:
>
> > hi:
> >
> >   these two wayes of operating one file :
> >
> >   1.use open/write interface call .
> >
> >   2.mmap this file into memory , then access this memory area and do r/w .
> >
> >   what is the essential difference between this teo wayes?
> >
> > thanks!
> >

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux