Hi I am writing a Database in C and would like to write out data to Hard Drive and not have it stored in RAM anymore. Is there a way to do this?
Currently I create a big file and open it as such
fd = open("database.dat",O_CREAT | O_RDWR);
hd = mmap(0, SSD_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
And then write to memory addresses that have been mmapped and then
msync(dest,DB_PAGE_SIZE, MS_SYNC);
where dest
in in the mmaped region.