mmap text file
Ssagarr Patil
hugarsagar at outlook.com
Wed Apr 1 06:10:39 EDT 2015
Hi Valdis,
> On Tue, 31 Mar 2015 17:11:33 +0530, Ssagarr Patil said:
>> Hi,
>
>> while (loop) {
>> /* get the current file size of output file */
>> filesize = lseek(outfd, 0, SEEK_END);
>>
>> /* Increase file size */
>> ftruncate(outfd, (off_t)filesize + (off_t)buf.size
>
>
> Are you sure you want to do these two *every time* through the loop?
>
>> /* mmap destination file */
>> if((dest = mmap(0, buf.size, PROT_WRITE, MAP_SHARED, outfd, filesize)) == (void *) -1) {
>
> Similarly here - usually the *entire* file gets mmap'ed.
>
> Also, what did perror() output? (probably nothing, since you stuck a printf
> in front of it, which probably reset errno on you).
>
>> memcpy(dest, src, size);
>> munmap(dest);
>
> You're not going to achieve faster throughput by adding to the syscall
> overhead.
>
any pointers on avoiding syscall this then ?
Regards,
Sagar
More information about the Kernelnewbies
mailing list