ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/concep16.htm

94 lines
4.1 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>Thread priority and scheduling</title>
<!-- Begin Header Records ========================================== -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- NETMG2 SCRIPT A converted by B2H R4.1 (346) (CMS) by HOLTJM at -->
<!-- RCHVMW2 on 29 Jan 1999 at 10:01:37 -->
<!--File Edited November 2001 -->
<!--End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link -->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>Thread priority and scheduling</h2>
<p>The default thread creation attributes of the iSeries implementation of
Pthreads uses an explicitly specified priority of <strong>
DEFAULT_PRIO_NP</strong>. Some implementations inherit the scheduling priority
and policy of the creating thread by default. For better performance, the
iSeries implementation chooses to start each thread with an explicit priority so
that, when a thread is created, the priority of the creating thread does not
need to be retrieved at run-time.</p>
<p>An iSeries thread competes for scheduling resources against other threads in
the system, not solely against other threads in the process. The scheduler is a
delay cost scheduler based on several delay cost curves (priority ranges). The
POSIX standard and the Single UNIX Specification refers to this as scheduling
scope and scheduling policy, which cannot be changed from the default of
<strong>SCHED_OTHER</strong> in this implementation.</p>
<p>The following Pthread APIs support a scheduling policy of only
SCHED_OTHER.</p>
<ul>
<li><strong>pthread_setschedparam</strong> (SCHED_OTHER only supported)</li>
<li><strong>pthread_getschedparam</strong></li>
<li><strong>pthread_attr_setschedparam</strong></li>
<li><strong>pthread_attr_getschedparam</strong></li>
</ul>
<p>The priority of a thread is specified as a number that represents the value
that is added to the priority of the process. Changing the priority of the
process affects the priority of all of the threads within that process. The
default priority for a thread is <strong>DEFAULT_PRIO_NP</strong>, which is no
change from the process priority.</p>
<p>On the iSeries, numerically lower priority values indicate higher priority with
regard to scheduling. The <strong>pthread.h</strong> and <strong>
sched.h</strong> header files define the priority constants in a way that is
consistent with the threads standard, but opposite of priority specifications
on the iSeries. When you specify a priority of -99 in a call to <strong>
pthread_setschedparam</strong>(), the priority of the target thread is lowered
to the lowest possible value.</p>
<p>For example, process P1 is at iSeries priority 20 and contains a thread T1
that specifies a Pthread priority adjustment of -18. Process P2 is at iSeries
priority 25 and contains thread T2 that specifies a priority of -5. The result
is that the system schedules the threads using the iSeries priority for T1 as 38
and for T2 as 30. The thread scheduling is specified at a system level, and
although process P2 runs at a lower priority ranking than process P1, thread T2
within process P2 runs at a higher priority ranking than thread T1 in process
P1, and thus gets more processing resources.</p>
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center">
<a href="#Top_Of_Page">Top</a> |
<a href="rzah4mst.htm">Pthread APIs</a> |
<a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>