The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
A short puzzle about heap expansion
At the 2008 PDC, somebody stopped by the Ask the Experts table with a question about the heap manager. I don't understand why the heap manager is allocating a new segment. I allocated a bunch of small blocks, then freed nearly all of them. And then when my program makes a large allocation, it allocates a new segment instead of reusing the memory I had just freed. Under the classical model of the heap, the heap manager allocates a large chunk of memory from lower-level operating system services, and then when requests for memory come in from the application, it carves blocks of memory from the big chunk a...
What happens to the contents of a memory-mapped file when a process is terminated abnormally?
The same thing that happens when the handle is leaked.
He bought the whole seat, but we only needed the edge
After the Windows 95 project was released to manufacturing, but before the launch event itself, the team finally had a chance to relax and unwind after many years of hard work. The project manager decided to have a morale event to get everyone together to do something fun. A typical morale event might be going to see a baseball game, renting out a movie theater to watch the latest action flick, or something as simple as a picnic or a softball game. But this time, the project manager decided to do something different, something wild, something crazy, something everybody would talk about for days: He bought ...
Why doesn't TryEnterCriticalSection try harder?
Bart wants to know why the gives up if the critical section is busy instead of trying the number of times specified by the critical section spin count. Actually, there was another condition on the proposed new behavior: "but does not release its timeslice to the OS if it fails to get it while spinning." This second condition is a non-starter because you can't prevent the operating system from taking your timeslice away from you. The best you can do is detect that you lost your previous timeslice when you receive the next one. And even that is expensive: You have to keep watching the CPU cycle counter, and if...
Our legal department suggests you skip our salad dressing and just eat an avocado
Strange fine print.
Why can't I get my regular expression pattern to match words that begin with %?
A customer asked for help writing a regular expression that, in the customer's words, matched the string when it appeared as a standalone word. One of the things that people often forget to do when asking a question is to describe the things that they tried and what the results were. This is important information to include, because it saves the people who try to answer the question from wasting their time repeating the things that you already tried. That last entry was just to make sure that the test app was working, a valuable step when chasing a problem: First, make sure the problem is where you think it...
Email tip: When asking for help with a problem, also mention what you've already tried
When you ask a question, you should also mention what steps you've already taken when attempting to solve it on your own. First of all, it saves the people who decide to help you with your problem from exploring lines of investigation which you've already tried (and which you know don't work). "I tried setting the timeout to 60 seconds before issuing the call, but it still failed with the error ." Second, it cuts down on noise on the discussion list. — Try setting the timeout to a higher value. "I already tried that; it didn't work." Third, it demonstrates that you cared enough about the problem to try...
Email tip: When you say that something didn't work, you have to say how it didn't work
I illustrate this point with an imaginary conversation, inspired by actual ones I've seen (and, occasionally, been a frustrated party to). From: X I want to do ABC, but I don't have a DEF. Anybody know of a workaround? Somebody has an idea: From: Y Try mounting this ISO file into a virtual machine and trying the ABC from there. Unfortunately, it didn't work: From: X I tried that, but it didn't work. Any other ideas? When somebody suggests a troubleshooting step or a workaround, but when you try it and it doesn't work, you need to say how it didn't work. The person who made the suggestion had...
The difference between your job and your hobby
There was an internal discussion about what Microsoft employees should be doing that do not directly relate to their job responsibilities, such as what text editor programmers should be using to write and edit code. Should anybody who uses a programming editor other than Visual Studio be branded a traitor? How about somebody who prefers a smartphone made by a certain Cupertino company? (And for some reason, this discussion took place on the Microsoft bloggers mailing list, because many people consider it a mailing list whose members are bloggers, as opposed to a mailing list for discussing blogging. I happen to...