xxyzz / ostep-hw

Operating Systems: Three Easy Pieces(OSTEP) homework and project solutions
GNU General Public License v3.0
763 stars 179 forks source link

chapter 5 Q 2 #4

Closed songlin-zheng closed 3 years ago

songlin-zheng commented 4 years ago

If you write open() before fork(), as indicated in the question, both processes will append to the end of th file, not overwrite.

xxyzz commented 4 years ago

I updated the answer in https://github.com/xxyzz/ostep-hw/commit/8fbf5e185da90cdd0c814074885a6eb171d59cb2. It depends on the scheduler, maybe they will write sequentially in most cases but not all the time.