> Hi Rajat, > > mmap is used to map file(devices) or shared memory to process virtual > address. > > So, for any device or file, which you want to map, everything is > treated as file. So, in all cases you are trying to avoid file system. > Typically read(),write() all these functions are generic functions provided > by filesystem for a uniform access to all devices and files hiding the > details. > > So, when you are using mmap, you are excluding file system and directly > accessing memory as if it is within process address space. > Typically when you map certain virtual address of process, depending on > requested memory, those size pages are allocated to the calling process. > > Now depending upon what you have mapped to, the OS is going to perform > operations on that entity for the memory addressed in store and load > instructions. This entity can be device, file stored on IDE, shared memory > segment across networks. So, this also an abstraction provided by OS. ok. > > Regards, > Sri. > > > On Mon, Sep 20, 2010 at 1:33 AM, Rajat Jain <[email protected]> wrote: > >> Hello List, >> >> I wanted to understand how the mmap works. I mean, not from the kernel >> APIs or data structures perspective, but from the HW perspective. I >> understand that the use case is this: typically applications will mmap() a >> file (a device file or any other file) into user space, and then use direct >> pointers to read / write to that file. So as I understand, after the call to >> mmap, the compiler will generate simple load and store instructions fo any >> reads / writes into that file. What I'm trying to understand is that how is >> it ensured that those load & store instructions get translated into file >> reads/ writes. I think there are two cases: >> >> 1) If the backing file is /dev/mem or a device file, then at the time of >> mmap(), the page table entries / TLB entries are set up such that the >> virtual address in the user space, maps to the actual physical address >> desired. And the thus job is done. This case is clear. >> >> 2) The other case is that when the file is actually a datafile present in >> a file system lets say on a SATA disk. Now, for each load / store in the >> application, some driver code needs to trigger that will program the SATA >> controller registers and do n number of thinks to initiate the diska read / >> write transaction. How is this achieved? Because application is not making >> any System calls. Its just having load / store instructions. >> >> Thanks, >> >> Rajat Jain >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in >> the body of a message to [email protected] >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.linux-learn.org/faqs >> > > > > -- > Regards, > Sri. > >
-- Regards, Sri.
