c - Multiple threads writing on same file -
c - Multiple threads writing on same file -
i know if can utilize multiple threads write binary info on same file.
file *fd = openfile("test"); int size = 1000000000; int * table = sizeof(sizeof(int) * size); // .. filling table fwrite(table, sizeof(*table), size, fd);
so wonder if can utilize threads,and each thread calls fssek seek different location write in same file.
any thought ?
fwrite should thread safe, you'll need mutex anyway, because need seek , write atomic. depending on platform, might have write function takes offset, or might able open file in each thread. improve alternative if have in memory anyway code suggests, each thread fill single big array , write out when done.
c multithreading
Comments
Post a Comment