proch_reg Kernel Service

Purpose

Registers a callout handler.

Syntax

#include <sys/proc.h>
int proch_reg(struct prochr *)
Note: The prochr structure contains the following elements that must be set prior to calling proch_reg:

void (* proch_handler)(struct prochr *, int, long)
unsigned int
  int prochr_mask

Parameters

Item Description
int prochr_mask Specifies the set of kernel events for which a callout is requested. Unlike the old_style interface, the callout is invoked only for the specified events. This mask is formed by ORing together any of these defined values: 
PROCHR_INITIALIZE
Process created.
PROCHR_TERMINATE
Process terminated
PROCHR_EXEC
Process has issued the exec system call
PROCHR_THREADINIT
Thread created
PROCHR_THREADTERM
Thread terminated
proch_handler Specifies the callout function to be called when specified kernel events occur.

Description

If the same struct prochr * is registered more than once, only the most recently specified information is retained in the kernel.

The struct prochr * is not copied to a new location in memory. As a result, if the structure is changed, results are unpredictable. This structure does not need to be pinned.

The primary consideration for the new-style interface is to improve scalability. A lock is only acquired when callouts are made. A summary mask of all currently registered callout event types is maintained. This summary mask is updated every time proch_reg or proch_unreg is called, even when registering an identical struct prochr *. Further, the lock is a complex lock, so once callouts have been registered, there is no lock contention in invoking them because the lock is held read-only.

When a callout to a registered handler function is made, the parameters passed are:

Return Values

On successful completion, the proch_reg kernel service returns a value of 0. The only error (non-zero) return is from trying to register with a NULL pointer.

Execution Environment

The proch_reg kernel service can be called from the process environment only.