Welcome to MSDN Blogs Sign in | Join | Help

If somebody speaks a language I'm not expecting, sometimes I don't understand it, even though I should

During my visit to Göteborg, I booked a city tour on a tour bus. As I noted earlier, the tour is trilingual. Each point of interest is described by the tour guide three times, first in Swedish, then in English, and then in German. (Even the jokes are the same. You can tell which people on the bus speak which language by checking when they laugh at the jokes.)

I didn't know this when I got on the tour bus. I was simply expecting that the tour would be conducted in Swedish. After all, I'm in Sweden. They speak Swedish here.

The tour started, and the tour guide started by speaking in Swedish, which I sort of understood. Not great, but I got the basic idea.

And then she repeated herself in English. That was a pleasant surprise. Now I could fill in the parts that I missed from the Swedish narration.

Next, she spoke in German, but remember, I didn't know that the tour was trilingual. I just assumed she was returning to Swedish for the next part of the narration, so I thought to myself, "Wow, my Swedish suddenly sucks! I was doing so well and then boom, it's all gone!"

And then I realized, "Oh wait, that's not Swedish. That's German. I can understand this after all."

This is one of those weird language things I've noticed. The languages I learned as a child are kept in one part of my brain, and the languages I acquired as an adult go into another part. When people speak to me in a language I acquired as an adult, I don't even understand them until I first figure out what language they're using. On the other hand, the languages I acquired as a child I can understand immediately. (You can even switch languages in the middle of a sentence and I might not even notice.)

Posted by oldnewthing | 0 Comments
Filed under:

A 32-bit application can allocate more than 4GB of memory, and you don't need 64-bit Windows to do it

Commenter Herb wondered how a 32-bit program running on 64-bit Windows scan allocate more than 4GB of memory. Easy: The same way it allocates more than 4GB of memory on 32-bit Windows!

Over a year before Herb asked the question, I had already answered it in the tediously boring two-week series on the myths surrounding the /3GB switch. Here's a page that shows how you can allocate more than 2GB of memory by using shared memory (which Win32 confusingly calls file mappings). That code fragment allocated 4GB of memory at one go, and then accessed it in pieces (because a 32-bit program can't map an entire 4GB memory block at one go). To allocate more, either make the number bigger in the call to CreateFileMapping or just call CreateFileMapping multiple times.

The following week, I talked about how you can use AWE to allocate physical pages. Again, you can allocate as much memory as you like, but if you allocate enormous amounts of memory, you will probably not be able to map them all in at once.

The claims of the program are true, but 64-bit Windows wasn't necessary for the program to accomplish what it claims. It's like Dumbo and the magic feather. "Dumbo can fly with the magic feather in his trunk." Well, yeah, but he didn't actually need the feather.

(On the other hand, 64-bit Windows certainly makes it more convenient to use more than 4GB of memory, since you can map the memory into your address space all at once and use normal pointers to access it.)

Posted by oldnewthing | 1 Comments
Filed under:

The most unwanted song ever

A follow-up to why ABBA songs are so catchy: Vitaly Komar, Alex Melamid, and David Soldier developed a song scientifically engineered to be the most unwanted song ever: By their calculations, "fewer than 200 individuals of the world's total population would enjoy this piece."

Ah, opera rap.

Also check out The Most Wanted Paintings. America's Most Wanted Painting contains "an autumnal landscape with wild animals, a family enjoying the outdoors, the color blue, and George Washington."

Posted by oldnewthing | 9 Comments
Filed under:

Why does my screen go black when an emergency hibernation is in progress?

Sometime last year a customer wanted to know why the screen goes black when the system automatically hibernates due to critically low battery power. Shouldn't there be some sort of feedback to tell the user, "Hey, like, I'm hibernating, don't worry"?

The power management folks explained that they turn off the screen for a reason: They're trying to save your data while they still can. When the system gets the "Oh no, the battery is about to die!" notification from the hardware, there's no time to lose, and even less power to waste. Keeping the screen lit takes a lot of power, so turning it off might make the difference between a successful hibernation and loss of data.

Mind you, this doesn't all happen without fair warning. Before the battery goes critical, you will get a low battery warning balloon saying "Oh dear, things are getting pretty bad, you really should wrap things up before I'm forced to stop the car!"

It so happens that this particular customer had a system with a buggy BIOS that fails to notify the operating system of changes in power level with sufficient granularity. The power level went from "okay" straight to "critical" with no steps in between. As a result, Windows doesn't find out about the low battery level until it's already at critically low levels.

Note

Observe that I wrote "The power management folks explained". I am not the expert here; I'm repeating what I've heard in the interest of getting information out. Unfortunately, it looks like the the Windows Mobile PC Team Blog has gone dark, so it's not clear to me where you can ask your questions. (There is a more general site on Microsoft and the Environment, however.)

Posted by oldnewthing | 21 Comments
Filed under:

Foreign languages can be used to impede communication

One of the reasons people give for studying a foreign language is to increase the number of people one can communicate with. But what people don't mention is that foreign languages can also be used to impede communications, and that can be just as useful. (Be careful, though, because it can backfire.)

During my visit to Sweden some years ago, I was walking back to my hotel room from the Göteborg train station. I had spent the afternoon visiting the nearby city of Alingsås, whose claim to fame is that they are the birthplace of the man who introduced potatoes to Sweden, although he is probably more greatly celebrated for introducing a related process to Sweden: the technique of fermenting potatoes to make alcohol. Anyway, the reason I was there was not to learn the history of potatoes in Sweden, but rather to pay a visit to one of my Swedish readers.

Oh, wait, I was telling a story. I was walking back to my hotel from the train station, and as I crossed one of the plazas, a man approached me, speaking unaccented American English. He said, "Hey, you look Chinese. We have an organization for Chinese people, and the meetings are conducted in Swedish so you can understand!"

Okay, let's see if we can add up everything wrong with this situation.

  1. We're in Sweden, and I "look Chinese", so he decides to speak to me in English?
  2. He's speaking English in order to convince me to attend a meeting conducted in Swedish.
  3. If I'm Chinese, wouldn't "the language I can understand" be, um, say, some variation of Chinese?

I didn't feel like pointing this out to the gentleman. I just wanted to get back to my hotel, but he kept following me, repeating his spiel. I stopped and mentally enumerated the languages I knew how to speak.

  • English: Obviously he knows English. He's speaking it.
  • Swedish: We're in Sweden. There's a chance he knows Swedish.
  • German: Göteborg gets a lot of German tourists. The tourism signs and tour buses are trilingual: Swedish, English, and German. So there's a chance he knows German.
  • Chinese: Seeing as he's assuming that I'm a native Chinese speaker, yet he's speaking to me in English, it's a pretty safe bet that he doesn't speak Chinese. Especially if I pick a minority dialect.

I turned to him and said in my parents' native dialect, "I'm sorry, I don't know what you're saying."

He was apparently not expecting this, because he paused for a moment before saying "Oh, Thai people are welcome, too." I guess he took what I said and tried to map the phonemes to English and somehow came to the conclusion that I said, "I'm not Chinese; I'm Thai."

I merely reiterated my claim not to understand what he was saying and continued onward. He decided not to follow me any further.

I use this technique whenever I don't want to talk to somebody. And the trick works both ways: In Taiwan, when people try to talk to me and I'd rather not deal with them, I speak Swedish.

Posted by oldnewthing | 22 Comments
Filed under:

You can use a Coke slogan as your password, but not a Pepsi one

When Larry Osterman mentioned News Flash: Spaces are legal characters in both filenames and passwords, I was reminded of my own little experiment with passwords and spaces.

Over a decade ago, I tried using spaces in my password, and they were accepted, but I ran into a different problem: Brand name bias.

The password system accepted "Coke adds life" as my password, but it rejected "Pepsi the choice of a new generation". Why did the password system accept a Coke slogan but not a Pepsi one? Hint.

Posted by oldnewthing | 17 Comments
Filed under:

The New York Times says I'm doing it all wrong, but maybe that's for the better

Some time ago, The New York Times ran a story titled In Web World of 24/7 Stress, Writers Blog Till They Drop, which mentions that "those on the lower rungs of the business can earn as little as $10 a post."

Dude, if that's what people on the lower rungs earn, then I'm below ground level! (Nevermind that just the previous month, an article in The New York Times wrote about the business of blogging: Don't expect to get rich.)

Then again, I probably shouldn't complain, seeing as what most people took away from the article was that blogging kills.

Slate's Timothy Noah noted in his article Death by Blogging that the New York Times article employs a magic phrase which, once it appears, is a signal to the reader that the subject matter of the story is completely made up:

Give Richtel credit for admitting high up in the story that what follows is purest fancy. Newspaper reporters call these caveat-rich passages "to-be-sure grafs."

The "to-be-sure" paragraph appears as paragraph number six:

To be sure, there is no official diagnosis of death by blogging, and the premature demise of two people obviously does not qualify as an epidemic. There is also no certainty that the stress of the work contributed to their deaths. But...

It opens with the magic phrase that says "What you are reading in the remainder of this article is complete fantasy," then adds a few more statements saying that "None of what this article says is true." And then, as if to say, "Let's not let facts get in the way of a good story," it immediately resumes the fabrication with a "But..."

Posted by oldnewthing | 14 Comments
Filed under:

2009 mid-year link clearance

Time for the semi-annual link clearance.

And, as always, the obligatory plug for my column in TechNet Magazine:

Posted by oldnewthing | 18 Comments
Filed under:

Microspeak: The plan for the plan

I ran across an old document that contained a phrase I hadn't heard before:

The Plan for the Plan for the XYZ Team

Summary

XYZ is at ZBB and we are now at a recall class only bug bar until RTM. The team has also started working on a plan for a plan to address the requests made from the XYZ Leadership Team several months ago. Details of the planning ...

...

3. Bob would like a more concrete plan for a plan. Milestone breakdowns, entry/exit dates, etc...

...

Plan for a Plan

We established some deliverables to begin creating the plan for a plan:

Development/Design Code Review
Due date: Next week
Prerequisites: Dev work items

Alice will drive this to get sanity checks from other developers about overall design.

...

There's a lot of Microspeak in that snippet. We've got ZBB, recall class, deliverables, to drive, and the phrase for today: plan for a plan/the plan.

The phrase "plan for a plan" makes me think that you're trying to decide how you're going to decide what you're going to to. This is different from "early stages of planning", because when you're in the early stages of planning, you're actually planning something, even though you're still in the exploratory stage. On the other hand, planning for planning sounds like you don't even know how to plan, and you have to go learn how to do it again.

It reminds me of that Dilbert cartoon where Dilbert taunts the pointy-haired boss by suggesting that it would be rash to have a premeeting without planning it.

Posted by oldnewthing | 10 Comments
Filed under: ,

Learning to lie: Early forays

Some time ago, I was visiting a family with small children, and I found the two-year-old middle child with a marker in her hand suspiciously close to some fresh marks on the living room couch. The following conversation ensued:

"Who drew on the couch?"

My older sister.

"Your older sister isn't home."

The baby.

"The baby can't reach this."

The dog.

"You don't have a dog."

Posted by oldnewthing | 25 Comments
Filed under:

If you want to consume all the virtual address space, well, then go ahead and consume it, you don't need my help

Commenter Matthew Chaboud asks if there's an easy way to consume all the virtual address space below 4GB, short of, well, actually allocating it. "It seems like there should be a cleaner way to do this."

If you want to consume all the virtual address space, then call VirtualAlloc until you turn blue. Programs shouldn't care what address they get back from a memory allocation function; they should handle values below 2GB and above 2GB with equal facility.

It's not like there's a ConsumeAllAvailableVirtualAddressSpaceAndExhaustTheHeap function. (Is there a AllocateAllRemainingDiskSpaceAndFillExistingFilesWithZeroes function?) What would be the point of such a function? Once you call it, you have run out of memory!

If Mr. Chaboud is talking about keeping programs away from bottom 4GB of virtual address space on a 64-bit machine, then a much easier way to do this is to set the AllocationPreference configuration setting to specify that memory should be allocated from high addresses first. (But I don't think that's the scenario that prompted the original question, because on 64-bit Windows, the default heap is above the 4GB boundary, so there would be no need to exhaust the heap in order to consume the memory at virtual addresses below 4GB.)

Correction: Pavel Lebedinsky points out that the default heap is below 4GB on 64-bit machines. It used to be above the 4GB boundary on earlier versions of 64-bit Windows, but I guess they changed it.

Posted by oldnewthing | 9 Comments
Filed under:

The thread that gets the DLL_PROCESS_DETACH notification is not necessarily the one that got the DLL_PROCESS_ATTACH notification

The thread that gets the DLL_PROCESS_DETACH notification is not necessarily the one that got the DLL_PROCESS_ATTACH notification. This is obvious if you think about it, because the thread that got the DLL_PROCESS_ATTACH notification might not even exist any longer when the DLL is unloaded. How can something that doesn't exist send a notification?

Even so, many people fail to realize this. You can't do anything with thread affinity in your DLL_PROCESS_ATTACH or DLL_PROCESS_DETACH handler since you have no guarantee about which thread will be called upon to handle these process notifications. Of course, you're not supposed to be doing anything particularly interesting in your DLL_PROCESS_ATTACH handler anyway, but things with thread affinity are doubly bad.

The classic example of this, which I'm told the Developer Support team run into with alarming frequency, is a DLL that creates a window in its DLL_PROCESS_ATTACH handler and destroys it in its DLL_PROCESS_DETACH handler. Now, creating a window in DllMain is already a horrifically bad idea since arbitrary code can run during the creation of a window (for example, there may be a global hook), but the lack of a thread guarantee makes it downright insane. The DLL calls DestroyWindow in its DLL_PROCESS_DETACH handler, but since that notification comes in on a thread different from the one that received the DLL_PROCESS_ATTACH notification, the attempt to destroy the window fails since you must call DestroyWindow from the same thread that created it.

Result: The DLL's attempt to destroy its window fails, a message comes in, and the process crashes since the window procedure no longer exists.

Posted by oldnewthing | 11 Comments
Filed under:

News flash: Children are influenced by advertising

Anything in a McDonald's wrapper tastes better, according to children ages 3 to 5. Even something like carrots taste better if you put them in a McDonald's wrapper or cup.

Posted by oldnewthing | 27 Comments
Filed under: ,

First, try reading the error message, episode 2: Even programmers see error messages without reading them

I will occasionally note that users don't read error messages; they just click Cancel. And the phenomenon isn't just restricted to naïve users. Even programmers ignore error messages. All they see is "Blah blah blah an error occurred."

For example, there's this message that appeared on a peer-to-peer discussion group:

I tried to submit an update to our database and I got this error. What does it mean? Is the error on the client or the server?

Opening transaction 34508.
Locking record 14 for update.
Updating record 14 in table BLUECHEESE.
Operation failed.
write: The file or directory is corrupted and unreadable.

When I try to view the record to see whether my update made it, I get this error:

The database may be corrupt; it requires administrator attention.
To protect the database, it has been taken offline.

I'm no expert here, but it looks like a write operation failed because the file or directory is corrupted and unreadable. Since you're updating a record on the server, it's probably a corruption problem on the server. (After all, there's no change taking place on the client. The client is just asking the server to do the work.)

And the second error message seems to suggest that the database may be corrupt and requires administrator attention. As a precautionary measure, the database took itself offline so the corruption can't spread. I'm pretty sure that's a server-side thing, since the database is on the server.

Posted by oldnewthing | 22 Comments
Filed under:
More Posts Next page »
 
Page view tracker