initp Kernel Service

Purpose

Changes the state of a kernel process from idle to ready.

Syntax

#include <sys/types.h>
#include <sys/errno.h>

int initp
(
pid, func, init_parms,
parms_length
, name)
pid_t  pid;
void ( func) (int
flag,
void* init_parms, int parms_length );
void * init_parms;
int  parms_length;
char * name;

Parameters

Item Description
pid Specifies the process identifier of the process to be initialized.
func Specifies the process's initialization routine.
init_parm Specifies the pointer to the initialization parameters.
parms_length Specifies the length of the initialization parameters.
name Specifies the process name.

Description

The initp kernel service completes the transition of a kernel process from idle to ready. The idle state for a process is represented by p_status == SIDL. Before calling the initp service, the creatp service is called to create the process. The creatp service allocates and initializes a process table entry.

The initp service creates and initializes the process-private segment. The process is marked as a kernel process by a bit set in the p_flag field in the process table entry. This bit, the SKPROC bit, signifies that the process is a kernel process.

The process calling the initp service to initialize a newly created process must be the same process that called the creatp service to create the new process.

"Using Kernel Processes" in AIX® Version 7.1 Kernel Extensions and Device Support Programming Concepts further explains how the initp kernel service completes the initialization process begun by the creatp service.

The pid parameter identifies the process to be initialized. It must be valid and identify a process in the SIDL (idle) state.

The name parameter points to a character string that names the process. The leading characters of this string are copied to the user structure. The number of characters copied is implementation-dependent, but at least four are always copied.

The func parameter indicates the main entry point of the process. The new process is made ready to run this function. If the init_parms parameter is not null, it points to data passed to this routine. The parameter structure must be agreed upon between the initializing and initialized process. The initp service copies the data specified by the init_parm parameter (with the exact number of bytes specified by the parms_length parameter) of data to the new process's stack.

Execution Environment

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

Example

To initialize the kernel process running the function main_kproc, enter:

{ 
.
.
.
pid = creatp();
initp(pid, main_kproc, &node_num, sizeof(int), "tkproc");         
.
.
}
void
main_kproc(int flag, void* init_parms, int parms_length)
{
        .
        .
        .
        int i;
        i = *( (int *)init_parms );
        .
        .
        .
} 

Return Values

Item Description
0 Indicates a successful operation.
ENODEV The process could not be scheduled because it has a processor attachment that does not contain any available processors. This can be caused by Dynamic Processor Deallocation.
ENOMEM Indicates that there was insufficient memory to initialize the process.
EINVAL Indicates an pid parameter that was not valid.