RE: Shared mmap and data consistency upon a crash
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Thread-index: AcZ0EJo6T4GhLlU7Q6+X9yyilMmXnQAAQvCQ Thread-topic: Shared mmap and data consistency upon a crash Hi Felix, You need to msync() to get your data into your file soon after you changed the data in the shared file. You have to certainly do it before the point where you assume probable crash lurks. --Sanjay -----Original Message----- From: darwin-dev-bounces+samishra=quark.com@lists.apple.com [mailto:darwin-dev-bounces+samishra=quark.com@lists.apple.com] On Behalf Of Felix Schwarz Sent: Wednesday, May 10, 2006 2:32 PM To: darwin-dev@lists.apple.com Subject: Shared mmap and data consistency upon a crash Hello, I am currently exploring the possibilites to use mmap to speed up some of my most critical I/O, but am wondering about the reliability of mmap and the durability of changes made to a file this way for one particular edge case: If 1) I mmap() a file using MAP_SHARED, PROT_READ and PROT_WRITE 2) I write into the returned address space 3) my app crashes prior to reaching munmap() and close() Pseudocode: // mmap file (1) p_m = fopen(..) mptr = mmap(..p_m..) // Modify the file (2) *mptr = 0xBEEF; // Crash here (3) *((int *) 0) = 1; // Memory would have been unmapped and the corresponding file closed here // However, this shall not be reached in this example munmap(); fclose(p_m); Will the data written in 2) actually show up in the file? Does mmap() take care that mapped memory and the file it is mapped to are synced in the event of a crash? Felix _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/samishra%40quark.com This email sent to samishra@quark.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Sanjay Mishra