SPUG: $fd->sync on Win32

Stuart Poulin stuart_poulin at yahoo.com
Tue May 18 17:36:00 CDT 2004


Thanks David!
Good Googlin' ;-)
I wish I could have found this info a few days back.
I did end up writing it in C and using cygwin.  I'm not sure how cygwin actually implements it, but it appears to work the same as on Unix systems.  Maybe I could do a little "Inline" thing for Win32.
 
Nice thing is Perl 5 can sometimes look like C so porting to C can be easy at times.  Long live Perl 5.
 
thanks,
  Stu

David Innes <davidinnes at chicagoscience.com> wrote:

Hi Stewart,

 

Disclaimer: I’ve never done drive testing and I’m ignorant of low-level disk/file functions but…

 

According to Google, it looks as though the Win32 API call FlushFileBuffers() might be equivalent to fsync.  (http://support.microsoft.com/default.aspx?scid=kb;en-us;66052)

 

You can also open a file with no buffering with no caching using the FILE_FLAG_WRITE_THROUGH or the even deeper FILE_FLAG_NO_BUFFERING flags on the CreateFile() API call.  (http://support.microsoft.com/default.aspx?scid=kb;en-us;99794)

 

Recalling my previous disclaimer, Google also turns up a multi-platform tool called dt at http://www.bit-net.com/~rmiller/dt.html.  It appears to require cygwin for Windows platforms but I don’t know whether that’s for the test machine only or for Windows targets as well.

 

Finally, depending on whether you want to run fsync only on the testing host and not targets you may want to play around with Windows Services for UNIX, which also lets you call fsync.  It looks like it’s a free download but it looks like it only works on Win2k, WinXP Pro, and Win 2003 Server.  (http://www.microsoft.com/windows/sfu/productinfo/features/default.asp) 

 

Dave Roth’s Windows NT/Win32 Perl Programming: The Standard Extensions book (Powels: http://www.powells.com/cgi-bin/biblio?inkey=17-157870216x-0 or Amazon: http://www.amazon.com/exec/obidos/tg/detail/-/157870216X/qid=1084823355/sr=1-2/ref=sr_1_2/102-3650323-2047354?v=glance&s=books) goes into a lot of detail about hacking around the Win32 APIs.

 

Hope one of those helps.

                        -- David Innes

 

-----Original Message-----
From: spug-list-bounces at mail.pm.org [mailto:spug-list-bounces at mail.pm.org] On Behalf Of Stuart Poulin
Sent: Thursday, May 13, 2004 1:14 PM
To: spug-list at mail.pm.org
Subject: SPUG: $fd->sync on Win32

 

Hi Folks, 


 


I need to write some benchmark tools that will test various drive access to local disks, network shares, etc. on Windows and Unix.


 


One part is to test fsync timing:


 


for ($j=0; $j<NNNN; $j++){
  unless ($fd->syswrite($buffer, MAXBUF)){
   die "Unable to write $ARGV[0] : $!";
  }
  $fd->sync();


 }


 


$fd->sync Works fine on Unix but isn't implemented on Win32. $fd->sync is really what I want in this case and not $fd->flush.


 


Other than using cygwin.dll - anybody have an idea for Win32?


 


 


Thanks,


   Stu


 


---------------------------------


Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2' 


		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20040518/674de63e/attachment.htm


More information about the spug-list mailing list