hanging programs - ultimate termination method other than power switch?

Discussion in 'Apple' started by Boris Harss, Oct 1, 2005.

  1. Boris Harss

    Boris Harss Guest

    Hello, All!

    I have a question that might be stupid and annother one that is born
    from frustration; I never had a situation like this on another UNIX
    machine in 15 years of using all between HP-UX, Solaris, Linux,
    IBM-UNIX, ... So, here I go:

    I have a Mac-Mini (512 MB, OS 10.4.2), running mostly Firebird, Firefox
    and PhotoShop 6.0 in Classic environment. In addition, of course, there
    are standard tools like "preview". Today, I had again a situation I
    encountered before in similar form but with other applications. This
    time, I had Preview started several times with pretty big images while a
    lot of other things were open - obviously, the system started to swap
    and became very sluggish. So far, so predictable #-). I tried to shut
    down preview, which did not work (red button on window, right-click in
    dock, Apple-Alt-ESC, kill -9). Then, I shut down all open applications
    (first classic and photoshop, than the web browser and firebird) - that
    worked slowly but in a normal fashion. However, even so preview was now
    "alone" on the system, it still could not be closed. There was memory
    free, no swapping at the time. Especially: kill -9 <pid> did not work,
    and the task remained using 90% CPU. Shutdown failed because it was also
    unable to close preview. I had to physically switch off the system to
    make it operable again, even so it was in principal responsive.

    QUESTIONS:

    * Is there a more drastic way to shut down a task than kill -9?
    * Why does OS-X become so terrible slow with one task
    running at 90% CPU if it is not swapping? "Normal" UNIX
    systems do not do that (never did that to me, at least).

    SUSPICION:

    Is it possible, that Apple did for the sake of the nice looks or
    portability of old MAC-software, integrate some functions of the user
    interface/API deeper in the UNIX-kernel than is good for stability?

    Cheers,
    B.
     
    Boris Harss, Oct 1, 2005
    #1
    1. Advertisements

  2. Boris Harss

    Jeff Wiseman Guest

    Don't know the exact answers but here are some thoughts:



    I assume that you mean without shutting off the computers power.
    If so, then I think the answer is no. However, that is because as
    long as the OS is running kill -9 <PID> will *ALWAYS* work when
    run correctly. Running it correctly means:

    1) you have suitable access priviledges to run kill against that
    particular PID (i.e., you might have to sudo it)

    2) you are actually sending the -9 signal to the correct PID.
    Frequently folks will send a kill to a task not realizing that
    they've gotten the wrong task or a child of the task that they
    want to kill.


    Swapping only occurs when you run out of memory. If there is more
    than enough memory for all the applications that are running
    (including the one running at 90%), why would anything be
    swapping out? The issue is likely an interface spinning due to
    some odd state the task is in. E.g., watching for input from
    another task in the system that someone killed with a Kill -9
    might do this. waiting for some caching to catch up that is in a
    hosed state can also do this. When the help system preferences
    and caches get fouled up, I've seen it a lot.

    I suspect that you have either a set of cache problems or some
    corrupted preference files somewhere. Cleaning out the /tmp area
    as well may be needed (a power shutdown and reboot would handle
    the /tmp one). If you have been doing a lot of kill -9 operations
    then the problem could have been worstened since kill -9 is very
    nasty and messy. Since it can't be trapped by the task it is sent
    to, any clean file shutdowns and cleanup procedures that the task
    may have programmed into it are totally bypassed. This can leave
    file artifacts laying all over the place.

    Kill -9 should be a last place scenario if possible and the
    ramifications of it need to be understood when using it.
     
    Jeff Wiseman, Oct 1, 2005
    #2
    1. Advertisements

  3. Several things come to mind.

    For the record, kill -9 (e.g. kill -KILL) is the UNIX kernel's way of
    saying "Die a screaming horrible death and don't bother cleaning up
    after yourself". One thing that blocks it is pending I/O, either from a
    program or swapping. I think that's what you're seeing.

    If you're going to be so impatient with a swapping system, buy more
    memory. 512MB seems rather slim for Photoshop usage, except for an
    occasional vacation snapshot. As you've seen, you start swapping and
    swapfiles start being created (MenuMeters is great for putting network
    and memory utilization meters on the toolbar btw). Once you've created
    the swap files, only a reboot will clean them up. So, the more memory
    you have installed, the longer you can run with minimal swap files. I'd
    also run the Activity Monitor's CPU monitor in the dock or turn on
    MenuMeter's CPU monitor. With Activity Monitor, you can open the dock
    icon and see what processes are consuming what resources.

    Consider buying a modern VM version of Photoshop if you use it much.
    You won't have as many memory problems as running it under Classic. You
    can probably pick up a used version on eBay. I don't recall if
    Photoshop 6 will run on MacOS X. I know Photoshop 7 will.

    Once you start swapping, you'll see the spinning beachball whenever you
    need to create more swap files. Performance will drag also as you've
    seen. Shutting down applications either with a Quit or a Force Quit
    won't uncreate the swap files.

    Also consider that on a single processor system, that processor is
    handling everything--CPU, I/O, and memory. That means CPU is used for
    swapping I/O. This is why I eschewed a mini-mac or emac or imac and
    bought a used Dual G4. There's a lot more "headroom" when I start
    swapping. You might some on eBay that are very reasonable.

    But bottom line, I think MacOS X is doing it's job with the resources it
    has. You either need to be more patient or give it more resources.
     
    Michael Vilain, Oct 1, 2005
    #3
  4. Boris Harss

    Boris Harss Guest

    Hi!
    Sure. In my case the first option (IO) was surely the problem since the
    system was no longer swapping at the time. I had made sure by ending all
    other applications and I looked for swapping activity.
    Hmmm... impatient is one thing, but the beast would not come back at
    all. Even so I start to regret my choice on memory more and more.
    On my old windows 98 PC the same photoshop version (6.0) worked OK with
    only 256 MB. But here, of course, we have a bigger system plus classic
    to add to the equation...
    Thanks for the MenuMeters hint, I will google for it. However, also for
    the records (;-)) ), having a certain swap file usage is *not*
    necessarily a sign of memory capacity problems, it just means that some
    allocated memory pages are deemed unlikely to be used soon, so that, for
    example, the hard disk cache takes a hinger priority. In this case, the
    page in question is swapped out and will likely not be use for a long
    time (on a computer time scale). However, if you start to get into
    swapping, you *do* have a memory problem.
    Exactly as you say - PS 7 is the first one that runs native under OS-X.
    And I also agree, that would reduce my problems. However, it was
    "preview" that hand up after Photoshop and classic where successfully
    shut down.
    Maybe true. However, under any UNIX I used to know, that should not be
    an issue- again: The fact that there are memory blocks put into the swap
    file does not mean that you have a RAM problem. The fact, that OS-X does
    not delete/shrink the swap file if blocks in it become free again is
    surely a performance optimisation in the sense to reduce overhead.
    "Normal" systems use even a regular partition that is always there,
    needed, or not. Only if you frequently need to access these memory
    pages, you are in trouble.
    True, but many UNIX systems I worked with had only one CPU (in fact,
    multi processor systems on workstations are something fairly recent. In
    the old times, that was a server domain). from a theoretical point of
    view, a second CPU would double my performance in exactly this
    situation. Half-Very-Very-slow is still very-slow #-).
    I agree on the conclusion, I am afraid, but I not with the first
    sentence. I have seen UNIX systems with a load of 10 being still pretty
    normally responsive when it comes to doing simple things in a terminal
    window. I have never seen (before X) a UNIX system that manages to hang
    up that easily and regularly on IO-Tasks (Disk IO! The grandmother of
    all UNIX IO!) as OS-X seems to do. That, in fact, brought me to my dire
    speculation on Apple doing fancy "optimizations" giving applications,
    aqua or other higher system layers access to things they should not
    access in a UNIX system.

    Cheers,
    B.
     
    Boris Harss, Oct 1, 2005
    #4
  5. Boris Harss

    danied Guest


    That's true as far as it goes.

    Keep in mind that Kill really doesnt do much more than *send a signal*
    to an offending process. If that process refuses to respond to the
    kill signal, then it will not die (which might be the case here).

    As you point out, it can refuse to die while waiting on I/O. However,
    if it's IO task never completes (as often is the case) then the process
    will never die. Also consider its using 90% CPU according to the OP,
    so it is apparently in some kind of tight loop while 'waiting'.

    I'm not sure if OS X uses shared memory in the same way, but it should
    possible to simply deny the process any memory by removing the shared
    memory segment that contains the process using the ipcrm command. This
    is basically a 'shared memory remove' command. I havent had to use it
    on Mac before, but I have had to use it in HP-UX environments.

    Just a cursory look shows that ipcs (to list segments) and ipcrm (to
    remove them) exists in OS X. However, I don't see anything with ipcs
    so perhaps another command is used in OS X.

    Keep in mind that removing the segment will probably still leave the
    process on the kernel process stack. Not really a terrible thing but
    the process will still show as being around, it just wont doing
    anything or consuming any memory. It may show up as a <defunct>
    process after removing the memory segment for it.
     
    danied, Oct 3, 2005
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.