1 .\"
   2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
   3 .\" permission to reproduce portions of its copyrighted documentation.
   4 .\" Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\"
   7 .\" The Institute of Electrical and Electronics Engineers and The Open
   8 .\" Group, have given us permission to reprint portions of their
   9 .\" documentation.
  10 .\"
  11 .\" In the following statement, the phrase ``this text'' refers to portions
  12 .\" of the system documentation.
  13 .\"
  14 .\" Portions of this text are reprinted and reproduced in electronic form
  15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
  16 .\" Standard for Information Technology -- Portable Operating System
  17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
  18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
  19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
  20 .\" between these versions and the original IEEE and The Open Group
  21 .\" Standard, the original IEEE and The Open Group Standard is the referee
  22 .\" document.  The original Standard can be obtained online at
  23 .\" http://www.opengroup.org/unix/online.html.
  24 .\"
  25 .\" This notice shall appear on any product containing this material.
  26 .\"
  27 .\" The contents of this file are subject to the terms of the
  28 .\" Common Development and Distribution License (the "License").
  29 .\" You may not use this file except in compliance with the License.
  30 .\"
  31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  32 .\" or http://www.opensolaris.org/os/licensing.
  33 .\" See the License for the specific language governing permissions
  34 .\" and limitations under the License.
  35 .\"
  36 .\" When distributing Covered Code, include this CDDL HEADER in each
  37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  38 .\" If applicable, add the following below this CDDL HEADER, with the
  39 .\" fields enclosed by brackets "[]" replaced with your own identifying
  40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  41 .\"
  42 .\"
  43 .\" Copyright 1991, 1992, 1994, The X/Open Company Ltd.
  44 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
  45 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
  46 .\"
  47 .TH PTHREAD_GETSCHEDPARAM 3C "Apr 1, 2008"
  48 .SH NAME
  49 pthread_getschedparam, pthread_setschedparam \- access dynamic thread
  50 scheduling parameters
  51 .SH SYNOPSIS
  52 .LP
  53 .nf
  54 cc -mt [ \fIflag\fR... ] \fIfile\fR... -lpthread [ \fIlibrary\fR... ]
  55 #include <pthread.h>
  56 
  57 \fBint\fR \fBpthread_getschedparam\fR(\fBpthread_t\fR \fIthread\fR, \fBint *restrict\fR \fIpolicy\fR,
  58      \fBstruct sched_param *restrict\fR \fIparam\fR);
  59 .fi
  60 
  61 .LP
  62 .nf
  63 \fBint\fR \fBpthread_setschedparam\fR(\fBpthread_t\fR \fIthread\fR, \fBint\fR \fIpolicy\fR,
  64      \fBconst struct sched_param *\fR\fIparam\fR);
  65 .fi
  66 
  67 .SH DESCRIPTION
  68 .LP
  69 The \fBpthread_getschedparam()\fR and \fBpthread_setschedparam()\fR functions
  70 allow the scheduling policy and scheduling parameters of individual threads
  71 within a multithreaded process to be retrieved and set. Supported policies are
  72 :
  73 .sp
  74 .ne 2
  75 .na
  76 \fB\fBSCHED_OTHER\fR\fR
  77 .ad
  78 .RS 15n
  79 traditional time-sharing scheduling class
  80 .RE
  81 
  82 .sp
  83 .ne 2
  84 .na
  85 \fB\fBSCHED_FIFO\fR\fR
  86 .ad
  87 .RS 15n
  88 real-time class: run to completion
  89 .RE
  90 
  91 .sp
  92 .ne 2
  93 .na
  94 \fB\fBSCHED_RR\fR\fR
  95 .ad
  96 .RS 15n
  97 real-time class: round-robin
  98 .RE
  99 
 100 .sp
 101 .ne 2
 102 .na
 103 \fB\fBSCHED_IA\fR\fR
 104 .ad
 105 .RS 15n
 106 interactive time-sharing class
 107 .RE
 108 
 109 .sp
 110 .ne 2
 111 .na
 112 \fB\fBSCHED_FSS\fR\fR
 113 .ad
 114 .RS 15n
 115 fair-share scheduling class
 116 .RE
 117 
 118 .sp
 119 .ne 2
 120 .na
 121 \fB\fBSCHED_FX\fR\fR
 122 .ad
 123 .RS 15n
 124 fixed priority scheduling class
 125 .RE
 126 
 127 .sp
 128 .LP
 129 See \fBpthreads\fR(5). The affected scheduling parameter is the
 130 \fIsched_priority\fR member of the \fBsched_param\fR structure.
 131 .sp
 132 .LP
 133 The \fBpthread_getschedparam()\fR function retrieves the scheduling policy and
 134 scheduling parameters for the thread whose thread \fBID\fR is given by
 135 \fIthread\fR and stores those values in \fIpolicy\fR and \fIparam\fR,
 136 respectively. The priority value returned from \fBpthread_getschedparam()\fR is
 137 the value specified by the most recent \fBpthread_setschedparam()\fR or
 138 \fBpthread_create()\fR call affecting the target thread, and does not reflect
 139 any temporary adjustments to its priority as a result of any priority
 140 inheritance or ceiling functions. The \fBpthread_setschedparam()\fR function
 141 sets the scheduling policy and associated scheduling parameters for the thread
 142 whose thread  \fBID\fR is given by \fIthread\fR to the policy and associated
 143 parameters provided in \fIpolicy\fR and \fIparam\fR, respectively.
 144 .sp
 145 .LP
 146 If the \fBpthread_setschedparam()\fR function fails, no scheduling parameters
 147 will be changed  for the target thread.
 148 .SH RETURN VALUES
 149 .LP
 150 If successful, the \fBpthread_getschedparam()\fR and
 151 \fBpthread_setschedparam()\fR functions return  \fB0\fR. Otherwise, an error
 152 number is returned to indicate the error.
 153 .SH ERRORS
 154 .LP
 155 The \fBpthread_getschedparam()\fR and \fBpthread_setschedparam()\fR functions
 156 will fail if:
 157 .sp
 158 .ne 2
 159 .na
 160 \fB\fBESRCH\fR\fR
 161 .ad
 162 .RS 9n
 163 The value specified by \fIthread\fR does not refer to an existing thread.
 164 .RE
 165 
 166 .sp
 167 .LP
 168 The \fBpthread_setschedparam()\fR function will fail if:
 169 .sp
 170 .ne 2
 171 .na
 172 \fB\fBEINVAL\fR\fR
 173 .ad
 174 .RS 10n
 175 The value specified by \fIpolicy\fR or one of the scheduling parameters
 176 associated with the scheduling policy \fIpolicy\fR is invalid.
 177 .RE
 178 
 179 .sp
 180 .ne 2
 181 .na
 182 \fB\fBEPERM\fR\fR
 183 .ad
 184 .RS 10n
 185 The caller does not have the appropriate permission to set either the
 186 scheduling parameters or the scheduling policy of the specified thread.
 187 .RE
 188 
 189 .SH ATTRIBUTES
 190 .LP
 191 See \fBattributes\fR(5) for descriptions of the following attributes:
 192 .sp
 193 
 194 .sp
 195 .TS
 196 box;
 197 c | c
 198 l | l .
 199 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 200 _
 201 Interface Stability     Committed
 202 _
 203 MT-Level        MT-Safe
 204 _
 205 Standard        See \fBstandards\fR(5).
 206 .TE
 207 
 208 .SH SEE ALSO
 209 .LP
 210 \fBpthread_attr_init\fR(3C), \fBsched_getparam\fR(3C),
 211 \fBsched_get_priority_max\fR(3C), \fBsched_get_priority_max\fR(3C),
 212 \fBsched_get_priority_min\fR(3C), \fBsched_setparam\fR(3C),
 213 \fBsched_getscheduler\fR(3C), \fBsched_setscheduler\fR(3C),
 214 \fBattributes\fR(5), \fBpthreads\fR(5), \fBstandards\fR(5)