Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261399AbVETJa0 (ORCPT ); Fri, 20 May 2005 05:30:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261395AbVETJa0 (ORCPT ); Fri, 20 May 2005 05:30:26 -0400 Received: from hermine.aitel.hist.no ([158.38.50.15]:1292 "HELO hermine.aitel.hist.no") by vger.kernel.org with SMTP id S261399AbVETJaS (ORCPT ); Fri, 20 May 2005 05:30:18 -0400 Message-ID: <428DAF67.70105@aitel.hist.no> Date: Fri, 20 May 2005 11:35:35 +0200 From: Helge Hafting User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: sylvanino b CC: linux-kernel@vger.kernel.org Subject: Re: questions about system function: mmap / fwrite References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1268 Lines: 37 sylvanino b wrote: >Hello, > >I have a question about ways of accessing a file. > >I know it is possible to use: fseek + fwrite/fread to access a file. >and It is also possible to map file in memory with "mmap" function, >and access it by adressing memory. > >Currently I use the frame buffer of mobile phones with mmap function. >For my understanding, I would like to know what is the difference >between using fseek+fwrite compared to mmap style. >Dont hesitate to be precise or to use technical terms. > >Thanks you, > > There may be subtle performance differences, but I'd say the most important here is to use the API that best suits the problem at hand. fwrite/fread is sequential in nature, useful when you want to read/write large contigous chunks of data, and when the notion of a "current position" in the file is useful. mmap is nice when you find it useful to access the file as a random-access array of bytes. mmap style access seems to be the best fit for a framebuffer. Helge Hafting Helge Hafting - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/