I am new to masm32 and I am studying the examples in the \masm32\examples\ folder. The example findfile, which is in masm32\examples\exampl05\findfile\ must be executed as findfile <filename>. When this is done right after Windows start up it takes about 70 seconds. When I repeat the same findfile<filename> it only takes 3 seconds. So only the first execution takes 70 seconds. Can somebody give an explanation? My system is Windows XP SP3.
When you open a folder, the OS obtains a list of the files in that folder. It caches this list so it can be obtained quickly next time. On startup, many paths have not been opened yet, so they are missing from this cache. The first time you run your program, the paths accessed are added to the cache. The next times you run it, they're already in the cache and so it runs much quicker.
I wondered what would happen if, after the first execution, I would rename or delete one of the found files. It appeared that the list in the cache is then updated accordingly.
The media onto which the file systems structures are written is the thing being cached. The file you renamed represents a very small fraction of the total data and structures cached.
The cache is still kept in synch - when you make a change, it's changed first in the cache; the actual disk structures are updated 'later' (in the background, whenever it's convenient for the OS.)