Can't We All Just Get Along? (Win/Mac)

JoeyBlades:

Please explain this concept… the rest of your explanation doesn’t make much sense to me without it. :wink:

Not necessarily. Each task has its own memory space, and therefore its own stack.

Also, the compiler doesn’t manage reentrancy, it only does enough to make recursive calls possible. It’s still simple to write a non-reentrant function.

I don’t see how the term reentrancy applies here… but I think, in general, it’s the driver’s job to ensure that the state remains the same. An application can open a wave output device, play a sound, and close the device, all without worrying about whether another application has interfered.

I don’t understand this part at all.

The most irritating example is that it doesn’t cede control while it’s laying out a page. With a complex page and a slow computer, this means that for several seconds or even a few minutes, the computer is completely unresponsive (even if Netscape is running in the background). The mouse moves and cmd-opt-esc works, but nothing else.

If I’m trying to browse the web and use IRC at the same time, usually this means that I’m out of the conversation for a few minutes, and I can’t even type a response to what I’ve already read. Some of my keystrokes do show up, so Netscape must be yielding occasionally, but not often enough. A line like “my flight comes in at 9:00” ends up looking like “myfg co n :00”.

I think this is one of the best reasons to use preemptive multitasking. With a complex task like this, where do you yield? After every HTML element, every 5 elements, every 10 elements? Too often and the task runs slowly; not often enough and the computer becomes unusable. “Too often” and “not often enough” change meaning depending on the computer’s speed and the size of the task. But if the OS manages task switching, everything runs smoothly and the programmer has one less thing to worry about.

Admitted.

Now, I suspect that the reason it didn’t work was Apple’s unfamiliarity with preemptive multitasking, not any inherent flaws in the concept. :wink:

Mr2001:

I’m glad you brought this up, because this is precisely where WindowsNT fails for me quite frequently. I listen to CDs and MP3s quite frequently, and one of the things I hate is sometimes my sound will stop to play another sound, a system beep or some such. Rather than the sound from my music continuing, all sound through my sound card shuts down. I can see from my vue meters that my MP3 player still thinks it’s outputting sound, but nothing comes out. When this happens, the only way to fix it (that I’ve found) is to reboot the system. Is this a reentrancy problem in it’s purest sense, I can’t say but it is clarly a case of a background task interrupting the sound drivers and the original task is unable to successfully regain control. I’ve found a similar problem with the CD-ROM driver. I’ll be playing an audio CD, open the CD-ROM directory from Explorer and poof, my CD-ROM drive will no longer play analog CDs. Again, I have to reboot to resolve this problem.

In reference to my level 2 (GUI) reentrancy:

Again, let me use some NT examples, since I’m sure you will have witnessed these yourself. Let’s say you’ve got a bunch of activities going on… maybe you’ve just printed a long document and you’re switching to another application - let’s say the CDPlayer. You go to the Start menu, slide up to the Programs submenu, slither over to the Accessories sub-submenu, glide over to the Multimedia sub-sub-submenu, but before you can pull down to the CDPlayer item, a little dialog pops up to inform you that your print job has just completed. All of your popup menus disappear because the internal state has been lost and the routines you were using to pop up the menus are not reentrant (on a high level). Another example is when dragging a window. When background activities preempt, you typically see one of three behaviors (1) choppy movement [to be expected and generally acceptable] (2) display artifacts or (3) a virtual ‘mouseup’ event. All multitasking environments will be subject to choppy movement when other tasks are getting CPU cycles. Windows GUI code is apparently not always reentrant, since it sometimes leaves behind ghost images of a window I’m dragging or screen bits from menus or filenames or icons in Explorer, for instance. Granted these are fairly rare and usually don’t cause any real problem, but most Windows users have seen this phenomenon. I must admit that I have seen it in the Mac world, as well. The third behavior, though, can be a real problem and it happens quite frequently. Suppose you’re dragging a window from one place on the screen to another, if another task preempts, your drag may be interrupted. It’s as if you let up on the mouse button in mid-drag. If you’re just dragging a window, the consequences are probably not too severe. If you’re dragging the icons of several files, the consequences can be more dramatic. At the very least, you may have to go back an reselect the icons. Occasionally, however, I have accidentally moved files from one folder to another because the ‘virtual mouseup’ happened to occur when I had the icons over the top of another folder (enroute to another location). This can be a lot of fun, trying to figure out where the files got dropped, which files got dropped, and putting them all back into their proper places… I’ve never had the Mac do a virtual mouseup on me.
On Netscape:

I don’t understand this. I often switch from Netscape to other applications when Netscape is rendering pages (especially with slow connections). The only time I’ve ever seen Netscape refuse to give up control is in some JavaScripts running under Windows NT. Interestingly, these same JavaScripts don’t sieze my Mac in the same way.

Maybe, but my guess is that it’s the same thing that made Windows 3.1 so successful. They tried to overlay a new architecture ontop of a previous one that was not designed for these kinds of constructions…