Browse by Tags

Tagged Content List
  • Blog Post: Atomicity, volatility and immutability are different, part three

    So what does "volatile" mean, anyway? Misinformation abounds on this subject. First off, so as to not bury the lead: in C# the rules have been carefully designed so that every volatile field read and write is also atomic . (Of course the converse does not follow; it is perfectly legal for an operation...
  • Blog Post: Atomicity, volatility and immutability are different, part two

    Last time we established that an "atomic" read or write of a variable means that in multithreaded scenarios, you never end up with "halfway mutated" values in the variable. The variable goes from unmutated to mutated directly, with no intervening state. I also talked a bit about how making fields of...
  • Blog Post: Atomicity, volatility and immutability are different, part one

    I get a fair number of questions about atomicity, volatility, thread safety, immutability and the like; the questions illustrate a lot of confusion on these topics. Let's take a step back and examine each of these ideas to see what the differences are between them. First off, what do we mean by "atomic...
  • Blog Post: Read-only and threadsafe are different

    Here's a common problem that we face in the compiler realm all the time: you want to make an efficient immutable lookup table for mapping names to "symbols". This is in a sense the primary problem that the compiler has to solve; someone says "x = y + z;" and we have to figure out what "x", "y" and "z...
  • Blog Post: Careful with that axe, part two: What about exceptions?

    (This is part two of a two-part series on the dangers of aborting a thread. Part one is here .) Suppose you’re shutting down the worker thread we were talking about last time, and it throws an exception? What happens? Badness, that’s what. What to do about it? As in our previous...
  • Blog Post: Careful with that axe, part one: Should I specify a timeout?

    (This is part one of a two-part series on the dangers of aborting a thread. Part two is here .) The other day, six years ago, I was was talking a bit about how to decide whether to keep waiting for a bus , or to give up and walk. It led to a quite interesting discussion on the old JoS forum . But...
  • Blog Post: What is this thing you call "thread safe"?

    Caveat: I am not an expert on multi-threading programming. In fact, I wouldn't even say that I am competent at it. My whole career, I've needed to write code to spin up a secondary worker thread probably less than half a dozen times. So take everything I say on the subject with some skepticism. A...
  • Blog Post: Events and Races

    Here’s a question similar to one I saw on stackoverflow the other day. Suppose you have an event: public event Action Foo; The standard pattern for firing this event is: Action temp = Foo; if (temp != null) temp(); What the heck is up with that? Why not just call “ Foo() ” ? First off...
  • Blog Post: Locks and exceptions do not mix

    A couple years ago I wrote a bit about how our codegen for the lock statement could sometimes lead to situations in which an unoptimized build had different potential deadlocks than an optimized build of the same source code. This is unfortunate, so we've fixed that for C# 4.0. However, all is still...
  • Blog Post: Arrays considered somewhat harmful

    I got a moral question from an author of programming language textbooks the other day requesting my opinions on whether or not beginner programmers should be taught how to use arrays. Rather than actually answer that question, I gave him a long list of my opinions about arrays, how I use arrays, how...
  • Blog Post: Subtleties of C# IL codegen

    It must be CLR week over at The Old New Thing because it's been non-stop posts about C# lately. Raymond's last two technical posts have been about null checks and no-op instructions generated by the jitter when translating IL into machine code. I'll comment on both posts here, but I want to get the...
  • Blog Post: Human sacrifice, dogs and cats living together, mass hysteria! and thread model errors!

    Reader Shaka comments on my post about error messages that "catastrophic failure" really does take the cake as being a terrible error message. I fondly remember the first time I saw "catastrophic failure" as an error message. I was an intern, running the build lab for Visual Basic for Applications...
  • Blog Post: The Tragedy of Thread Happiness Disease

    A JOS reader interested in developing server software asked recently Is it possible to determine the number of concurrent threads a server can support from the server's specification? Now, as I've said before , I'm no expert on performance tuning multi-threaded applications, but...
  • Blog Post: Speeding Can Slow You Down

    I hope all you readers living in the United States had a restful and enjoyable Thanksgiving holiday. I sure did. I've been meaning to talk a bit about some of the performance issues you run into when tuning massively multi-threaded applications, like the ASP engine. I'd like to start off by saying...
  • Blog Post: Arrrrr! Cap'n Eric be learnin' about threadin' the harrrrd way

    Avast ye scurvy dogs, it be National Talk Like A Pirate Day! A scurvy bilge rat commented on the preceding discussion about putting apartment threaded objects in Session scope: back in the era of the NT4 Option Pack I wrote a lot of code that involved stashing Scripting.Dictionary objects in both...
  • Blog Post: Why is it a bad idea to put script objects in Session scope?

    Often a web site will have a series of related pages requested one after the other by the same user.   As a convenience for the site developers, the ASP object model provides a Session object to store server-side state for a current user.   It also has a global "Application" object which...
  • Blog Post: How does Active Server Pages use the script engines?

    It's always struck me as a little bit odd that Active Server Pages, a web server, encourages developers to use VBScript and JScript to write server-side scripts. I mean, the whole point of a web server is that it produces complex strings (web pages are just strings of HTML after all) as blindingly fast...
  • Blog Post: What are threading models, and what threading model do the script engines use?

    I've got a few ideas for some future posts that depend on the reader understanding a little bit about COM threading. Since I myself understand only a little bit about COM threading, I'll just do a brain dump for you all right here. I'm sure you all know about multi-threaded applications. The idea...
Page 1 of 1 (18 items)