• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Shared mmap and data consistency upon a crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shared mmap and data consistency upon a crash


  • Subject: Shared mmap and data consistency upon a crash
  • From: Felix Schwarz <email@hidden>
  • Date: Wed, 10 May 2006 11:02:13 +0200

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: OpenDirectory: creating a LocalCachedUser?
  • Next by Date: RE: Shared mmap and data consistency upon a crash
  • Previous by thread: Re: OpenDirectory: creating a LocalCachedUser?
  • Next by thread: RE: Shared mmap and data consistency upon a crash
  • Index(es):
    • Date
    • Thread