January, 2012

  • The Old New Thing

    The Freudian typo that will not die: Enchanced video quality

    • 18 Comments

    While wasting time doing valuable background research on my computer, I received the following suggestion:

    For enchanced video quality, click here.

    It's good to know that the typo that I first encountered in 1993 is still alive and kicking.

    (And even though it's not important to the story, people will demand some sort of follow-up, so here it is: I submitted feedback to the vendor, who said that it was a known issue fixed in the next update.)

  • The Old New Thing

    Why does it take Task Manager longer to appear when you start it from the Ctrl+Alt+Del dialog?

    • 39 Comments

    Amit was curious why it takes longer for Task Manager to appear when you start it from the Ctrl+Alt+Del dialog compared to launching it from the taskbar.

    Well, you can see the reason right there on the screen: You're launching it the long way around.

    If you launch Task Manager from the taskbar, Explorer just launches taskmgr.exe via the usual Create­Process mechanism, and Task Manager launches under the same credentials on the same desktop.

    On the other hand, when you use the secure attention sequence, the winlogon program receives the notification, switches to the secure desktop, and displays the Ctrl+Alt+Del dialog. When you select Task Manager from that dialog, it then has to launch taskmgr.exe, but it can't use the normal Create­Process because it's on the wrong desktop and it's running under the wrong security context. (Because winlogon runs as SYSTEM, as Task Manager will tell you.)

    Clearly, in order to get Task Manager running on your desktop with your credentials, winlogon needs to change its security context, change desktops, and then launch taskmgr.exe. The desktop switch is probably the slowest part, since it involves the video driver, and video drivers are not known for their blazingly fast mode changes.

    It's like asking why an international package takes longer to deliver than a domestic one. Because it's starting from further away, and it also has to go through customs.

  • The Old New Thing

    Does mapping the same shared memory two times in a process lead to double the address space usage?

    • 19 Comments

    A customer designed a system which uses shared memory. Specifically, for each database file, they create a corresponding shared memory block of, say, 200MB. Multiple clients which connect to the same database file use the same shared memory block. Naturally, if two processes each access the same database file, each process will map the shared memory block into their respective address space. The question arose regarding what happens if one process connects to the same database file twice. Will the two calls to Map­View­Of­File share the same address space, or will each one allocate a separate chunk of address space?

    Win32 makes no guarantees what will happen. All that you can be sure of is that the memory will be mapped into your address space, and you will get a pointer to it, and when you're done, you call Unmap­View­Of­File. Whether the two calls return the same pointer is unspecified.

    In fact, Windows 95 returned the same pointer, whereas Windows NT returns a different pointer. We saw this earlier when we intentionally mapped the same shared memory block multiple times, and observed somebody actually taking a dependency on this behavior in order to effect the strangest way of detecting Windows NT. Don't take a dependency on this behavior; who knows, maybe a future version of Windows NT will consolidate multiple mappings in order to conserve address space.

    If you want force this consolidation behavior, you'll have to roll it yourself, say with a lookup table of active mappings and a reference count.

  • The Old New Thing

    The 2012/2013 Seattle Symphony subscription season at a glance

    • 5 Comments

    Every year, I put together a little pocket guide to the Seattle Symphony subscription season for my symphony friends to help them decide which ticket package they want. As before, you might find it helpful, you might not, but either way, you're going to have to suffer through it. Here's the at-a-glance season guide for the 2012/2013 season. (Full brochure. Seattle Times coverage.)

    Week Program Comments 21 13 7A
    7B
    7C
    7D
    7E
    7F
    7G 4A BS SU WG
    09/20
    2012
    Berlioz: Roman Carnival Overture
    Martinů: Symphony #6 Fantaises symphoniques
    Debussy: Nocturnes: Nuages and Fêtes
    Respighi: Pines of Rome
    Good
    Nervous
    Excellent
    Excellent
                       
    10/04
    2012
    Mussorgsky: Night on Bald Mountain
    Tchaikovsky: Rococo Variations
    Sibelius: Symphony #1
    Awesome
    Good
    Excellent
                       
    10/18
    2012
    Beethoven: Coriolan Overture
    Mozart: Sinfonia Concertante K297b
    Fujikura: Mina
    Haydn: Symphony #103 Drum Roll
    Awesome
    Excellent
    Wildcard
    Awesome
                   
     

     
     
    10/26 Sonic Evolution Wildcard                    
    11/01
    2012
    Tchaikovsky: The Snow Maiden Suite
    Tchaikovsky: Violin Concerto
    Prokofiev: Symphony #6
    Good
    Awesome
    Nervous
                       
    11/08
    2012
    Adams: Harmonielehre
    Beethoven: Piano Concerto #5
    Polarizing
    Awesome
                       
    11/15
    2012
    Brahms: Piano Concerto #2
    Dutilleux: The Shadow of Time
    R. Strauss: Till Eulenspiegel
    Awesome
    Nervous
    Good
                       
    11/29
    2012
    Berg: Violin Concerto
    Mahler: Symphony #4
    Polarizing
    Polarizing
                 
     
       
    01/10
    2013
    Stravinsky: Pulcinella Suite
    Mendelssohn: Piano Concerto #1
    Mozart: Symphony #39
    Excellent
    Excellent
    Awesome
                   
     

     
     
    01/31 Messiaen: Turangalîla Symphony Polarizing                    
    02/07
    2013
    Rossini: William Tell Overture
    Schumann: Piano Concerto
    Brahms: Symphony #4
    Awesome
    Excellent
    Awesome
                       
    02/14
    2013
    (Rossini: William Tell Overture)
    Faure: Pelléas et Mélisande Suite
    Mozart: Piano Concerto #21
    Ravel: Shéherazade
    Szymanowski: Symphony #4
    Awesome
    Good
    Awesome
    Nervous
    Nervous

     



     
     



             
     




     
    03/14
    2013
    Tippett: The Midsummer Marriage: Ritual Dances
    Bruch: Violin Concerto #1
    Elgar: Enigma Variations
    Nervous
    Awesome
    Excellent
                 

     
       
    03/21
    2013
    Mozart: Don Giovanni Overture
    Britten: Cello Symphony
    Beethoven: Symphony #5
    Awesome
    Nervous
    Awesome
                 

     
       
    03/28
    2013
    Liadov: The Enchanted Lake
    Kancheli: Styx
    Rimsky-Korsakov: Scheherezade
    Okay
    Nervous
    Awesome
                   
     

     
     
    04/13
    2013
    Mozart: Piano Concerto #9
    Bruckner: Symphony #4 Romantic
    Awesome
    Excellent
                       
    04/18
    2013
    Antheil: A Jazz Symphony
    Gruber: Percussion Concerto Rough Music
    Bernstein: On the Waterfront Suite
    Stravinsky: The Firebird Suite
    Excellent
    Okay
    Good
    Excellent
                       
    04/25
    2013
    Sibelius: Karelia Overture
    Sibelius: Violin Concerto
    Zavaro: New Work†
    Beethoven: Symphony #7
    Good
    Awesome
    Wildcard
    Awesome
                   
     


     
     
    05/30
    2013
    Smetana: Wallenstein's Camp
    Beethoven: Violin Concerto
    Dvořák: Symphony #6
    Excellent
    Awesome
    Awesome
                       
    06/13 Britten: War Requiem Nervous                    
    06/20
    2013
    Shostakovich: Violin Concerto #1
    John Luther Adams: Become Ocean
    Nervous
    Okay
                       
    06/27
    2013
    Saint-Saëns: Organ Symphony
    Wagner: Tristan: Prelude and Liebestod
    Wagner: Tannhäuser Overture and Venusberg Music
    Awesome
    Okay
    Excellent
                       
    Week Program Comments 21 13 7A
    7B
    7C
    7D
    7E
    7F
    7G 4A BS SU WG

    Legend:

    21Masterworks 21-concert series (Choice of Thursdays or Saturdays)
    13Masterworks 13-concert series (Choice of Thursdays or Saturdays)
    7AMasterworks 7-concert series A (Thursdays)
    7BMasterworks 7-concert series B (Saturdays)
    7CMasterworks 7-concert series C (Thursdays)
    7DMasterworks 7-concert series D (Saturdays)
    7EMasterworks 7-concert series E (Thursdays)
    7FMasterworks 7-concert series F (Saturdays)
    7GMasterworks 7-concert series G (Sunday afternoons)
    4AMasterworks 4-concert series A (Friday afternoons)
    BS Beyond the Score multimedia lecture-concert (Sunday afternoons)
    SUSymphony Untuxed (Fridays)
    WGWolfGang (Various evenings)
    Premiere

    For those not familiar with the Seattle Symphony ticket package line-ups: Most of the ticket packages are named Masterworks nX where n is the number is the number of concerts in the package, and the letter indicates which variation. Ticket packages have been combined if they are identical save for the day of the week. For example, 7C and 7D are the same concerts; the only difference is that 7C is for Thursday nights, while 7D is for Saturday nights. The Beyond the Score concerts focus on only one of the pieces. The WolfGang series is available only to members of the WolfGang club.

    This chart doesn't include "one-off" concert series such as the Mainly Mozart or Distinguished Artists series. A "one-off" series is a concert series which shares no concerts with any other series.

    Changes from last season:

    • The Rush Hour series was redesigned and became the Symphony Untuxed series.
    • Symphony Specials was dropped.
    • The Baroque & Wine Series and Mainly Mozart concerts still exist, but I dropped them from the table since they are now one-off series.
    • WolfGang already existed but I added it to the list now that there's room for it.

    The comments column very crudely categorizes the works to assist my less-classically-aware friends. This is, of course, a highly subjective rating system, but I tried to view each piece from the ears of my symphony friends. Thus, I rated downward pieces that I personally like but which others might not and rated up pieces that I may not find musically satisfying but which nevertheless tend to be crowd-pleasers.

    These predictions have, of course, proven wrong in the past.

    Here's what the comments mean. Note that they do not indicate whether the piece is significant in a musicological sense; they're just my guess as to whether my friends are going to like it. (For example, I know that my friends don't like minimalism, and I suspect they don't like serialism, so I rated the Adams and Berg down even though I think they're quite good. They also don't like vocal pieces. On the other hand, it turns out that I overcame my Bruckner jinx, so I can at least give the Bruckner a positive score this time. Let's just hope it's not the Hass edition.)

    • Awesome: Guaranteed crowd-pleaser.
    • Excellent: You will definitely like this piece.
    • Good: You will probably like this piece.
    • Okay: You may like this piece.
    • Nervous: I have a bad feeling about this one.
    • Polarizing: Some people will love it; others will hate it.
    • Wildcard: I have no idea what will happen.

    In many cases, I am not familiar with the piece and am basing my evaluation on what I know about the composer (or am just guessing).

  • The Old New Thing

    Why doesn't the Windows 7 Start menu have a pushpin for pinning items?

    • 31 Comments

    You may have noticed a minor inconsistency between pinning a program to the Start menu and pinning a destination to a program's Jump List. Although pinned items appear at the top of the respective lists, and both the Start menu and Jump List let you right-click an item and select Pin/Unpin, the Jump List also lets you pin and unpin an item by clicking on the pushpin. Why doesn't the Start menu have a pushpin in addition to the right-click menu?

    For a time, items on the Start menu did have a pushpin, just like items on Jump Lists. The design had a few problems, however. Start menu items can also have a triangle indicating the presence of a flyout menu, and the presence of two indicators next to an item made the interface look awkward and too busy. And what do you do if an item has only one indicator? Do you right-justify all the indicators? Or do you place the indicators in columns and reserve blank space for the missing ones?

    Internet Explorer ¤ ▶
    Command Prompt ¤
    Notepad
    Calculator  
    Internet Explorer ¤
    Command Prompt ¤  
    Notepad  
    Calculator    

    Both look ugly for different reasons. The right-justify-everything version looks ugly because the pushpin appears to keep moving around. The blank-space-if-no-flyout version looks ugly because you have a pushpin hovering in the middle of nowhere. (Imagine trying to click on one of these things: You just have to "know" that the magic click spot for pinning an item is 20 pixels to the left of the far right edge.)

    But the real death blow to showing a pushpin for pinning items to the Start menu was the usability testing. Users had trouble figuring out where to click to pin an item or to open the Jump List and frequently got the opposite of what they wanted. Since opening the Jump List is by far the more common operation, it won the battle of the prominent UI affordance, and the option for pinning and unpinning was left to a context menu.

    Which, as it happens, is where the pin/unpin option started in the first place.

  • The Old New Thing

    How do I disable the fault-tolerant heap?

    • 10 Comments

    A while back, I linked to a talk by Silviu Calinoiu on the fault-tolerant heap. But what if you don't want the fault-tolerant heap? For example, during program development, you probably want to disable the fault-tolerant heap for your program: If the program is crashing, then it should crash so you can debug it!

    Method 1 is to disable the fault-tolerant heap globally. While this prevents the fault-tolerant heap from auto-activating in the future, it does not go back and undo activations that were enabled in the past. In other words, you have to remember to do this before your application crashes for the first time.

    Therefore, you probably want to combine Method 1 with Method 2 on the same page, where it gives instructions on how to reset the list of applications for which the fault-tolerant heap is enabled.

    Mario Raccagni provides a third way of disabling the fault tolerant heap, this time for one specific process instead of globally. His explanation is in Italian, so you get to exercise your translation skills.

    tl;dr version: Go to the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER versions of Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\your_application.exe and delete the Fault­Tolerant­Heap entry.

  • The Old New Thing

    A single-handed effort to keep the memory of $2 bills alive

    • 43 Comments

    As I noted when I told the story of the computer programmer who dabbled in making change that my colleague had a lot of money-related quirks.

    For some reason my colleague felt the $2 bill deserved more attention. Every so often, he would go to the bank and buy $100 in $2 bills, then reintroduce the bills into circulation and enjoy people's reactions to them. (Most cashiers looked at it and recognized that it was legal tender, but couldn't find a good place to put it in the till. It usually got tossed under the drawer with all the checks.)

    It was a regular occurrence that the bank didn't have that many $2 bills on hand, but they managed to find them and let him know when he could come pick them up.

    One time, the bank called him back. "Hi, we asked all our branches in the entire county, but all together we can't find enough $2 bills. If you want, we can place an order with the Federal Reserve. The catch is, though, that the minimum order is $2000."

    "Sure, go ahead and place the order."

    Some time later, he went in to pick up his huge stack of $2 bills.

    My colleague now found himself in a situation where something fun turned into an ordeal, like a smoker who is forced to smoke an entire pack of cigarettes at one sitting. Or in this case, more like 1000 cigarettes.

    At the end of group meals at a restaurant, after everybody had calculated their share and put their money in the bill holder (this being the days when people actually paid cash for things), he would raid the bill holder for change, taking out all the notes greater than $2 and replacing them with the appropriate number of $2 bills. As a result, when the servers came to collect the bill holders, they found them stuffed with $1 and $2 bills (mostly $2).

    Too bad he didn't make a pad out of them.

    Bonus reading: $1 billion that nobody wants. Follow-up.

  • The Old New Thing

    Can OANOCACHE be used for non-debug purposes?

    • 14 Comments

    Friday asks whether OANOCACHE can be used for non-debug purposes, say to improve stability and/or speed.

    You can try, but it's not recommended. For one thing, it probably damages stability, because there are many applications out there which unwittingly rely on the BSTR cache to protect them from heap corruption bugs. The Windows team has for years wanted to tweak the BSTR cache (even going so far as getting rid of it entirely), but the compatibility issues always return and quash any attempts at radical restructuring.

    Identifying applications that rely on the BSTR cache and deploying an appropriate compatibility shim would be one thing. It's applications which support third party plug-ins that are the sticky point. You say, "Okay, this application is fine, we'll use the new BSTR cache behavior" and then it loads a plug-in DLL that requires the old BSTR cache behavior. Now you're stuck since you don't have a time machine.

  • The Old New Thing

    How do FILE_FLAG_SEQUENTIAL_SCAN and FILE_FLAG_RANDOM_ACCESS affect how the operating system treats my file?

    • 39 Comments

    There are two flags you can pass to the Create­File function to provide hints regarding your program's file access pattern. What happens if you pass either of them, or neither?

    Note that the following description is not contractual. It's just an explanation of the current heuristics (where "current" means "Windows 7"). These heuristics have changed at each version of Windows, so consider this information as a tip to help you choose an appropriate access pattern flag in your program, not a guarantee that the cache manager will behave in a specific way if you do a specific thing.

    If you pass the FILE_FLAG_SEQUENTIAL_SCAN flag, then the cache manager alters its behavior in two ways: First, the amount of prefetch is doubled compared to what it would have been if you hadn't passed the flag. Second, the cache manager marks as available for re-use those cache pages which lie entirely behind the current file pointer (assuming there are no other applications using the file). After all, by saying that you are accessing the file sequentially, you're promising that the file pointer will always move forward.

    At the opposite extreme is FILE_FLAG_RANDOM_ACCESS. In the random access case, the cache manager performs no prefetching, and it does not aggressively evict pages that lie behind the file pointer. Those pages (as well as the pages that lie ahead of the file pointer which you already read from or wrote to) will age out of the cache according to the usual most-recently-used policy, which means that heavy random reads against a file will not pollute the cache (the new pages will replace the old ones).

    In between is the case where you pass neither flag.

    If you pass neither flag, then the cache manager tries to detect your program's file access pattern. This is where things get weird.

    If you issue a read that begins where the previous read left off, then the cache manager performs some prefetching, but not as much as if you had passed FILE_FLAG_SEQUENTIAL_SCAN. If sequential access is detected, then pages behind the file pointer are also evicted from the cache. If you issue around six reads in a row, each of which begins where the previous one left off, then the cache manager switches to FILE_FLAG_SEQUENTIAL_SCAN behavior for your file, but once you issue a read that no longer begins where the previous read left off, the cache manager revokes your temporary FILE_FLAG_SEQUENTIAL_SCAN status.

    If your reads are not sequential, but they still follow a pattern where the file offset changes by the same amount between each operation (for example, you seek to position 100,000 and read some data, then seek to position 150,000 and read some data, then seek to position 200,000 and read some data), then the cache manager will use that pattern to predict the next read. In the above example, the cache manager will predict that your next read will begin at position 250,000. (This prediction works for decreasing offsets, too!) As with auto-detected sequential scans, the prediction stops as soon as you break the pattern.

    Since people like charts, here's a summary of the above in tabular form:

    Access pattern Prefetch Evict-behind
    Explicit random No No
    Explicit sequential Yes (2×) Yes
    Autodetected sequential Yes Yes
    Autodetected very sequential Yes (2×) Yes
    Autodetected linear Yes ?
    None No ?

    There are some question marks in the above table where I'm not sure exactly what the answer is.

    Note: These cache hints apply only if you use Read­File (or moral equivalents). Memory-mapped file access does not go through the cache manager, and consequently these cache hints have no effect.

  • The Old New Thing

    Why do Microsoft customer records use the abbreviation "cx" for customer?

    • 40 Comments

    As is common in many industries, Microsoft customer service records employ abbreviations for many commonly-used words. In the travel industry, for example, pax is used as an abbreviation for passenger. The term appears to have spread to the hotel industry, even though people who stay at a hotel aren't technically passengers. (Well, unless you think that with the outrageous prices charged by the hotels, the people are being taken for a ride.)

    For a time, the standard abbreviation for customer in Microsoft's customer service records was cu. This changed, however, when it was pointed out to the people in charge of such things that cu is a swear word in Portuguese. The standard abbreviation was therefore changed to cx.

    If you're reading through old customer records and you know Portuguese and you see the word cu, please understand that we are not calling the customer a rude name.

    The person who introduced me to this abbreviation added, "I just spell out the word. It's not that much more work, and it's a lot easier to read."

    Some years ago, I was asked to review a technical book, and one of the items of feedback I returned was that the comments in the code fragments were full of mysterious abbreviations. "Sgnl evt before lv cs." I suggested that the words be spelled out or, if you really want to use abbreviations, at least have somewhere in the text where the abbreviations are explained.

    If I had wanted to demonstrate the social skills of a thermonuclear device, my feedback might have read "unls wrtg pzl bk, avd unxplnd n unnec abbvs."

Page 1 of 4 (34 items) 1234