Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Hard disk LEDs and noisy machines (by Julio Merino) (Developers)

posted by bretjohn Homepage E-mail, Rio Rancho, NM, 19.02.2024, 16:40

> You are confusing buffering and caching.

Buffering and caching are essentially the same thing (or are at least trying to accomplish something similar), though they do it in different ways. Every application that I know of (including the OS) reads from the disk into memory and manipulates what's in memory before writing back, or manipulates the memory before writing something new to disk. They don't work with the data while it's still on the disk. Part of the reason for that is that the data is stored on the disk in blocks (sectors/clusters) and you may only need to manipulate the data in bits or bytes, or at least something much smaller than a sector/cluster. There are other reasons as well, but that is an important one.

Any OS worth its salt will never simply buffer/cache data in memory before writing to disk. The problem with that approach is that if there is a crash in the middle somewhere ALL the data is lost. That's why they invented Journaling File Systems (JFS). In a JFS, the data is not simply stored in memory waiting to be put on disk later. The data is written to disk right away, but is stored in a temporary "holding space" called the Journal. What is stored in the Journal is enough information (the data and/or metadata) so that it can be moved to the correct place on the disk later, but while it's stored in the Journal it's "messy". If there is a crash between the Journal write and the "real" write, the data can still be put on the disk where it needs to be. If there is a crash while writing to the Journal, the data will be corrupted. The point of the Journal is to get _something_ relevant out of memory and onto the disk as fast as possible and worry about cleaning up the details later. Also note that in a JFS the disk is used a lot more than in a "regular" file system since the data is written and then moved (written to a new location and then deleted from the old location).

BTW, that's similar to how databases work. When you update a record in a database it gets written to disk right away -- it is not simply stored in memory waiting for a "batch update" to happen later.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 51 users online (0 registered, 51 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum