Will Pervasive Multithreading Make a Comeback? 657
exigentsky writes "Having looked at BeOS technology, it is clear that, like NeXTSTEP, it was ahead of its time. Most remarkable to me is the incredible responsiveness of the whole OS. On relatively slow hardware, BeOS could run eight movies simultaneously while still being responsive in all of its GUI controls, and launching programs almost instantaneously. Today, more than ten years after BeOS's introduction, its legendary responsiveness is still unmatched. There is simply no other major OS that has pervasive multithreading from the lowest level up (requiring no programmer tricks). Is it likely, or at least possible, that future versions of Windows or OS X could become pervasively multithreaded without creating an entirely new OS?"
I hope so (Score:4, Interesting)
Another cool operating system to check out is MenuetOS [menuetos.net]... it is written entirely in Assembly! Very fast boot times and the GUI and eevrything fits easily on a floppy!
Threading isn't any easier when it is pervasive (Score:5, Interesting)
However, taking only a few cycles to spin up or kill a thread (rather than the 10,000 plus it takes Windows), or perform a context switch, is a significant help. (There used to be an interesting article benchmarking those things on the Be website, but I can't find it any more).
MS have also added some more interesting stuff to the scheduler in Vista, which helps with uninterrupted sound or movie playback, so at least some of that stuff is possible without a complete redesign.
Not gonna happen on Mac until... (Score:1, Interesting)
The AppKit docs are riddled with notes like "on the main thread" or "some thread will receive this notification". Maybe Leopard will change that.
BeOS rocked! (Score:4, Interesting)
Re:No Maybe Yes (Score:3, Interesting)
Re:It makes sense with multi-core cpus (Score:4, Interesting)
Tried (for Windows) and killed (Score:5, Interesting)
Yes (Score:5, Interesting)
I'm a CS grad student at the University of North Carolina. I've never used BeOS, but I'm confident that responsiveness will increase, because the work I'm doing right now is attended to address this very issue.
The thing that makes multi threaded programming so difficult is concurrency control - it's extremely easy for programmers to screw up lock-based methods, deadlocking the entire system. The are newer methods of concurrency control that have been proposed, and the most promising method (in my opinion) is 'Software Transactional Memory' which makes it almost trivial to convert correct sequential code to code that is thread-safe. Currently, there are several 'High Performance Computing Languages' in development, and to my knowledge, they all include transactional memory.
The incredible difficulties involved in making chips faster are precipitating a shift to multicore machines. The widespread prevalence of these machines, coupled with newer concurrency control techniques will undoubtedly lead to an increase of responsiveness.
Re:Question... (Score:3, Interesting)
Also BeOS the company didn't respond at all to my requests for help with this. They provided zero technical support to me. Emails went unanswered.
Maybe BeOS had some nice architecture, but there is more to an OS than its handling of threads - much, much more, and I think that BeOS was not even close to ready for prime time. And the developers clearly had glossed over many aspects of an operating system (such as the aforementioned error diagnostics) to get to the pretty demos that the OS was capable of.
Re:I hope so (Score:3, Interesting)
I distinctly remember thinking that it was very, very much like Windows in this regard. Linux was awesome because the operating system could give you a wealth of information about what it was doing, so that if you put time into it, you could diagnose and fix pretty much any problem. The tools were there for you. With BeOS and Windows, where the tools and logging would be, was simply a big empty void. There was nothing you could do if your hardware was not perfectly supported. You could not figure out what was wrong. The operating system had no facilities to support any kind of diagnosis of the problem.
I never expected BeOS to support every piece of hardware out there. But then again, I *did* expect it to, since it was such a new and unsupported OS, provide tools to the user to let them solve problems. But BeOS didn't, and for this reason, I think that it was not a very good OS. Sure it had nice pretty demos, but I'm guessing that Be the company focused all of their efforts on the code paths necessary to enable the pretty demos, and left all of the other critically useful (and underrated) aspects of the operating system unimplemented.
Perhaps with enough time, they could have addressed that. But BeOS, as it was, was only a cute toy, in my opinion.
Re:Yes...well, maybe eventually... (Score:4, Interesting)
If/when the CPU designers currently screaming "more threads, more threads!" at us coders get around to implementing efficient h/w transactional memory, painless fine grain parallelism may become a reality. Until then, STM may be fine for very large applications on systems with huge memories and lots of cores, but probably isn't an option for the average desktop.
But STM does present some intriguing possibilities for distributed parallel environments (think STM + DSM).
Re:Yes (Score:2, Interesting)
Re:Puh-lease (Score:3, Interesting)
What you say may have been true some years ago. Nowadays Linux is far more advanced technically than Windows with respect to multi-threading and even more multi-processor / multi-core support.
E.g. gcc does thread-safe initialization of local static variables -- Visual C++ does not. Linux runs on up to 4096 processor machines -- Windows does not. Linux can be run tickless (to some extend) -- Windows can be not. Linux has support for the SUSv3 realtime API with support for nanosecond resolution timers -- Windows has nothing comparable. Linux will shortly have the new completely fair scheduler (CFS) were a user reported that the system is still quite usable with 32k busy threads running in parallel -- Windows would be not.
Re:Multithreaded won't be optional any more. (Score:4, Interesting)
Are you serious? The idea is to have all your programs running all the time, and interact with them whenever you want with instantaneous response. Not to mention that most apps people run nowadays either are servers (P2P, LAN Shares, etc), clients that sit around listening to servers (IM) or querying them with frequent regularity (Email Client). And the progression is towards having personal servers that you can connect to using either a local or remote client.
The next generation of computing is going to come from the vast multitude of developers who are accustomed to writing client-server applications applying what they know to computers that behave like a server cluster. They are better equipped to approach the problems and rewards of this architectural progression than the guy who has been working in the traditional application space. Now, that's a generalization that's full of exceptions, but it'll be still be proven true on the wider scale.
Re:Multithreaded won't be optional any more. (Score:3, Interesting)
There is no reason to add support for SMP machines to any program that only uses a fraction of a single core's power. If you're doing something in the background then it might be worth spawning off a worker thread to keep the UI responsive, but most other things are better handled with co-routines, which are much easier to reason about (hence the fact that pretty much every GUI toolkit uses some form of them).
When you are not performing embarrassingly parallel computations, threads aren't such a good idea, since you end up with a lot of synchronisation issues that can be avoided by moving to an asynchronous model such as that used by Erlang.
Re:We had different programmers 10 years ago (Score:4, Interesting)
Was it more cost effective to have a programmer recode it in C (which includes the required maintenance) or use the less optimal but easier to maintain VB COM? I'm all for using C over C#, Java, and VB, but sometimes you need to look at the situation from a business standpoint.
Re:Question... (Score:5, Interesting)
This is good, I like this political stuff:
MS-DOS 1.0 was Herbert Hoover, aloof to the problems of the common man but friend of the engineer in all of us. Also discovered Transformers.
Mac OS 7-8-9, all Franklin Roosevelt, very competent, lead us through difficult times, but left a legacy of programs which have become quite a mixed bag.
Windows 3.1, Dwight Eisenhower, amiable enough, competent, but leaving historians (and many contemporaries) very wanting.
Windows 95 thru ME, Lyndon Johnson, one of the boys, very able at getting things done, but in the end a disaster, rightfully ceding his throne.
Windows NT, Richard Nixon, the archetypal back-room politician, ruthless, and ultimately brought down by little faults, but many believe he was a great president and did much to modernize the Republican Party.
Windows XP, Ronald Reagan, everybody who hates him never met him, he could charm anyone, the Great Communicator. Bought Iranian weapons for contras with drug money.
Mac OS X, Bill Clinton, cheerful and smart, if not the most productive. Known for his speeches.
Re:I don't get it (Score:1, Interesting)
> You mean--like every one? Beagle uses it, and so does Nautilus. It's been there for a number of years.
It's ok. Too bad there is no recursive directory support in inotify. Software has to add a watch for every subdirectory of a tree it wants to monitor.
Microsoft decided against responsiveness (Score:2, Interesting)
Microsoft realized this early on and put a bunch of barriers into windows (and more so into MFC) that are designed to prevent programmers from even writing multithreaded GUIs.
Let me make this clear. If you call an MFC gui routine from a thread other than the main GUI thread it will return without executing. If you "send" or "post" a message to a control from the wrong thread using the MFC versions of send() and post(), it will return without doing anything. Microsoft used thread local memory to prevent programmers from being able to write multi-threaded GUIs.
I've programmed work-arounds many times with user-messages and created programs that were as responsive as BEOS programs. Understand that the fact that most programs' guis lock up for a few seconds when opening files, etc. is the result of MS' decision to not trust programmers with multithreading the GUI.
I've also worked on multiprocessor, high performance server apps, and I know how obscure multithreaded techniques are, and how small mistakes can make software unreliable. I don't entirely blame MS for preferring reliability to responsiveness, but they are in a position where they could educate rather than restrict, and they chose restricting.
Re:We had different programmers 10 years ago (Score:3, Interesting)
Concurrent Euclid? Dude, where did you go to school? U of T? In the 80s?
I had the distinct pleasure of having Jim Cordy as a prof when I was an undergrad in the 90s. In particular, studying compilers with the man was the single most
Actually, thinking back to the days reminds me of a funny story I haven't thought about in about a decade. I was taking first year computer science. There was a fellow in my class, smart guy, good C coder.. couldn't see the forest for the trees. In fact, he still owes me a pair of Sony headphones he borrowed about a thousand years ago. Anyhow. He stood up in class one day and asked Cordy something like "What kind of an IDIOT would design a language like TURING?".. "Well, Mr xxx... that idiot would be me".
Haha hahaha
I kind of miss being in school.
But I don't miss stats.
I do miss forging usenet control messages.
Too bad you can't do that any more. Kids are missing so much nowadays!
Re:Yes...well, maybe eventually... (Score:4, Interesting)
As far as performance the key here is compiler design. Sure in the fully general case STM may be fairly resource intensive but most cases aren't the general case. The hope is that compilers can be improved to natively support STM and recognize where simplifying assumptions can be made.
In other words practical STM is a way to get the compiler to meet the programmer halfway. Compilers can't do auto-parrililization and won't be able to anytime in the foreseeable future but having programmers deal with very low level constructs like locks and semaphores is confusing and a waste of time. This is a nice comprimise to meet in the middle. At least as long as it is used correctly.
Re:I don't get it (Score:4, Interesting)
So what? Why do you want to put more functionality into the kernel than necessary? You can write user-mode code around inotify for recursive watches--Beagle does just that. If enough people wanted it, it could be wrapped up as a library.
Re:It makes sense with multi-core cpus (Score:2, Interesting)
Re:It's the I/O, stupid (Score:2, Interesting)
I've made work around classes to fix that so that it's only a few key strokes in C++ to chain (ie call) a routine that doesn't run in the current (GUI) thread, it runs in a work thread, and to chain back to a completion routine in the gui when its finished.
It works like a charm, and programs can be completely responsive 100% of the time, like BEOS, I suppose. You can be loading a file, and still the menu works and you can move around the subwindows and edit them... And if a window is recalculating, it's still responsive during that - and it redraws the new data, when done.
You have to specifically decide what the program can do and not do while it's calculating, and code that. So there is more work in keeping a program responsive. You have to code for responsiveness.
Way off-topic (Score:3, Interesting)
There's a sign hanging in the restroom here at work, and I just realized it was a haiku.
Isogutomo
kokoro shizukani
te wo soete
soto ni kobosuna
-Matsutake no Tsuyu
Even when hurried
Quiet your heart
Steady with your hand
And don't spill any on the outside
-Mushroom Dew
Beautiful, isn't it? The English version just says, "We aim to please, so please aim."
Rose-tinted hindsight... (Score:4, Interesting)
BeOS showed no exceptional capabilities. Both Rhapsody and NT were easily able to run multiple concurrent applications without slowdown, and BeOS was at least as often bottlenecked on I/O.
BeOS was certainly a competent OS design, but the "remarkable" performance was only remarkable when it was compared with the classic Mac OS and mainstream Windows 9x. With those as the "competition", the legend of BeOS has grown over the years, but any contemporary preemptive multitasking OS could do as well.
Re:It makes sense with multi-core cpus (Score:3, Interesting)
I assume those 8 movies are all small so they all fit in memory and don't let the hard drive become the bottleneck, and low-resolution so they don't engage the tilt bits [auckland.ac.nz]? Vista may be a bit faster than XP, but that doesn't make it a useful operating system for people who want to go where they want to today, rather than go to whichever sandbox Microsoft has approved today.
That being said, I've had multiple HD resolution videos running on my Linux laptop and desktop, flawlessly, on multiple Beryl cube sides. Vista isn't faster than Linux in any meaningful measure, and is slower in many instances because of it's insistence on DRM and encryption over INTERNAL BUSES.
Re:I don't get it (Score:3, Interesting)
>So what? I can launch 20 applications simultaneously in Linux and have them running in a snap;
Well, I'm using Linux everyday at work, and I tell you: it doesn't feel responsive.
I played with BeOS (quite some time ago now) and it felt smooth, quick, reactive (on a PC ten time less powerful).
> that just isn't a big deal. Whether the OS stays responsive and fast depends on the apps.
Sure, if you ported FF to BeOS, it would suck as much on BeOS as it sucks on the other OS, that's true, but it's also true that using BeOS and its application felt responsive because they designed the applications which came with the OS, the toolkits, the programming guides this way, whereas using Linux or Windows don't feel responsive, and IMHO *this is* a big deal.
>If you launch Firefox, [..] simultaneously on BeOS, I guarantee you it would also bring it to its knees.
The thing is, you can bring an OS to 'its knees' while still making it 'responsive', and the video showed it quite well.. I remember another video where they overloaded the computer so that video rendering was stuttering, but the interface was still smooth, that's a priority issue and BeOS was nicely tuned for desktop load.
>But everybody uses Firefox because, in the end, it's still fast enough.
Well, I started using Opera because I don't think that FF is responsive enough. I don't understand why FF has a bigger marketshare than Opera: I think that Opera is better than FF.
Currently I'm using 50% FF and 50% Opera because I cannot stand Opera's weird tab management scheme (which cannot fully emulate FF tab management), but as soon as they fix this, I'll gladly drop FF until it becomes responsive (I'm not holding my breath)..
Re:It makes sense with multi-core cpus (Score:3, Interesting)
Oh yeah, and if there are lots of wait states in your program so that most of your threads are idle most of the time, it doesn't matter how many cores you have.
Re:Coming to Mac OS 10.5 (Score:2, Interesting)
Take the time. It's worth it. It's not like they will become useless in the meantime. While they are learning the new system they can apply it where possible (simpler projects) and continue using the old one to do real work. Then the next generation will come along, having been immersed in it from the beginning, and we can all move on for great justice.
Even Linux, as a new take on Unix, has avoided many of the classic UNIX mistakes and achieved great things that none of them ever touched; it's running on damned near everyone's hardware - they're putting it there themselves! And it's running on cellphones, cameras, etc etc. (Some guys who had designed a digital camera that I met at a job fair told me that they had based it on a uSparc processor, but they didn't tell me what OS it ran...) :)
Anyway, yes, we should just get the hell over it and move on. It's past time. Easy to say, hard to do, absolutely necessary.