[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

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

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 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

0 Indicates a successful operation.
ENOMEM Indicates that there was insufficient memory to initialize the process.
EINVAL Indicates an pid parameter that was not valid.

Implementation Specifics

The initp kernel service is part of the Base Operating System (BOS) Runtime.

Related Information

The creatp kernel service.

The func subroutine.

Introduction to Kernel Processes and Process and Exception Management Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]