kra_thread_create Kernel Service
Purpose
Creates a new kernel thread in the calling process and attaches the new kernel thread to a resource set.
Syntax
#include <sys/rset.h>
tid_t kra_thread_create (rstype, rsid, flags)
rstype_t rstype;
rsid_t rsid;
unsigned int flags;
Description
The kra_thread_create kernel service creates a new kernel-only thread in the calling kernel process and attaches the new kernel thread to a resource set as specified in the rstype and rsid parameters. After the kernel thread is created, the ID of the new kernel thread is returned. The returned ID of the new kernel thread is unique throughout the system.
The kra_thread_create kernel service can be used similar to the thread_create kernel service for creating a new kernel thread in the calling process.
The new kernel thread does not start immediately after it is created and the state of the new kernel thread is set to TSIDL. The new kernel thread starts after a call to the kthread_start kernel service. If the new kernel thread process exits before the new kernel thread starts, resources of the new kernel thread are released immediately. The signal-mask of the new kernel thread is inherited from the calling thread and the set of pending signals of the kernel thread is cleared. If the new kernel thread is in the TSIDL state, all the signals that are sent to the new kernel thread are marked as Pending.
- The resource set must contain processors that are available in the system.
- The calling process must either have the root authority or have the CAP_NUMA_ATTACH capability.
- The calling process must either have the root authority or have the same effective user ID as that of the target process.
- The calling thread must not have a bindprocessor bindings to a processor.
- The resource set must be contained in partition resource set of the calling process.
Parameters
| Item | Description |
|---|---|
| rstype | Specifies the resource set type to which the new kernel thread of the calling process will be
attached. The valid values are:
|
| rsid | Specifies the resource set that is associated with the rstype parameter. The valid
values are:
|
| flags | Reserved for future use. You can specify the value as 0. |
Return Values
Upon successful completion, the kra_thread_create kernel service returns a value of zero (0). If unsuccessful, the kra_thread_create kernel service returns one of the following errors:
| Item | Description |
|---|---|
| EINVAL | Indicates one of the following conditions:
|
| ENODEV | The specified resource set does not contain a processor that is available in the system. |
| EFAULT | Invalid address. |
| EPERM | Indicates one of the following conditions:
|
| ENOMEM | Available memory is not sufficient to create the kernel thread. |
| EAGAIN |
The total number of kernel threads executing system-wide or the maximum number of kernel threads per process would be exceeded. |
| ENOTSUP | The kra_thread_create kernel service is called directly from a kernel extension. |