Wikipedia:Reference desk/Archives/Computing/2011 March 21

= March 21 =

Safe file update (against power failure)
Is it true that in NTFS partitions, updating a file using the following method &hellip;


 * 1) write new data to a temporary file, then
 * 2) close the file to flush the data, then
 * 3) move the temporary file to the original file, replacing it.

&hellip; is safer than the following method (the traditional method), &hellip;


 * 1) truncate the file, then
 * 2) write new data to the file, then
 * 3) close the file to flush the data.

&hellip; power-failure-wise. I use the second method in my program, but a few days ago a power failure struck in the middle of an update, and upon powering up the computer, I got a file that contained only a fourth of the data, necessitating recovering the file. Of course I know that if I wanted greater safety, I should use continuous automatic backup, store the data in a database, install a UPS, etc., but that seemed overkill for my little program (it is not life-critical and the data is not very valuable either). 118.96.160.247 (talk) 01:00, 21 March 2011 (UTC)
 * I'm not a filesystem expert, but I believe that the the first method is indeed safer. It ensures that one version of the file is always on disk, and, since NTFS, like all modern filesystems, is a journaling filesystem, the file move operation will effectively be atomic, so the filename will always point to either the old or the new version.  I think this method would be safer even in a non-journaling filesystem, because it means that you'd no longer be risking data loss in the event of power loss during the "write new data" step, which is probably the longest one.  Paul (Stansifer) 15:58, 21 March 2011 (UTC)

What is this site up to?
For some reason I keep running into the site of some company in the UAE when looking for Google Image results showing maps of the Mexican drug cartels. The site leads me to (http:) //mwjwbrfy.co.cc/fast-scan/ (a site on Wikipedia's blacklist) which has source code mentioning all kinds of "antivirus" terms and file names. How is it supposed to check these, and what does it do with them? Wnt (talk) 02:43, 21 March 2011 (UTC) [note: I was running NoScript and didn't allow the second link ... I don't know if it would be a good idea]
 * It's a bunch of obfuscated javascript that runs when you load the page, a standard malware technique. Looking at the code, it seems to pretend to be a virus scanner checking for and finding various viruses.  It advises you to click a link to disinfect your system, and clicking the link (or any of the links on the page) downloads a .exe that is presumably evil.  Blacklisting is obviously appropriate.  75.57.242.120 (talk) 03:47, 21 March 2011 (UTC)
 * Ah, so it doesn't have any way to look at these file names - just pretends to. Thanks! Wnt (talk) 03:55, 21 March 2011 (UTC)
 * As for Google image search leading to other pages, I asked a similar question last year. It was apparently the result of 'cloaking' and caused quite a stir at Google last year (see: this discussion and this one too). However, Google have take some action and my original search is now listing 'proper' sites.  Astronaut (talk) 06:02, 21 March 2011 (UTC)

How do I view performance of individual cores ?
I have a quad-core CPU, running Windows XP, and I would like to view the activity on each core. When I go to the Task Manager and choose the Performance tab, I only get one graph for CPU usage. So, how do I break it down to see all 4 cores, individually ? Also, is the graph shown the total activity on all 4 cores ? StuRat (talk) 08:17, 21 March 2011 (UTC)


 * Open the Task Manager, switch to Performance tab, then select View &rarr; CPU History &rarr; One Graph Per CPU. 118.96.160.247 (talk) 08:27, 21 March 2011 (UTC)


 * Nothing seems to occur when I do that. Incidentally, that's the only choice under View &rarr; CPU History &rarr;, so presumably it was always selected.  What was supposed to happen ? StuRat (talk) 08:35, 21 March 2011 (UTC)


 * Then Windows is only detecting a single non-hyperthreaded processor with a single core. Can you post the contents of your computer's BOOT.INI file? 118.96.160.247 (talk) 08:43, 21 March 2011 (UTC)


 * I can't seem to find it, even when I include hidden files in the search. Where is it normally located ? StuRat (talk) 09:11, 21 March 2011 (UTC)


 * Follow these instructions to open boot.ini in Notepad, then copy-and-paste into the Wikipedia edit box. (I think it's in the root directory, but you'll probably have an easier time with those instructions.) -- BenRG (talk) 09:40, 21 March 2011 (UTC)


 * OK, thanks, here it is:

[boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect /NoExecute=OptOut

Perhaps there's a more fundamental problem, that it's really only using one of the four cores ? It's supposedly a 2.8 MHz GHz machine, but seems downright slow. If I'm only getting 700 MHz out of a single core, that might explain it. StuRat (talk) 10:26, 21 March 2011 (UTC)


 * Windows is indeed only detecting a single "processing unit" in your computer. By "processing unit", I mean a single core if you have hyperthreading disabled or half-a-core if you have it enabled. 118.96.160.247 (talk) 10:37, 21 March 2011 (UTC)


 * How can I tell if it's enabled or disabled ? StuRat (talk) 10:56, 21 March 2011 (UTC)


 * In other news, there seems to be no problem with your BOOT.INI file. Actually, I am looking for /NUMPROC and other strange options that might cause Windows not to detect all the processors, but there is none of them. 118.96.160.247 (talk) 10:38, 21 March 2011 (UTC)


 * Is it running with Service Pack 3 and all the Windows updates? I'm still researching, but as far as I know Windows XP didn't originally have multicore support and it was added in later, but I could be wrong there. Just trying to verify when it was added if it wasn't in there from the start. Although that leads onto another question, although Windows XP has always had multi-processor support, was this computer installed with this processor or did you install it with a different (single core) processor and then swap in this one? I ask because if that was the case then you'll have a HAL for a single processor only and that's why you're not getting multicore support. I've heard of people swapping files around to hack it to work, but the Microsoft official solution used to be that a full reinstall was needed to change the HAL to multicore. I don't know if that's still the case (I don't really work with XP much anymore so I accept I could be wrong!), but that may still be the issue. Sorry no real solution, but hoping that's at least thrown out some ideas!  ZX81    talk  12:21, 21 March 2011 (UTC)


 * This is a "refurbished" computer, meaning it's had the hardware and software updated, and was then resold. It's possible they updated the hardware to multi-core after they installed the O/S.  How can I tell if I have a "HAL" for a single core ?  Also, I do have Service Pack 3, and I believe I have all Windows updates except one I didn't want, which disabled booting from a USB device. StuRat (talk) 17:45, 21 March 2011 (UTC)


 * Apparently (I had to look it up, but I've found an old XP machine and it seems to work) if you load up registry editor (Start -> Run -> regedit) and navigate to: HKEY_Local_Machine\System\CurrentControlSet\Enum\Root\ACPI_HAL\0000 you'll see a HardwareID value there and you need to check what it is. Although there are three things it could be, you're only likely to have either acpiapic_mp (multiprocessor) or acpiapic_up (uniprocessor) which should answer that for you.  ZX81    talk  18:33, 21 March 2011 (UTC)


 * My registry doesn't quite match what you describe. I have two branches:

HKEY_Local_Machine\System\CurrentControlSet001\Enum\Root\ACPI_HAL\0000 HKEY_Local_Machine\System\CurrentControlSet003\Enum\Root\ACPI_HAL\0000


 * But neither of those contains a "HardwareID". StuRat (talk) 18:48, 21 March 2011 (UTC)


 * That "2.8 GHz" should be the clock speed of each core. It'd be pretty lame to add up the clock speeds of each core, because, for most tasks, you can only use one core in the first place.  Paul (Stansifer) 15:15, 21 March 2011 (UTC)


 * Although if it really is 'a 2.8 MHz machine' I wouldn't be surprised your computer is slow. Actually I'm surprised Windows even starts. Even 95 wasn't designed for something that slow :-P Nil Einne (talk) 16:47, 21 March 2011 (UTC)


 * Yes, but making a computer sound 4X as fast as it really is would definitely be something that salesmen would do, if they couldn't be sued or arrested for it. StuRat (talk) 17:50, 21 March 2011 (UTC)


 * Go to "My Computer", "Device Manager", find the entry for the CPU and tell us what model it is. I don't know the exact sequence of icons to click but maybe some Windows user can supply that if needed. 75.57.242.120 (talk) 21:04, 21 March 2011 (UTC)


 * This ?

ACPI\GENUINEINTEL_-_x86_family_15_MODEL_2\_0


 * StuRat (talk) 01:45, 22 March 2011 (UTC)


 * That'll be why you're not getting more than one CPU then I'm afraid, that's simply not a multicore processor: http://en.wikipedia.org/wiki/Celeron#Northwood-128  ZX81    talk  02:32, 22 March 2011 (UTC)


 * How can you tell it's that model from the string I provided ? StuRat (talk) 03:10, 22 March 2011 (UTC)


 * It said Family 15, model 2 in your text string which matches up with the one in the article I linked. Also our same article says that this processor was made in speeds all the up to 2.8GHz which matches what you said at the top of this thread.  ZX81    talk  03:18, 22 March 2011 (UTC)


 * It it's 2.8 GHz on a single core, then I wonder why it's so slow ? That link says "Northwood-based Celerons suffer considerably from their small L2 cache", could that be the problem ?  One place where it's really noticeable is when I go to open or close a file, and choose a different "Save in" directory at the top.  It takes about 4 seconds to bring up the list, which seems painfully slow.  Browser web-page loading/refreshes are also slow.  My Fortran programs run quite fast in the MS-DOS command prompt window, on the other hand. StuRat (talk) 15:27, 22 March 2011 (UTC)


 * The Celerons are basically cut down versions of their bigger brothers (less performance, but cheaper), however they're not THAT slow. How much RAM have you got? From what you're describing it sounds very much like you're low on memory and you need to add more. When it's going slow and you're waiting for things to happen, is the hard drive light mainly turned on/hardly going out? If so (and the RAM figure is < 1Gb) then that'll likely be what the problem is and it's Paging to the disk as it's run out of real memory and that's considerably slower. How much memory XP "needs" seems to vary per person, but whilst a basic system will run quite happily on 512Mb (and even 256Mb!), by the time you've added some antivirus software/antispyware/firewall you're probably looking at needing 1Gb minimum to actually have some memory left to run other programs. Personally I say 1.5Gb just to be extra safe and allow some flexibility for running bigger things, but I fully expect other people to disagree with me and say that's over cautious.  ZX81    talk  19:17, 22 March 2011 (UTC)


 * Yea, that might be the problem. It lists the memory as 504 MB, which I assume is 512 less 8 for the built-in graphics board. StuRat (talk) 19:26, 22 March 2011 (UTC)
 * Filesystem operations (the "Save in" taks) are almost entirely unaffected by processor speed and cache. Hard drive speed (and, under some circumstances, memory size) is the bottleneck.  Memory size is the most important thing for user experience speed under most circumstances. Paul (Stansifer) 20:48, 22 March 2011 (UTC)

Windows hosts file
I have a installation test procedure which asks me to edit the Windows hosts file,, to add an alias for the local machine, i.e. to add a line like



It then suggests testing this by typing



at a command prompt. But it doesn't work.

It's as if the system is using some other hosts file, somewhere else. I can successfully invoke



where  is the other alias already in the hosts file. Moreover, pinging  continues to work even if I rename   so it can't be found (i.e., further suggesting that there's another hosts file somewhere else that's actually being used).

This is on what I thought was a reasonably clean installation of Windows XP.

I've tried rebooting. I've tried. Neither of these helped. I've checked, and it's indeed set to. I've used Windows Explorer to search all of  for other files named , and it didn't find any.

Anybody have any other ideas? —Steve Summit (talk) 23:17, 21 March 2011 (UTC)


 * Hmm, you're doing everything right, at least for a normal system. You don't need to run any commands, or reboot or restart the network, after changing the file: just like its unix equivalent, changes are actioned immediately (for new lookups). Some ideas:
 * you've inadvertently introduced a corrupt character (perhaps an invisible one); try putting your alias at the very top of the hosts file.
 * you're happening to use a name that's conflicting with WINS; try a different name
 * something has changed the registry key \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath (which should read %SystemRoot%\System32\drivers\etc by default) to something else - this specifies where files like host are to be found
 * -- Finlay McWalter ☻ Talk 00:21, 22 March 2011 (UTC)


 * Thanks, Finlay. I'd already checked for funky characters, and the alias in question is one that works perfectly on other machines.  (Also I've tried things like "blort" and "piffle", which don't work, either, so I'm decently sure the problem is not any kind of name clash.)  I don't know how you knew of that utterly obscure, utterly (potentially) specific to my problem, seven-level-deep registry key, and I was delighted to check it out, but... no, it's set correctly.  So still no joy. —Steve Summit (talk) 11:34, 22 March 2011 (UTC)
 * I've had the host file behave in unexpected ways as well. I always assumed it was caching results, but I'm not sure. Here's a tangential discussion: on the issue. Here's Microsoft's discussion of the host file, which might give you some insights . Shadowjams (talk) 20:06, 22 March 2011 (UTC)

Well, I finally got it working. In the end, the problem was evidently some combination of (Oddly, I find that I can't say for certain which of these things actually made the difference, because when I tried reenabling them in various combinations, I couldn't get it to reliably fail again! Partly this was because once there's been a success, the successful result is cached.  I tried using   after every change, and I still couldn't get it to fail reliably.  But at least it's working now!) —Steve Summit (talk) 14:50, 25 March 2011 (UTC)
 * a blank line in the file (between the boilerplate comment at the top, and the  line)
 * the file being non-world-readable
 * the file having the execute bit set