How to identify a non-responsive process programmatically

I am looking for a way to identify a non-responding (non-zombie) process programmatically. I found some information to check the status of TH_STATE_UNINTERRUPTIBLE, but there was some discussion that this is not the right way.

+3
source share
2 answers

I assume that you mean that the spinning wheel application freezes? There are many ways to freeze. An important reason is important. If this is a Cocoa application, you can try sending the main thread / Window event ... or create a Spin Control script.

+1
source

... , - , Ask Different...

sched_prim.c( ) xnu-124.7 :

#define MAX_STUCK_THREADS   128

/*
 *  do_thread_scan: scan for stuck threads.  A thread is stuck if
 *  it is runnable but its priority is so low that it has not
 *  run for several seconds.  Its priority should be higher, but
 *  won't be until it runs and calls update_priority.  The scanner
 *  finds these threads and does the updates.
 *
 *  Scanner runs in two passes.  Pass one squirrels likely
 *  thread ids away in an array  (takes out references for them).
 *  Pass two does the priority updates.  This is necessary because
 *  the run queue lock is required for the candidate scan, but
 *  cannot be held during updates [set_pri will deadlock].
 *
 *  Array length should be enough so that restart isn't necessary,
 *  but restart logic is included.  Does not scan processor runqs.
 *
 */
thread_t        stuck_threads[MAX_STUCK_THREADS];
int             stuck_count = 0;

/*
 *  do_runq_scan is the guts of pass 1.  It scans a runq for
 *  stuck threads.  A boolean is returned indicating whether
 *  a retry is needed.
 */

- , , ?

?


sched_prim.c xnu-1699.26.8 Mac OS X 10.7.4.

+1

Source: https://habr.com/ru/post/1735109/


All Articles