Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My device receives a data stream. I want to write a C program to save this data stream to many files in a SD-Card. The SD-Card is formatted in FAT32 for a compatibility reason. I want to write full page of memory to aim to improve the write efficiency and get longer life of the SD-Card. Is it possible to lock the synchronization between the cache buffer and the storage device until the buffer is as long as the page size ? In other word, flush only full page of data ? Or I have to format the SD-Card to JFFS2 or YAFFS ?
Welcome to LQ. If you're writing C, that ought do be doable in your program. If you have to ask, you've failed the exam :-P. The system has it's own mind on matters, and doing that through the system is not on.
Yes, I'm writing in C. That was actually my idea to store temporary the data stream in a buffer, and when I have enough data (one page size), write them in the SD-Card :
write (fd, buffer, PAGE_SIZE);
But I was wondering if the OS really flushes the data in one time from the virtual memory to the hardware.
Maybe a other method it to map the memory :
mem = mmap (0, PAGE_SIZE, PROT_WRITE, MAP_SHARED, PAGE_SIZE * pageCounter);
memcpy (mem, buffer, PAGE_SIZE);
munmap (mem, PAGE_SIZE);
But again, my question is the same, does the OS flush in one time from the virtual memory to the hardware ? I hope so with the MAP_SHARED flag.
If you're writing C make sure to install the info pages from your distro, as they have entries for the various function calls. There is a HOWTO and several guides on programming for linux. People will expect you to have a knowledge of that stuff before you start asking. I will bow out here, as C is not hugely my thing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.