ra_detachrset Subroutine

Purpose

Detaches a work component from a resource set.

Library

Standard C library (libc.a)

Syntax

#include <sys/rset.h>
int ra_detachrset (rstype, rsid, flags)
rstype_t rstype;
rsid_t rsid;
unsigned int flags;

Description

The ra_detachrset subroutine detaches a work component specified by rstype and rsid from a resource set.

The work component is an existing process identified by the process ID or an existing kernel thread identified by the kernel thread ID (tid). A process ID or thread ID value of RS_MYSELF indicates the detach command applies to the current process or the current kernel thread, respectively.

The following conditions must be met to detach a process or a kernel thread from a resource set:
  • The calling process must either have root authority or have CAP_NUMA_ATTACH capability.
  • The calling process must either have root authority or the same effective userid as the target process.
  • For R_FILDES rstype, the calling process must specify an open file descriptor, and it must have write access to the file, or the calling process' effective userid must be equal to the file owner's userid.
  • For R_SHM rstype, the calling process' effective userid must be equal to the shared segment's owner.

If these conditions are not met, the operation will fail.

Once a process is detached from a resource set, the threads in the process can run on all available processors contained in the process' partition resource set. Once a kernel thread is detached from a resource set, that thread can run on all available processors contained in its process effective or partition resource set.

Parameters

Item Description
rstype Specifies the type of work component to be detached from to the resource set specified by rset. This parameter must be the following value, defined in rset.h:
  • R_PROCESS: existing process
  • R_THREAD: existing kernel thread
  • R_FILDES: file identified by an open file descriptor
  • R_SHM: shared memory segment identified by shared memory segment ID
  • R_SUBRANGE: attachment involves a subrange of the work component
rsid Identifies the work component to be attached to the resource set specified by rset. This parameter must be the following:
  • Process ID (for rstype of R_PROCESS): set the rsid_t at_pid field to the desired process' process ID.
  • Kernel thread ID (for rstype of R_THREAD): set the rsid_t at_tid field to the desired kernel thread's thread ID.
  • Open file descriptor (for rstype of R_FILDES): set the rsid_t at_fd field to the desired file descriptor.
  • Shared memory segment ID (for rstype of R_SHM): set the rsid_t at_shmid field to the desired shared memory ID.
  • Pointer to a subrange_t struct (for rstype of R_SUBRANGE): set the subrange_t su_offset, su_length, su_rstype, and su_rsid fields. The other fields in the subrange_t struct are ignored.
flags For rstype of R_PROCESS, the R_DETACH_ALLTHRDS indicates that R_THREAD rsets are detached from all threads in a specified process. The process' effective rset is not detached in this case. Reserved for future use. Specify as 0.

Return Values

If successful, a value of 0 is returned. If unsuccessful, a value of -1 is returned, and the errno global variable is set to indicate the error.

Error Codes

The ra_detachrset subroutine is unsuccessful if one or more of the following are true:
Item Description
EINVAL One of the following is true:
  • The flags parameter contains an invalid value.
  • The rstype parameter contains an invalid type qualifier.
ESRCH The process or kernel thread identified by the rstype and rsid parameters does not exist.
EPERM One of the following is true:
  • The calling process has neither root authority nor CAP_NUMA_ATTACH attachment privilege.
  • The calling process has neither root authority nor the same effective user ID as the process identified by the rstype and rsid parameters.