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

kthread_start Kernel Service

Purpose

Starts a previously created kernel-only thread.

Syntax

#include <sys/thread.h>
int kthread_start (tid, i_func, i_data_addr, i_data_len, i_stackaddr, i_sigmask)
tid_t tid;
int (*i_func) (void *);
void *i_data_addr;
size_t i_data_len;
void *i_stackaddr;
sigset_t *i_sigmask;

Parameters

tid Specifies the kernel-only thread to start.
i_func Points to the entry-point routine of the kernel-only thread.
i_data_addr Points to data that will be passed to the entry-point routine.
i_data_len Specifies the length of the data chunk.
i_stackaddr Specifies the stack's base address for the kernel-only thread.
i_sigmask Specifies the set of signal to block from delivery when the new kernel-only thread begins execution.

Description

The kthread_start kernel service starts the kernel-only thread specified by the tid parameter. The thread must have been previously created with the thread_create kernel service, and its state must be TSIDL.

This kernel service initializes and schedules the thread for the processor. Its state is changed to TSRUN. The thread is initialized so that it begins executing at the entry point specified by the i_func parameter, and that the signals specified by the i_sigmask parameter are blocked from delivery.

The thread's entry point gets one parameter, a pointer to a chunk of data that is copied to the base of the thread's stack. The i_data_addr and i_data_len parameters specify the location and quantity of data to copy. The format of the data must be agreed upon by the initializing and initialized thread.

The thread's stack's base address is specified by the i_stackaddr parameter. If a value of zero is specified, the kernel will allocate the memory for the stack (96K). This memory will be reclaimed by the system when the thread terminates. If a non-zero value is specified, then the caller should allocate the backing memory for the stack. Since stacks grow from high addresses to lower addresses, the i_stackaddr parameter specifies the highest address for the thread's stack.

The thread will be automatically terminated when it returns from the entry point routine. If it is the last thread in the process, then the process will be exited.

Execution Environment

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

Return Values

The kthread_start kernel service returns one of the following values:

0 Indicates a successful start.
ESRCH Indicates that the tid parameter is not valid.

Implementation Specifics

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

Related Information

The thread_create kernel service.

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


[ Previous | Next | Contents | Home | Search ]