• 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
Re: non-blocking file writes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-blocking file writes


  • Subject: Re: non-blocking file writes
  • From: Jeff Harrell <email@hidden>
  • Date: Tue, 8 Jul 2003 08:36:27 -0500

You guys are talking as if you were doing direct I/O. Now, I'm an IRIX programmer, and I'm somewhat new to this Darwin thing, but aren't write() calls buffered inside the Darwin kernel? In other words, you issue a write(), and you get program control back immediately. The data itself sits in a buffer waiting to be spooled out to disk, or over a socket, or whatever. At least, that's how it is in the IRIX world, and I just would have naturally assumed that's how it is in the Darwin world, too. But assumptions are often wrong...

On Tuesday, July 8, 2003, at 08:08 AM, Devon E Bowen wrote:

If I understand you correctly, what you are asking is how do I write to a
file without making the user wait for the write to finish? I think the only
answer is to do the file writing in a separate thread.

That's half of the problem. The other half is being able to implement flow
control. For example, if I know that the file will block on a write, I
can implement flow control and tell my upstream source (network socket) to
stop sending me data. Otherwise, my process memory grows and grows as I
receive more data and need to hold on to it in this separate thread until
it gets written. Of course, I can implement some kind of artificial
threshold to simulate a block on write. Seems a bit odd, though. The other
solution suggested by email@hidden would have the same issues.

But you are correct that few people would go to that trouble - since in most
cases file writes are finished in fractions of a second.

That's usually true for local disk. But not for pathological conditions such
as an NFS host that goes missing during a reboot or something. I'm trying
to write a robust application. The UNIX select() call allows you to wait
for readability or writeability of any file descriptor. Seems strange to me
that this functionality gets lost in the Cocoa event loop. It's almost like
they are trying to prevent you from writing robust apps. 8-)

In any case, thanks for the help. Now I know I didn't miss something.

Devon
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.



--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: non-blocking file writes (From: Devon E Bowen <email@hidden>)

  • Prev by Date: NSString to int (or double) conversion
  • Next by Date: Re: Cannot declare variables in the middle anymore
  • Previous by thread: Re: non-blocking file writes
  • Next by thread: Re: non-blocking file writes
  • Index(es):
    • Date
    • Thread