simple HD fragmented ?

CandyKid

Senior member
Apr 16, 2000
266
0
0
Could someone explain to me exactly what fragmenting is? I know how to defrag and all that stuff to fix it, but i was just wondering what it means when your HD is fragmented, how does it happen. Just curious.
Thanks
Gleb
 

Modus

Platinum Member
Oct 9, 1999
2,235
0
0
WARNING: The following post is needlessly long and needlessly boring. It is the work of a socially deprived computer consultant with nothing better to do on a Saturday afternoon. Read at your own risk.

Since the days of DOS 6, when Microsoft first introduced their Disk Defragmenter utility, hard drive defragmentation has been a regular chore for most PC users. There were other utilities before DEFRAG.EXE that did the same job -- Norton SpeedDisk, for example -- however none came to be as widely used as Microsoft's program.

It wasn't long before "Have you defragged your hard drive?" worked it's way up the ladder of standard questions a PC support technician would ask when confronted with an otherwise unsolvable problem. Windows 95 introduced a new, protected mode version of Disk Defragmenter, and Windows 98 improved on it with Intel's Application Launch Acceleration Technology. The prevailing sentiment was that defragmentation was more than just a process whereby you improve the performance of a well-used file system; it was an absolute necessity, and no computer problem could be diagnosed without first defragging the hard drive of the system in question.

"But what is it really doing?" asked many.

"It's making sure your files are properly organized," was the answer from even the most knowledgeable techs.

While this is true in a sense, there is a more accurate, detailed explanation that I think would benefit many.

I first learned about defragmentation while talking to my father. He was a programmer back when "mass storage" meant a two foot reel of magnetic tape whirling away next to a room-sized mainframe computer. Today, we are spoiled by cheap 7200 rpm hard drives transfering data at 40 megs a second, with seek times under 9 ms. But back then, "seek time" actually meant something. If you wanted to retrieve a particular record from a database, it involved a grueling wait as the tape turned around and around, finally reaching the right spot.

Later, when tapes began to store files under a system much like the one in use on today's hard drives, fragmentation became a serious problem. So what is it? To answer that, you have to know a little bit about the way data is stored on a random access device (modern tape drives, hard drives, RAM, CDROM's. . . just about any computer storage technology.)

First of all, files as we know them mean nothing to your hard drive. They're just chunks of data that the operating system requests from time to time. For any file system to work, there has to be a way of quickly locating the file you want. Obviously you can't just search through the entire drive, one byte at a time, until you find what you're looking for. If you have an MP3 file that occupies 4 megs, your operating system needs to know exactly where that file is on your disk, so that when you go to play it, it can tell your hard disk to seek to the exact location where the data begins and spit out 4 megs of it.

The solution is a File Allocation Table (FAT). Your operating system uses the first part of your drive as a FAT, storing the names of all your files and their physical locations on the disk. If you want to access "stayinalive.mp3", your operating system looks in the FAT and cross-references the file name to a specific location on disk. It tells your hard drive to seek to the proper location and retrieve the data.

Bingo, disco inferno!

But there's a complication. To have a speed-efficient FAT, the data area of the drive must be divided into a finite number of identically-sized clusters (allocation units). Each cluster can hold only one file. Obviously, a single cluster (only 4 to 32k in size) will not accomodate a large file. In this case, the cluster holds the first portion of the file, and contains a pointer to the next cluster in the chain of clusters that collectively holds the entire file. Usually, the next cluster in the chain comes immediately after the preceeding cluster. All well and good, but let's look at a common scenario:

A file is written to disk; its chain is closed. A second file is written to disk. Logically, the operating system places this second file immediately after the first file on the physical disk. The second file is closed. But some time later, the first file needs to be changed -- information must be added. What does the OS do? It cannot simply tack the extra data onto the end of the file, for that would overwrite the file beginning immediately after it. Instead, the OS begins adding to the file somewhere else on the disk. Then, it goes to the end of the original chain and adds a new pointer, indicating where the rest of the chain continues.

The problem with this method is that, although it is close to 100% efficient at conserving space, any files that are constantly modified will begin to occupy several chains across the disk. When these files are accessed, the drive must seek back and forth to read them in their entirety. Thus, when a file does not occupy a single, physically-continuous chain, we say it is fragmented.

Defragmentation works by examing the chain structure for every file on your drive, and then rebuilding fragmented files into single, continuous chains. For a large drive with many frequently-used files, this process is understandably slow.

Windows 98 and presumably all future Microsoft operating systems have Intel's Application Launch Acceleration Technology incorporated into Disk Defragmenter. This feature takes advantage of the fact that Windows records the precise order in which any application loads its support files. When your disk is being defragmented, files are physically placed in the exact order they are loaded by common programs, reducing seek times later on, since the drive can now read data in a continuous stream.

This sounds marvelous, but the fact is that today's drives seek very, very fast. Spending two hours to defragment a hard drive and move large chains back and forth will not save you two hours of lost performance. And defragmentation is certainly not the magical "cure all" many tech support personell make it out to be. Still, it's a useful chore when a computer is otherwise unoccupied.

Modus
 

obenton

Platinum Member
Oct 11, 1999
2,012
0
0
... needlessly long, but not boring. It's a pleasure, in fact, reading needlessly long but literate posts.
 

CandyKid

Senior member
Apr 16, 2000
266
0
0
thank you very much!! I really think it's awesome that you would take that much time to explain something to someone you dont even know. I really appreciate it. It was very insightfull and It definetly explained everything I needed to know. If you have some time could you also explain to me directx. why does it cause so many problems and the history of the engine.
thanks a lot
gleb
 

Modus

Platinum Member
Oct 9, 1999
2,235
0
0
CandyKid,

Now hold on a second. Don't go thinking I wrote that just for you. I'm not that nice :p

Actually, I wrote it a couple months ago just for fun, because I found that a lot of people (like yourself) didn't really understand what fragmentation was. I always keep my large posts on topics that interest or inflame me (winmodems, partitioning, AMD vs. Intel, etc). I just pasted it in here for you. As for DirectX:

Looking past all the Microsoft hype about "a better entertainment experience", DirectX is basically just an application programming interface (API). An API is a library of standard routines that can be accessed by any compliant application. This library allows a programmer to forgoe writing code that has been done thousands of times before, for instance, displaying a small message window or closing an application. In fact, Windows itself is essentially one big API. That's why all Windows programs use the same interface, with the same buttons and boxes and bars.

Similar elements must be incorporated into every game that comes out: sound output, joystick processing, graphics. DirectX allows game developers to use Microsoft's standard routines for, say, 3D positional audio, instead of writing new code themselves. Theoretically, this allows game developers to focus on content rather than mechanics. The only problem is that the DirectX API is now huge that it becomes a new computer language unto itself. Still, a game programmer who knows it inside and out has an enormous advantage.

Another important function of DirectX is hardware abstraction. With so many new video cards and sound cards coming out and the technology advancing so quickly, it would be impossible for game developers to anticipate how to deal with every new piece of computer hardware. With DirectX, they don't have to. They simply make sure that when drawing, say, a textured polygon, they use the appropriate Direct3D routines. Hardware manufacturers, in turn, make sure that their software drivers are DirectX-compliant, meaning that DirectX can talk to them in a standarized way for every card, and tell them what to do.

So when playing a DirectX game, their are many levels of processing before your gun shot appears on the screen:

- you pull the trigger on your joystick
- the sound card processes the game port data and sends it to the software drivers
- the sound card drivers pass this on to DirectX (DirectInput)
- DirectInput passes this on to the game
- the game wants to draw your gun again, this time slightly recoiled from firing
- Direct3D routines are accessed
- video drivers are accessed
- video hardware is accessed
- the gun moves

Modus
 

CandyKid

Senior member
Apr 16, 2000
266
0
0
couldn't you just let me glow in the thought someone did post that up just for me? j/k thanks anyway its still really cool of you to do that , and thanx for explaining the directx thing.
I know you've responded a lot but could you do one more thing, all those documents you mentioned are things a would love to read and learn about, could you send me those documents via e-mail? That would be awesome. my e-mail addy is: candydancin@aol.com.
if you dont want to thats fine you've already done a lot.
thanks again
gleb