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 .sp
  69 .LP
  70 The \fBpthread_getschedparam()\fR and \fBpthread_setschedparam()\fR functions
  71 allow the scheduling policy and scheduling parameters of individual threads
  72 within a multithreaded process to be retrieved and set. Supported policies are
  73 :
  74 .sp
  75 .ne 2
  76 .na
  77 \fB\fBSCHED_OTHER\fR\fR
  78 .ad
  79 .RS 15n
  80 traditional time-sharing scheduling class
  81 .RE
  82 
  83 .sp
  84 .ne 2
  85 .na
  86 \fB\fBSCHED_FIFO\fR\fR
  87 .ad
  88 .RS 15n
  89 real-time class: run to completion
  90 .RE
  91 
  92 .sp
  93 .ne 2
  94 .na
  95 \fB\fBSCHED_RR\fR\fR
  96 .ad
  97 .RS 15n
  98 real-time class: round-robin
  99 .RE
 100 
 101 .sp
 102 .ne 2
 103 .na
 104 \fB\fBSCHED_IA\fR\fR
 105 .ad
 106 .RS 15n
 107 interactive time-sharing class
 108 .RE
 109 
 110 .sp
 111 .ne 2
 112 .na
 113 \fB\fBSCHED_FSS\fR\fR
 114 .ad
 115 .RS 15n
 116 fair-share scheduling class
 117 .RE
 118 
 119 .sp
 120 .ne 2
 121 .na
 122 \fB\fBSCHED_FX\fR\fR
 123 .ad
 124 .RS 15n
 125 fixed priority scheduling class
 126 .RE
 127 
 128 .sp
 129 .LP
 130 See \fBpthreads\fR(5). The affected scheduling parameter is the
 131 \fIsched_priority\fR member of the \fBsched_param\fR structure.
 132 .sp
 133 .LP
 134 The \fBpthread_getschedparam()\fR function retrieves the scheduling policy and
 135 scheduling parameters for the thread whose thread \fBID\fR is given by
 136 \fIthread\fR and stores those values in \fIpolicy\fR and \fIparam\fR,
 137 respectively. The priority value returned from \fBpthread_getschedparam()\fR is
 138 the value specified by the most recent \fBpthread_setschedparam()\fR or
 139 \fBpthread_create()\fR call affecting the target thread, and does not reflect
 140 any temporary adjustments to its priority as a result of any priority
 141 inheritance or ceiling functions. The \fBpthread_setschedparam()\fR function
 142 sets the scheduling policy and associated scheduling parameters for the thread
 143 whose thread  \fBID\fR is given by \fIthread\fR to the policy and associated
 144 parameters provided in \fIpolicy\fR and \fIparam\fR, respectively.
 145 .sp
 146 .LP
 147 If the \fBpthread_setschedparam()\fR function fails, no scheduling parameters
 148 will be changed  for the target thread.
 149 .SH RETURN VALUES
 150 .sp
 151 .LP
 152 If successful, the \fBpthread_getschedparam()\fR and
 153 \fBpthread_setschedparam()\fR functions return  \fB0\fR. Otherwise, an error
 154 number is returned to indicate the error.
 155 .SH ERRORS
 156 .sp
 157 .LP
 158 The \fBpthread_getschedparam()\fR and \fBpthread_gsetschedparam()\fR functions
 159 will fail if:
 160 .sp
 161 .ne 2
 162 .na
 163 \fB\fBESRCH\fR\fR
 164 .ad
 165 .RS 9n
 166 The value specified by \fIthread\fR does not refer to an existing thread.
 167 .RE
 168 
 169 .sp
 170 .LP
 171 The \fBpthread_setschedparam()\fR function will fail if:
 172 .sp
 173 .ne 2
 174 .na
 175 \fB\fBEINVAL\fR\fR
 176 .ad
 177 .RS 10n
 178 The value specified by \fIpolicy\fR or one of the scheduling parameters
 179 associated with the scheduling policy \fIpolicy\fR is invalid.
 180 .RE
 181 
 182 .sp
 183 .ne 2
 184 .na
 185 \fB\fBEPERM\fR\fR
 186 .ad
 187 .RS 10n
 188 The caller does not have the appropriate permission to set either the
 189 scheduling parameters or the scheduling policy of the specified thread.
 190 .RE
 191 
 192 .SH ATTRIBUTES
 193 .sp
 194 .LP
 195 See \fBattributes\fR(5) for descriptions of the following attributes:
 196 .sp
 197 
 198 .sp
 199 .TS
 200 box;
 201 c | c
 202 l | l .
 203 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 204 _
 205 Interface Stability     Committed
 206 _
 207 MT-Level        MT-Safe
 208 _
 209 Standard        See \fBstandards\fR(5).
 210 .TE
 211 
 212 .SH SEE ALSO
 213 .sp
 214 .LP
 215 \fBpthread_attr_init\fR(3C), \fBsched_getparam\fR(3C),
 216 \fBsched_get_priority_max\fR(3C), \fBsched_get_priority_max\fR(3C),
 217 \fBsched_get_priority_min\fR(3C), \fBsched_setparam\fR(3C),
 218 \fBsched_getscheduler\fR(3C), \fBsched_setscheduler\fR(3C),
 219 \fBattributes\fR(5), \fBpthreads\fR(5), \fBstandards\fR(5)