blob: bcbdd6b31122f3826281ed54806d5610f3d7929d [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Task Scheduling Interfaces &mdash; NuttX latest documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/tabs.css" type="text/css" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="../../_static/jquery.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Task Control Interfaces" href="03_task_control.html" />
<link rel="prev" title="Task Control Interfaces" href="01_task_control.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> NuttX
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../../latest" selected="selected">latest</option>
<option value="../../../10.0.0" >10.0.0</option>
<option value="../../../10.0.1" >10.0.1</option>
<option value="../../../10.1.0" >10.1.0</option>
<option value="../../../10.2.0" >10.2.0</option>
<option value="../../../10.3.0" >10.3.0</option>
<option value="../../../11.0.0" >11.0.0</option>
<option value="../../../12.0.0" >12.0.0</option>
<option value="../../../12.1.0" >12.1.0</option>
<option value="../../../12.2.0" >12.2.0</option>
<option value="../../../12.2.1" >12.2.1</option>
<option value="../../../12.3.0" >12.3.0</option>
<option value="../../../12.4.0" >12.4.0</option>
<option value="../../../12.5.0" >12.5.0</option>
<option value="../../../12.5.1" >12.5.1</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../components/index.html">OS Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation Details</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Userspace API</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="01_task_control.html">Task Control Interfaces</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Task Scheduling Interfaces</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#functions">Functions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="03_task_control.html">Task Control Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="04_message_queue.html">Named Message Queue Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="05_counting_semaphore.html">Counting Semaphore Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="06_clocks_timers.html">Clocks and Timers</a></li>
<li class="toctree-l3"><a class="reference internal" href="07_signals.html">Signal Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="08_pthread.html">Pthread Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="09_env_vars.html">Environment Variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="10_filesystem.html">File System Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="11_network.html">Network Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="12_shared_memory.html">Shared Memory Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="13_boardctl.html">Board IOCTL</a></li>
<li class="toctree-l3"><a class="reference internal" href="13_logging.html">Logging</a></li>
<li class="toctree-l3"><a class="reference internal" href="structures.html">OS Data Structures</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../os/index.html">Architecture APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">API Reference</a></li>
<li class="breadcrumb-item"><a href="index.html">Userspace API</a></li>
<li class="breadcrumb-item active">Task Scheduling Interfaces</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/reference/user/02_task_scheduling.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="task-scheduling-interfaces">
<h1>Task Scheduling Interfaces<a class="headerlink" href="#task-scheduling-interfaces" title="Permalink to this heading"></a></h1>
<p>By default, NuttX performs strict priority scheduling: Tasks of higher
priority have exclusive access to the CPU until they become blocked. At
that time, the CPU is available to tasks of lower priority. Tasks of
equal priority are scheduled FIFO.</p>
<p>Optionally, a NuttX task or thread can be configured with round-robin or
<em>sporadic</em> scheduler. The round-robin is similar to priority scheduling
<em>except</em> that tasks with equal priority and share CPU time via
<em>time-slicing</em>. The time-slice interval is a constant determined by the
configuration setting <code class="docutils literal notranslate"><span class="pre">CONFIG_RR_INTERVAL</span></code> to a positive, non-zero
value. Sporadic scheduling scheduling is more complex, varying the
priority of a thread over a <em>replenishment</em> period. Support for sporadic
scheduling is enabled by the configuration option
<code class="docutils literal notranslate"><span class="pre">CONFIG_SCHED_SPORADIC</span></code>.</p>
<p>The OS interfaces described in the following paragraphs provide a POSIX-
compliant interface to the NuttX scheduler:</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="#c.sched_setparam" title="sched_setparam"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_setparam()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_getparam" title="sched_getparam"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_getparam()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_setscheduler" title="sched_setscheduler"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_setscheduler()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_getscheduler" title="sched_getscheduler"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_getscheduler()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_yield" title="sched_yield"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_yield()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_get_priority_max" title="sched_get_priority_max"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_get_priority_max()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_get_priority_min" title="sched_get_priority_min"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_get_priority_min()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.sched_get_rr_interval" title="sched_get_rr_interval"><code class="xref c c-func docutils literal notranslate"><span class="pre">sched_get_rr_interval()</span></code></a></p></li>
</ul>
</div></blockquote>
<section id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this heading"></a></h2>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_setparam">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_setparam</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.pid_t" title="pid_t"><span class="n"><span class="pre">pid_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pid</span></span>, <span class="pre">FAR</span><span class="w"> </span><span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="structures.html#c.sched_param" title="sched_param"><span class="n"><span class="pre">sched_param</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">param</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_setparam" title="Permalink to this definition"></a><br /></dt>
<dd><p>This function sets the priority of the task specified
by pid input parameter.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pid</strong> – The task ID of the task. If <code class="docutils literal notranslate"><span class="pre">pid</span></code> is zero, the priority of
the calling task is set.</p></li>
<li><p><strong>param</strong> – A structure whose member <code class="docutils literal notranslate"><span class="pre">sched_priority</span></code> is the integer
priority. The range of valid priority numbers is from
<code class="docutils literal notranslate"><span class="pre">SCHED_PRIORITY_MIN</span></code> through <code class="docutils literal notranslate"><span class="pre">SCHED_PRIORITY_MAX</span></code>.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><p>On success, sched_setparam() returns 0 (<code class="docutils literal notranslate"><span class="pre">OK</span></code>). On
error, -1 (<code class="docutils literal notranslate"><span class="pre">ERROR</span></code>) is returned, and <code class="docutils literal notranslate"><span class="pre">`errno</span></code> &lt;#ErrnoAccess&gt;`__ is
set appropriately.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">EINVAL</span></code>. The parameter <code class="docutils literal notranslate"><span class="pre">param</span></code> is invalid or does not make sense
for the current scheduling policy.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">EPERM</span></code>. The calling task does not have appropriate privileges.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ESRCH</span></code>. The task whose ID is <code class="docutils literal notranslate"><span class="pre">pid</span></code> could not be found.</p></li>
</ul>
</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name. Differences from the full POSIX implementation include:</p>
<blockquote>
<div><ul class="simple">
<li><p>The range of priority values for the POSIX call is 0 to 255. The
priority 0 is the lowest priority and 255 is the highest priority.</p></li>
</ul>
</div></blockquote>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Setting a task’s priority to the same value has the similar effect
to <code class="docutils literal notranslate"><span class="pre">sched_yield()</span></code>: The task will be moved to after all other tasks
with the same priority.</p>
</div>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_getparam">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_getparam</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.pid_t" title="pid_t"><span class="n"><span class="pre">pid_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pid</span></span>, <span class="pre">FAR</span><span class="w"> </span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="structures.html#c.sched_param" title="sched_param"><span class="n"><span class="pre">sched_param</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">param</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_getparam" title="Permalink to this definition"></a><br /></dt>
<dd><p>This function gets the scheduling priority of the task
specified by pid.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pid</strong> – The task ID of the task. If pid is zero, the priority of the
calling task is returned.</p></li>
<li><p><strong>param</strong> – A structure whose member <code class="docutils literal notranslate"><span class="pre">sched_priority</span></code> is the integer
priority. The task’s priority is copied to the <code class="docutils literal notranslate"><span class="pre">sched_priority</span></code>
element of this structure.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>0 (<code class="docutils literal notranslate"><span class="pre">OK</span></code>) if successful, otherwise -1 (<code class="docutils literal notranslate"><span class="pre">ERROR</span></code>).</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_setscheduler">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_setscheduler</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.pid_t" title="pid_t"><span class="n"><span class="pre">pid_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pid</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">policy</span></span>, <span class="k"><span class="pre">const</span></span><span class="w"> </span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="structures.html#c.sched_param" title="sched_param"><span class="n"><span class="pre">sched_param</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">param</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_setscheduler" title="Permalink to this definition"></a><br /></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">sched_setscheduler()</span></code> sets both the scheduling
policy and the priority for the task identified by <code class="docutils literal notranslate"><span class="pre">pid</span></code>. If <code class="docutils literal notranslate"><span class="pre">pid</span></code>
equals zero, the scheduler of the calling thread will be set. The
parameter <code class="docutils literal notranslate"><span class="pre">param</span></code> holds the priority of the thread under the new
policy.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pid</strong> – The task ID of the task. If <code class="docutils literal notranslate"><span class="pre">pid</span></code> is zero, the priority of
the calling task is set.</p></li>
<li><p><strong>policy</strong> – Scheduling policy requested (either <code class="docutils literal notranslate"><span class="pre">SCHED_FIFO</span></code> or
<code class="docutils literal notranslate"><span class="pre">SCHED_RR</span></code>).</p></li>
<li><p><strong>param</strong> – A structure whose member <code class="docutils literal notranslate"><span class="pre">sched_priority</span></code> is the integer
priority. The range of valid priority numbers is from
<code class="docutils literal notranslate"><span class="pre">SCHED_PRIORITY_MIN</span></code> through <code class="docutils literal notranslate"><span class="pre">SCHED_PRIORITY_MAX</span></code>.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><p>On success, <code class="docutils literal notranslate"><span class="pre">sched_setscheduler()</span></code> returns <code class="docutils literal notranslate"><span class="pre">OK</span></code>
(zero). On error, <code class="docutils literal notranslate"><span class="pre">ERROR</span></code> (-1) is returned, and
<code class="docutils literal notranslate"><span class="pre">errno</span></code> is set appropriately:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">EINVAL</span></code>: The scheduling <code class="docutils literal notranslate"><span class="pre">policy</span></code> is not one of the recognized
policies.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ESRCH</span></code>: The task whose ID is <code class="docutils literal notranslate"><span class="pre">pid</span></code> could not be found.</p></li>
</ul>
</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_getscheduler">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_getscheduler</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.pid_t" title="pid_t"><span class="n"><span class="pre">pid_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pid</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_getscheduler" title="Permalink to this definition"></a><br /></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">sched_getscheduler()</span></code> returns the scheduling policy
currently applied to the task identified by <code class="docutils literal notranslate"><span class="pre">pid</span></code>. If <code class="docutils literal notranslate"><span class="pre">pid</span></code> equals
zero, the policy of the calling process will be retrieved.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pid</strong> – The task ID of the task to query. If <code class="docutils literal notranslate"><span class="pre">pid</span></code> is zero, the
calling task is queried.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><p>On success, <code class="docutils literal notranslate"><span class="pre">sched_getscheduler()</span></code> returns the policy for the task
(either <code class="docutils literal notranslate"><span class="pre">SCHED_FIFO</span></code> or <code class="docutils literal notranslate"><span class="pre">SCHED_RR</span></code>). On error, <code class="docutils literal notranslate"><span class="pre">ERROR</span></code> (-1) is
returned, and <code class="docutils literal notranslate"><span class="pre">errno</span></code> is set appropriately:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ESRCH</span></code>: The task whose ID is pid could not be found.</p></li>
</ul>
</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_yield">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_yield</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">void</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_yield" title="Permalink to this definition"></a><br /></dt>
<dd><p>This function forces the calling task to give up the
CPU (only to other tasks at the same priority).</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>0 (<code class="docutils literal notranslate"><span class="pre">OK</span></code>) or -1 (<code class="docutils literal notranslate"><span class="pre">ERROR</span></code>)</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_get_priority_max">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_get_priority_max</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">policy</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_get_priority_max" title="Permalink to this definition"></a><br /></dt>
<dd><p>This function returns the value of the highest possible
task priority for a specified scheduling policy.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>policy</strong> – Scheduling policy requested.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The maximum priority value or -1 (<code class="docutils literal notranslate"><span class="pre">ERROR</span></code>).</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_get_priority_min">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_get_priority_min</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">policy</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_get_priority_min" title="Permalink to this definition"></a><br /></dt>
<dd><p>This function returns the value of the lowest possible
task priority for a specified scheduling policy.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>policy</strong> – Scheduling policy requested.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The minimum priority value or -1 (<code class="docutils literal notranslate"><span class="pre">ERROR</span></code>)</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.sched_get_rr_interval">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">sched_get_rr_interval</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.pid_t" title="pid_t"><span class="n"><span class="pre">pid_t</span></span></a><span class="w"> </span><span class="n"><span class="pre">pid</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="structures.html#c.timespec" title="timespec"><span class="n"><span class="pre">timespec</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">interval</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.sched_get_rr_interval" title="Permalink to this definition"></a><br /></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">sched_rr_get_interval()</span></code> writes the timeslice
interval for task identified by <code class="docutils literal notranslate"><span class="pre">pid</span></code> into the timespec structure
pointed to by <code class="docutils literal notranslate"><span class="pre">interval</span></code>. If pid is zero, the timeslice for the
calling process is written into ‘interval. The identified process should
be running under the SCHED_RR scheduling policy.’</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>pid</strong> – The task ID of the task. If pid is zero, the priority of the
calling task is returned.</p></li>
<li><p><strong>interval</strong> – A structure used to return the time slice.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><p>On success, sched_rr_get_interval() returns OK (0).
On error, ERROR (-1) is returned, and <code class="docutils literal notranslate"><span class="pre">errno</span></code> is
set to:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">EFAULT</span></code>: Cannot copy to interval</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">EINVAL</span></code>: Invalid pid.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ENOSYS</span></code>: The system call is not yet implemented.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ESRCH</span></code>: The process whose ID is pid could not be found.</p></li>
</ul>
</p>
</dd>
</dl>
<p><strong>POSIX Compatibility:</strong> Comparable to the POSIX interface of the same
name.</p>
</dd></dl>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="01_task_control.html" class="btn btn-neutral float-left" title="Task Control Interfaces" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="03_task_control.html" class="btn btn-neutral float-right" title="Task Control Interfaces" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, The Apache Software Foundation.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>