Other

  • The Old New Thing

    Justifiable assault with folding chair

    • 23 Comments

    Everybody's lunchtime conversation a few days ago was the riot at a used laptop sale in Richmond, VA. [Local coverage.] What got me was this fellow Jesse Sandler:

    "I took my chair here and I threw it over my shoulder and I went, 'Bam,'" the 20-year-old said nonchalantly, his eyes glued to the screen of his new iBook, as he tapped away on the keyboard at a testing station.

    "They were getting in front of me and I was there a lot earlier than them, so I thought that it was just," he said.

    Because if somebody cuts in front of you in line, you are perfectly justified in assaulting them with a folding chair. That's one of the guiding principles this country was founded on.

  • The Old New Thing

    Let's just make up some dollar values and print them as fact

    • 35 Comments

    Everybody is going nuts over a patent decision regarding the iPod interface, but that's not what I'm writing about (so don't ask me for my opinion). Rather, I'm reacting to the claims being made by many people that Apple will have to pay Microsoft $10 for every iPod.

    What I want to know is where this amount "$10" came from.

    Multiple people are confidently reporting a sawbuck as the amount in question. GeekCoffee attributes it to AppleInsider.com, but a search of AppleInsider turns up no article where they assigned a monetary value to the issue. A site called TrustedReviews repeats the $10 price tag with no source. ("You don't need a source. Just trust us!") MacNewsWorld even puts the amount in its headline, although the article gives no justification for how they arrived at it. Sky News helpfully converts the amount to £6 but again provides no source for this value.

    Are people just making up stuff and publishing it as fact? Or is there some root source for this $10 amount that I'm missing and which nobody is bothering to cite? (My suspicion is that one person took a wild guess and everybody else decided to run with it.)

  • The Old New Thing

    What are the access rights and privileges that control changing ownership of an object?

    • 11 Comments

    Changing the ownership of an object (typically a file) is not difficult in principle: You call the SetNamedSecurityInfo function with the new security descriptor.

    The hard part is getting to that point. (Thanks to John, a colleague in security, for correcting an earlier draft of this entry.)

    If you have WRITE_OWNER access on an object, then you can change the owner of the object to yourself (or to any SID in your token that has the SE_GROUP_OWNER attribute): you can take ownership. However, you cannot change the owner to somebody else: you cannot give ownership to another person. Doing that would allow you to violate quota restrictions.

    Imagine if this were possible, that you could change the ownership to something that you aren't a member of: Your account is at its disk quota. No problem, you just find somebody who isn't over quota (like Fred in Accounting) and take some of your biggest files and set their owner to Fred. This causes the disk space to be charged to its new owner Fred, without Fred even knowing that it has happened to him. If you put the file in a directory that Fred doesn't have access to, poor Fred will start getting "You are over disk quota" messages and have no way of finding this evil file that you charged to him. It's like stealing somebody's library card and checking out books with it.

    In order to set the owner to somebody else, you need to assert SeRestorePrivilege, which by default is assigned to administrators and backup operators. Backup operators need to be able to set the owner to somebody else because restoring its security descriptor is an important part of the process of restoring a file from backup.

    But what about SeTakeOwnershipPrivilege? That privilege is assigned to administrators, and it lets you act as if you had WRITE_OWNER access (but not SeRestorePrivilege) to everything. With SeTakeOwnershipPrivilege, you can take ownership of any file, but you can't assign it to somebody else.

    And then there's the mysterious CREATOR_OWNER SID, described in a Knowledge Base article as well as in a blog entry by Larry Osterman. The important thing to remember is that granting CREATOR_OWNER SID to an object after it has been created doesn't actually grant anything to the creator or owner. Read the linked articles for more details.

  • The Old New Thing

    What I'll be doing at this year's PDC

    • 6 Comments

    I will be heading down to Los Angeles the Friday before the PDC in order to visit friends and relatives and to check out the King Tut exhibit at the Los Angeles County Museum of Art. The last time Tutankhamun came to the United States was back in the late 1970's. I was an elementary school student and a few of my classmates were lucky enough to have obtained tickets to the exhibition; they gave it rave reviews.

    I will show up at the Convention Center when the PDC proper begins on Tuesday. I am officially scheduled to be in the Fundamentals Lounge from 11:30am to 2:30pm on Tuesday, then again on Thursday all day after my talk. Unofficially, I plan to be in the Fundamentals Lounge pretty much the entire time, though I may step out every so often to check out the exhibitors' booths and hands-on labs, to eat, or just to tease the people in the other lounges.

    What this means for you is that if you have something you want to discuss with me, you can just drop in the Fundamentals Lounge and there's a good chance I'll be there. No need to make an appointment. Don't be afraid to approach me; if I didn't want to be disturbed I'd have stayed in my hotel room! If I'm not around, you can call the main Microsoft switchboard +1-425-882-8080 and ask for me, and the call will be forwarded to my mobile.

    As for my talk, it will be in the style of a lecture, so there will be no slides. Slides will be provided in the handouts for completeness, but I won't use them. I'm told the talk will be recorded, and it is my understanding that the post-conference DVD will contain copies of every talk, so those of you who attend will be able to re-live the excitement in the comfort of your very own cubicle. (And to pre-empt the inevitable follow-up question: The PDC team own the recording of my talk, so don't ask me if I can make a copy available. It's not mine to give out.)

    One consequence of giving a lecture-style talk is that I will be using a Tablet PC as a sort of electronic chalkboard. There's one catch, though: I don't own a Tablet PC myself. I'll try to borrow one from a colleague for my talk, but in the worst-case scenario, I may get up on stage and ask to borrow one from an audience member. (Downside of loaning me your Tablet PC: You can't take notes on your Tablet PC during the talk. Upside: You get a copy of all the notes and diagrams!)

  • The Old New Thing

    How can a company get access to Windows Error Reporting data?

    • 38 Comments

    What happens to all the crashes in programs not written by Microsoft that are submitted via Windows Error Reporting? Microsoft still collects and indexes them, and vendors can sign up to gain access to the error reporting database to see the crashes in their programs. The service is free, although it does require a Verisign ID so that the Winqual system can confirm that you are who you claim you are. (It would be bad if somebody could pretend to be, say, Adobe, and get all their crash data.)

    There will be a session at the PDC which will go into how you the software developer can take advantage of all this data in order to improve your product from pre-release through general availability and even into sustained engineering.

    Windows Vista: Improving your Products Code Quality through Windows Feedback Services

    Your customers are sharing their pain and product experiences with you. Are you listening? Learn how to use the updated automated feedback mechanisms in Windows to gather, view and act upon customer Feedback data. Windows Feedback data will enable you to improve quality early in your product cycle, prioritize work and fix problems your users are encountering on a daily basis; even lower your support costs while increasing customer satisfaction and reliability of your applications.

    Yes, it's a kind of boring title. The original title was "Turning dissatisfied customers into gold". I would've used something like "Your program is crashing. Are you listening?" Oh well, the title isn't important. What's important is that you can use this information to make your products better.

  • The Old New Thing

    Have you made any assignments in this space?

    • 35 Comments

    Riffing on Larry's profound distaste for the use of the word 'ask' as a noun (a distaste I share)...

    It's been three years since I heard the question "Have you made any assignments in this space?" during a meeting and I still don't know what the person was trying to say.

  • The Old New Thing

    Does Windows have a limit of 2000 threads per process?

    • 30 Comments

    Often I see people asking why they can't create more than around 2000 threads in a process. The reason is not that there is any particular limit inherent in Windows. Rather, the programmer failed to take into account the amount of address space each thread uses.

    A thread consists of some memory in kernel mode (kernel stacks and object management), some memory in user mode (the thread environment block, thread-local storage, that sort of thing), plus its stack. (Or stacks if you're on an Itanium system.)

    Usually, the limiting factor is the stack size.

    #include <stdio.h>
    #include <windows.h>
    
    DWORD CALLBACK ThreadProc(void*)
    {
     Sleep(INFINITE);
     return 0;
    }
    
    int __cdecl main(int argc, const char* argv[])
    {
    int i;
     for (i = 0; i < 100000; i++) {
      DWORD id;
      HANDLE h = CreateThread(NULL, 0, ThreadProc, NULL, 0, &id);
      if (!h) break;
      CloseHandle(h);
     }
     printf("Created %d threads\n", i);
     return 0;
    }
    

    This program will typically print a value around 2000 for the number of threads.

    Why does it give up at around 2000?

    Because the default stack size assigned by the linker is 1MB, and 2000 stacks times 1MB per stack equals around 2GB, which is how much address space is available to user-mode programs.

    You can try to squeeze more threads into your process by reducing your stack size, which can be done either by tweaking linker options or manually overriding the stack size passed to the CreateThread functions as described in MSDN.

      HANDLE h = CreateThread(NULL, 4096, ThreadProc, NULL,
                   STACK_SIZE_PARAM_IS_A_RESERVATION, &id);
    

    With this change, I was able to squeak in around 13000 threads. While that's certainly better than 2000, it's short of the naive expectation of 500,000 threads. (A thread is using 4KB of stack in 2GB address space.) But you're forgetting the other overhead. Address space allocation granularity is 64KB, so each thread's stack occupies 64KB of address space even if only 4KB of it is used. Plus of course you don't have free reign over all 2GB of the address space; there are system DLLs and other things occupying it.

    But the real question that is raised whenever somebody asks, "What's the maximum number of threads that a process can create?" is "Why are you creating so many threads that this even becomes an issue?"

    The "one thread per client" model is well-known not to scale beyond a dozen clients or so. If you're going to be handling more than that many clients simultaneously, you should move to a model where instead of dedicating a thread to a client, you instead allocate an object. (Someday I'll muse on the duality between threads and objects.) Windows provides I/O completion ports and a thread pool to help you convert from a thread-based model to a work-item-based model.

    Note that fibers do not help much here, because a fiber has a stack, and it is the address space required by the stack that is the limiting factor nearly all of the time.

  • The Old New Thing

    On paying for your meal upon leaving a restaurant

    • 14 Comments

    Robert Scoble's embarrassment over forgetting to pay a restaurant bill reminds me of an even more embarrassing incident experienced by a component team from the Windows 95 team.

    To celebrate something or other, their team went to lunch at The Salish Lodge, a fine dining establishment. At the end of the meal, everybody thought somebody else was going to handle the bill, and they all walked out as a group. The administrative assistant who made the reservation received a somewhat concerned telephone call from the restaurant when they discovered that a large party just skipped the check. Profuse apologies were extended and the bill was settled over the phone (with what I assume was a very generous tip). I just happened to be in the hallway when this whole thing happened and got to hear the story from the very exasperated administrative assistant shortly after it transpired.

    So remember, folks: Pay the bill before leaving the restaurant. It saves everybody a lot of grief.

  • The Old New Thing

    Watching the game of "Telephone" play out on the Internet

    • 21 Comments

    Let's see if I can get this straight.

    First, Chris Pirillo says (timecode 37:59) he's not entirely pleased with the word "podcast" in Episode 11 of This Week in Tech. The Seattle-PI then reports that the sentiment is shared with "several Microsoft employees" who have coined the word "blogcast" to replace it. Next, c|net picks up the story and says that the word "podcast" is a "faux-pas" on Microsoft campus. [Typo fixed: 9am]

    In this manner, a remark by someone who isn't even a Microsoft employee becomes, through rumor, speculation, and wild extrapolation, a word-ban at Microsoft.

    Pretty neat trick.

  • The Old New Thing

    When Marketing edits your PDC talk description

    • 23 Comments

    A few years ago, I told a story of how Marketing messed up a bunch of PDC slides by "helpfully" expanding acronyms... into the wrong phrases. Today I got to see Marketing's handiwork again, as they edited my talk description. (Oh, and psst, Marketing folks, you might want to link to the full list of PDC sessions from your Conference Tracks and Sessions page. Unless, of course, y'know, you don't want people to know about it.)

    For one thing, they stuck my name into the description of the talk, thereby drawing attention to me rather than putting the focus on the actual talk topic. Because I'm not there to be me. I'm there to give a talk. If I were just there to be me, the title would be "Raymond Chen reads the newspaper for an hour while listening to music on his headphones."

    (That's why I don't do interviews. Interviews are about the interviewee, and I don't want to talk about me. People should care about the technology, not the people behind it.)

    They also trimmed my topic list but stopped before the punch line.

    ... asynchronous input queues, the hazards of attaching thread input, and other tricks and traps ...

    The punch line was "... and how it happens without your knowledge." After all, you don't care about the fine details of a feature you don't use. The point is that it's happening behind your back so you'd better know about it because you're using it whether you realize it or not.

    They also took out the reference to finger puppets.

Page 81 of 94 (936 items) «7980818283»