Skip to content

Commit

Permalink
[PHP 8.4] pcntl add cpu affinity calls. (#4346)
Browse files Browse the repository at this point in the history
Co-authored-by: Gina Peter Banyard <girgias@php.net>
  • Loading branch information
devnexen and Girgias authored Jan 30, 2025
1 parent 888507c commit 5af24e4
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 0 deletions.
83 changes: 83 additions & 0 deletions reference/pcntl/functions/pcntl-getcpuaffinity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.pcntl-getcpuaffinity" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>pcntl_getcpuaffinity</refname>
<refpurpose>Get the cpu affinity of a process</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>bool</type><type>array</type></type><methodname>pcntl_getcpuaffinity</methodname>
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>pid</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<simpara>
Retrieve the cpu affinity of the <parameter>pid</parameter>.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>pid</parameter></term>
<listitem>
<simpara>
If &null;, the current process ID is used.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns the cpu affinity mask of the process, &return.falseforfailure;.
</simpara>
&return.falseproblem;
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
A <classname>ValueError</classname> is thrown when
<parameter>pid</parameter> is an invalid process id
or the cpu mask had failed to be created..
</simpara>
<simpara>
If <parameter>pid</parameter> is a process for which the current
user has no allowed permission, a <constant>E_WARNING</constant>
is emitted.
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>pcntl_setcpuaffinity</function></member>
</simplelist>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
90 changes: 90 additions & 0 deletions reference/pcntl/functions/pcntl-setcpuaffinity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.pcntl-setcpuaffinity" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>pcntl_setcpuaffinity</refname>
<refpurpose>Set the cpu affinity of a process</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>pcntl_setcpuaffinity</methodname>
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>pid</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>array</type><parameter>hmask</parameter></methodparam>
</methodsynopsis>
<simpara>
Sets the cpu affinity for the <parameter>pid</parameter> with the cpu affinity mask given by
<parameter>hmask</parameter>.
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>pid</parameter></term>
<listitem>
<simpara>
If &null;, the current process ID is used.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>hmask</parameter></term>
<listitem>
<simpara>
The cpu affinity mask comprised of one or more cpu id for binding the process to.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
&return.success;
</simpara>
&return.falseproblem;
</refsect1>

<refsect1 role="errors">
&reftitle.errors;
<simpara>
A <classname>TypeError</classname> is thrown if one
of the cpu id from the <parameter>hmask</parameter> is invalid.
A <classname>ValueError</classname> is thrown if
<parameter>pid</parameter> is an invalid process id
or the cpu mask had failed to be created.
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>pcntl_setcpuaffinity</function></member>
</simplelist>
</refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
2 changes: 2 additions & 0 deletions reference/pcntl/versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
<function name="pcntl_errno" from="PHP 5 &gt;= 5.3.4, PHP 7, PHP 8"/>
<function name="pcntl_exec" from="PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8"/>
<function name="pcntl_fork" from="PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8"/>
<function name="pcntl_getcpuaffinity" from="PHP 8 &gt;= 8.4.0"/>
<function name="pcntl_getpriority" from="PHP 5, PHP 7, PHP 8"/>
<function name="pcntl_get_last_error" from="PHP 5 &gt;= 5.3.4, PHP 7, PHP 8"/>
<function name="pcntl_rfork" from="PHP 8 &gt;= 8.1.0"/>
<function name="pcntl_setcpuaffinity" from="PHP 8 &gt;= 8.4.0"/>
<function name="pcntl_setpriority" from="PHP 5, PHP 7, PHP 8"/>
<function name="pcntl_signal" from="PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8"/>
<function name="pcntl_signal_dispatch" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>
Expand Down

0 comments on commit 5af24e4

Please sign in to comment.