proc_compare man page on NetBSD

Man page or keyword search:  
man Server   9087 pages
apropos Keyword Search (all sections)
Output format
NetBSD logo
[printable version]

PROC_COMPARE(3)		 BSD Library Functions Manual	       PROC_COMPARE(3)

NAME
     proc_compare — compare two processes' interactivity

LIBRARY
     System Utilities Library (libutil, -lutil)

SYNOPSIS
     #include <sys/sysctl.h>

     int
     proc_compare(const struct kinfo_proc2 *p1, const struct kinfo_lwp *l1,
	 const struct kinfo_proc2 *p2, const struct kinfo_lwp *l2);

DESCRIPTION
     The proc_compare() function compares two processes that are on the same
     terminal for their interactivity.	This means that the process returned
     is the one that has a better chance being the active foreground process
     on that tty.  This algorithm is used in the kernel for SIGINFO reporting
     and in userland by w(1).

     The algorithm used is as follows:
	   ·   If one of them is runnable, it is preferred.
	   ·   If both are runnable, the one with the largest CPU percent is
	       preferred.
	   ·   In a CPU percent tie, the one started more recently wins.
	   ·   If none are runnable, and one of them is a zombie, the non-zom‐
	       bie is preferred
	   ·   If both are zombies, the one started more recently wins.
	   ·   If neither is a zombie, the one with the smaller sleep time
	       wins.
	   ·   In a tie, and one is sleeping in non-interruptible sleep, pre‐
	       fer that one.
	   ·   If both are in the same state, the one started more recently is
	       preferred.
     In all cases where the most recently started wins, if there was no win‐
     ner, the one with the largest PID wins.

RETURN VALUES
     The proc_compare() function returns 0 if p1 is to be preferred and 1 if
     p2 is to be preferred.

SEE ALSO
     w(1)

HISTORY
     The proc_compare() was extracted from src/sys/kern/tty.c and
     src/usr.bin/w/proc_compare.c and merged in NetBSD 6.0.

BSD			       October 20, 2011				   BSD
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server NetBSD

List of man pages available for NetBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net