Slashdot Mirror


Fundamentals Of Multithreading

Bob Moore writes "SystemLogic has got a very thorough article on multithreading. Deals with Amdalh's Law, Latencies and Bandwidth, On-Chip Multiprocessing, Course-Grained Multithreading, Fine-Grained Multithreading, Simultaneous Multithreading, and Applications Of Multithreading. This is definately a good one."

20 of 122 comments (clear)

  1. We must ban multi-threading by Anonymous Coward · · Score: 3
    We must ban multi-threading, as it is evil, and causes our poor child processes to become corrupt. Do we really want our child processes to go around crashing all the time?


    WON'T SOMEBODY PLEASE THINK OF THE CHILD PROCESSES!!!!

  2. Re:Multithreaded server by Anonymous Coward · · Score: 4

    I am the owner of SystemLogic.net, just to let you know, we officially got /.'ed. I'm trying to log in to the site now to take off a couple scripts in order to lighten the load but I can't get in.

    Just letting you guys know I'm working on it.

  3. Re:First Rule by lars · · Score: 4
    Check out Peter Buhr's excellent book (I don't think it's ever actually been published, but it's used in the undergraduate "Control Structures" course at Waterloo):

    ftp://plg.uwaterloo.ca/pub/uSystem/uC++book.ps.gz

    It approaches the subject from a more theoretical rather than applied point of view, but if you understand all of the concepts in this book you will have a better working knowledge of concurent programming than 99% of the programmers in the industry!

  4. Value of a Multithreaded Programmer by bjb · · Score: 5
    I can't tell you how many people I've worked with over the years who have either no idea on what or how to write multithreaded programs or they claim that they can, but in practice they end up writing code that isn't thread safe.

    I can say that as a programmer, my value is significantly increased by being proficient in multithreaded programming (beyond Java, FWIW). If this article sparks any interest in people, do read further and practice, practice, practice! The people that I've interviewed in the past who have a strong working knowledge of multithreading get a lot of points in my book, and I'm sure other "aware" employers do the same.

    Keep in mind, however, that just knowing how to launch a thread isn't enough. If your code isn't reentrant and thread safe, launching a thread isn't worth a damn.

    Good article... now if I could only get to it ;-)

    --

    --
    Never hit your grandmother with a shovel, for it leaves a bad impression on her mind...
  5. Course-grained multithreading? by Doctor+Memory · · Score: 4

    Is this, like, during midterms, when you're trying to study for all your classes at once?

    --
    Just junk food for thought...
  6. Server slashdotted, I'm gonna take over by PD · · Score: 4

    Based on the description of the article, I looked up some things. What can I say? Somebody modded me down, so I'm at 49, and I'm incomplete without that karma point.

    Amdahl's law

    Amdahl's law

    On chip multiprocessing

    Simultaneous multithreading

  7. Re:Multithreading Can Be a Good General Design by Lumpish+Scholar · · Score: 3

    I feel that being able to multithread code effectively in Java would make a programmer advanced in that topic.

    Here's the best book on the subject:

    Doug Lea, Concurrent Programming in Java. Second Edition: Design Principles and Patterns


    book home page

    author home page (pointer to online supplement for the book)

    at Fatbrain

    at Amazon

    --
    Stupid job ads, weird spam, occasional insight at
  8. Re:Simultaneous Multithreading? by throx · · Score: 3

    If there are more threads than register sets, you have to do normal context switching. I think 4 threads is about the limit at the moment.

    To my knowledge there are no CPUs available at the moment that do SMT. I'm not even sure if there are operating systems that support it (you need OS support to load the thread specific context of each CPU register set). The Alpha EV8 will probably be the first mainstream CPU to support it, though there were plenty of rumors that an upcoming revision of the P4 Xeon will support it as well.

    It should be noted that SMT does nothing for you if the CPU is tied down in memory stalls, thus the x86 architecture is probably going to gain the least from this as it is very register starved and hence dumps things to memory all the time. Running more threads just increases the required memory bandwidth and so you need a very fast memory system (which the EV8 has) to keep up with everything.

    --

    Fear: When you see B8 00 4C CD 21 and know what it means

  9. Re:Simultaneous Multithreading? by throx · · Score: 4

    SMT is where you have one processor core executing several threads at the same time without having to context switch. The CPU maintains state (registers and flags etc.) for each thread and can execute instructions from each thread simultaneously down different pipes. This improves throughput as you don't have the overhead of task switching and you also have a far better chance of keeping your pipes full.

    Naturally, it requires OS support for it to work, but most CPU manufacturers are looking to go this way in the near future.

    --

    Fear: When you see B8 00 4C CD 21 and know what it means

  10. Re:First Rule by be-fan · · Score: 5

    Any programming construct can be harmful. Pointers, explicit memory allocation, anything! However, if interfaces are clearly defined, and and the code is kept simple (ie. lack of feature creep, something that the "new" (GNOME, KDE, etc) UNIX guys don't seem to understand) threading is just as harmless as pointers. I'm not going to get theoretical here, but I'll give you an actual example: BeOS. Say what you will about it being dead or the company being stupid or whatever, it has a kick-ass threading implementation. The app_server regularly runs with 60+ threads and the damn thing only crashes on me when I'm playing with a kernel driver. The apps, too, are stable, even though they are forced into using multi-threading due to the GUI architecture. If you want to see why this is the case, take a look at the BeBook (the API). Every time there is a possible thread interaction, they warn you about it. Just as you have to keep memory ownership clear, you have to do the same thing for threads. Theoretical rules aside, an entire platform begs to differ with you.

    --
    A deep unwavering belief is a sure sign you're missing something...
  11. Simultaneous Multithreading? by Louis+Savain · · Score: 3

    I can't get on the site. In the meantime, can someone tell mean what they mean by "simultaneous multithreading?" It sounds somewhat redundant.

    1. Re:Simultaneous Multithreading? by Wesley+Felter · · Score: 5

      The processor doesn't switch at all; it actually runs multiple threads at the same time (hence "simultaneous") because it has a separate set of registers for each thread.

      More info: http://www.cs.washington.edu/research/smt/

    2. Re:Simultaneous Multithreading? by DivineOb · · Score: 3

      About the memory stalls. What you said is actually false. I wrote a paper that is being presented in 2 weeks on way way to use SMT to attack memory stalls. You can view it here http://www-cse.ucsd.edu/users/tullsen/isca2001.pdf

      --

      I must burn in hell, suffer and pay for my sins
      But Gods the one who's losing, Satan always wins!

  12. Multithreading Can Be a Good General Design by EXTomar · · Score: 4

    The server appears to be slashdotted. Time to make up conversation while it recovers. ^_^

    Reguardless of whether your system/OS has multiple processors or can handle multiple process execution, writing your code to be multithreaded might be a good design choice. If nothing else it forces and enforces abstraction and "compartementalize" of the design and code.

    The one huge draw back to writting code that is multithreaded is the syntax baggage you must carry around and use to keep the system sane. Even in thread friendly languages Java where the language semantics try to help users write clean multithreaded code its still a non-trival thing to support. Bug can be very obscure and extremely non trival to solve in multithreaded code not to mention tools can become cumbersome(which stack am I asking for the value of "counter" on?).

    Its too bad that writing threaded code is still considered to be an "advanced coding skill".

    1. Re:Multithreading Can Be a Good General Design by jeffy124 · · Score: 3
      Last week at the JavaOne conference Allen Holub of Holub Associates gave an excellent presentation of taming java threads. Among the reasons Java's threads are though is because the spec on how they are handled is not well written. The talk was for two hours (most sessions were only one), and because of other items on my agenda couldnt stick around for the second hour, but his slides are at his website www.holub.com. I did find his first hour very intriuging in how Java implements some concepts from multi-threading.

      Its too bad that writing threaded code is still considered to be an "advanced coding skill".

      Java unfortunately makes threading so easy, it's one of it's shortcommings. Anyone can write code to take advantage of multiple threads, but without knowing exactly what's happening under the hood, unnecesssary things happen to degrade the performance on the Java VM. I know my first few multi-threaded programs in Java didnt turn out as I had hoped - performance was significantly worse than a comparable single-threaded version.

      I feel that being able to multithread code effectively in Java would make a programmer advanced in that topic.

      --
      The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
  13. Multithreaded server by Slashdolt · · Score: 3

    Perhaps if their server was multi-threaded, I'd be able to access the page...

    :-/

  14. I'd like to buy the book... by CraigoFL · · Score: 4

    ...but I'm reading Slashdot right now, and I can't do two things at once.

  15. Re:More please by plcurechax · · Score: 3
    It's not an article on Slashdot. It's just a link to somebody else's article.

    To be pendantic there is an article on /., pointing to an article on System Logic about multithreading.

    I want to see more articles on /. about technical topics, not editorials, which I feel are often poorly constructed. Whether the /. article is a "pointer" or not is secondary to me.

  16. More please by plcurechax · · Score: 4
    These are the sort of articles that I like seeing on /. Not the wind-up half-thought out "essays" that didn't get published elsewhere.

    more technical content, please.

  17. /.ed, working on it as fast as I can, can't get on by SystemLogicNet · · Score: 3

    Hey guys, just to let you know, I'm the owner of SystemLogic.net. Yeah, we got /.ed, I'm trying my best to get things up and running once again, but it's hard when you can't login to FTP, web, or telnet! I'm talking to my hosting company now to see if there's anything we can do. In the meantime, if anybody has access to a good server with PHP installed I could technically get a mirror up...dave@systemlogic.net