Skip to content

Commit

Permalink
fstime: replace sync() with fsync()
Browse files Browse the repository at this point in the history
Call fsync() to synchronize changes to the r/w files instead of
doing the system-wide sync. This may save some time in large concurrency scenarios.

github: closes kdlucas#103
  • Loading branch information
Zengkai163 authored Dec 3, 2024
1 parent a07fcc0 commit 2212847
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions UnixBench/src/fstime.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ int w_test(int timeSecs)
extern int sigalarm;

/* Sync and let it settle */
sync();
fsync(f);
sleep(2);
sync();
fsync(f);
sleep(2);

/* Set an alarm. */
Expand Down Expand Up @@ -322,9 +322,9 @@ int r_test(int timeSecs)
extern int sigalarm;

/* Sync and let it settle */
sync();
fsync(f);
sleep(2);
sync();
fsync(f);
sleep(2);

/* rewind */
Expand Down Expand Up @@ -386,9 +386,11 @@ int c_test(int timeSecs)
double start, end;
extern int sigalarm;

sync();
fsync(f);
fsync(g);
sleep(2);
sync();
fsync(f);
fsync(g);
sleep(1);

/* rewind */
Expand Down

0 comments on commit 2212847

Please sign in to comment.