⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 task.html

📁 A tutorial on RT-Linux
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD>   <TITLE>RTAI 1.0 documentation - Task functions</TITLE>   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">   <META NAME="Generator" CONTENT="VIM - Vi IMproved 5.3"></HEAD><BODY><A NAME="rt_task_init"></A><A NAME="rt_task_init_cpuid"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_init, rt_task_init_cpuid - create a new real time task</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>int rt_task_init (RT_TASK *</B><I>task</I><B>,void (*</B><I>rt_thread</I><B>)(int),int </B><I>data</I><B>,int </B><I>stack_size</I><B>,int </B><I>priority</I><B>,int </B><I>uses_fpu</I><B>,void(*</B><I>signal</I><B>)(void));</B><p><B>int rt_task_init_cpuid (RT_TASK *</B><I>task</I><B>,void (*</B><I>rt_thread</I><B>)(int),int </B><I>data</I><B>,int </B><I>stack_size</I><B>,int </B><I>priority</I><B>,int </B><I>uses_fpu</I><B>,void(*</B><I>signal</I><B>)(void),unsigned int </b><i>cpuid</i></b>);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_init</b> and <b>rt_task_init_cpuid</b> create a real time task.<BR><I>task</I> is a pointer to an RT_TASK type structurewhose space must be provided by the application. It must be kept duringthe whole lifetime of the real time task and cannot be an automatic variable.<BR><I>rt_thread</I> is the entry point of the task function.The parent task can pass a single integer value <I>data</I> to thenew task.<BR><I>stack_size</I> is the size of the stack to be usedby the new task, and <I>priority</I> is the priority to be giventhe task. The highest priority is 0, while the lowest isRT_LOWEST_PRIORITY (or RT_SCHED_LOWEST_PRIORITY in newer versions).<BR><I>uses_fpu</I> is a flag. Nonzero value indicates that the taskwill use the floating point unit.<BR><I>signal</I> is a function that is called, within thetask environment and with interrupts disabled, when the task becomes thecurrent running task after a context switch.<p>The newly created real time task is initially in a suspendstate. It is can be made active either with<b>rt_task_make_periodic</b>, <b>rt_task_make_periodic_relative_ns</b>or <b>rt_task_resume</b>.<p>On multiprocessor systems <b>rt_task_init_cpuid</b> assignstask to a specific CPU <i>cpuid</i>.<b>rt_task_init</b> automatically selects whichCPU will the task run on. This assignment may be changed by calling<b>rt_set_runnable_on_cpus</b> or <b>rt_set_runnable_on_cpuid</b>.If <i>cpuid</i> is invalid <b>rt_task_init_cpuid</b> falls back toautomatic CPU selection.</dd></dl><dl><dt><H3>RETURN VALUE</H3></dt><dd>On success 0 is returned.On failure a negative value is returned as described below.</dd></dl><dl><dt><H3>ERRORS</H3></dt><dd>	<dl><dt>	-EINVAL	</dt><dd>	Task structure pointed by <i>task</i> is already in use.	</dd></dl>	<dl><dt>	-ENOMEM	</dt><dd>	<I>stack_size</I> bytes could not be allocated for the stack.	</dd></dl></dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_delete"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_delete - delete a real time task</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>int rt_task_delete (RT_TASK *</B><I>task</I><B>);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_delete</b> deletes a real time task previously created by<b>rt_task_init</b> or <b>rt_task_init_cpuid</b>.<BR><I>task</I> is the pointer to the task structure.<BR>If task <i>task</i> was waiting for a semaphore it is removed from thesemaphore waiting queue else any other task blocked on message exchangewith <i>task</i> is unvlocked.</dd></dl><dl><dt><H3>RETURN VALUE</H3></dt><dd>On success 0 is returned.On failure a negative value is returned as described below.</dd></dl><dl><dt><H3>ERRORS</H3></dt><dd>	<dl><dt>	-EINVAL	</dt><dd>	<I>task</I> does not refer to a valid task.	</dd></dl></dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_make_periodic"></A><A NAME="rt_task_make_periodic_relative_ns"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_make_periodic, rt_task_make_periodic_relative_ns -	make a task run periodically</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>int rt_task_make_periodic (RT_TASK *</b><I>task</I><b>,	RTIME </b><I>start_time</I><b>,	RTIME </b><I>period</I><b>);</B><p><B>int rt_task_make_periodic_relative_ns (RT_TASK *</b><I>task</I><b>,	RTIME </b><I>start_delay</I><b>,	RTIME </b><I>period</I><b>);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_make_periodic</b> and <b>rt_task_make_periodic_relative_ns</b>mark the task <i>task</i>,previously created with <b>rt_task_init</b>, as suitable for aperiodic execution, with period <i>period</i>,when <b>rt_task_wait_period</b> is called.<BR>The time of first execution is given by <I>start_time</I> or<I>start_delay</I>.<I>start_time</I> is an absolute value measured in clock ticks.<I>start_delay</I> is relative to the current time and measured in nanosecs.</dd></dl><dl><dt><H3>RETURN VALUE</H3></dt><dd>On success 0 is returned.On failure a negative value is returned as described below.</dd></dl><dl><dt><H3>ERRORS</H3></dt><dd>	<dl><dt>	-EINVAL	</dt><dd>	<I>task</I> does not refer to a valid task.	</dd></dl></dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_wait_period"><dl><dt><H3>NAME</H3></dt><dd>rt_task_wait_period - wait till next period</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>void rt_task_wait_period (void);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_wait_period</b> suspends the execution of the currently runningreal timetask until the next period is reached. The task must have been previouslymarked for execution with <b>rt_task_make_periodic</b> or<b>rt_task_make_periodic_relative_ns</b>.<BR>Note that the task is suspended only temporarily, i.e.it simply gives up control until the next time period.</dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_yield"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_yield - yield the current task</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>void rt_task_yield (void);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_yield</b> stops the current task and takes it at the end of thelist of ready tasks, with the same priority. The scheduler makes thenext ready task of the same priority active.</dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_suspend"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_suspend - suspend a task</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>int rt_task_suspend (RT_TASK *</b><I>task</I><B>);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_suspend</b> suspends execution of the task <I>task</I>.It will not be executed until a call to<b>rt_task_resume</b> or <b>rt_task_make_periodic</b> is made.</dd></dl><dl><dt><H3>RETURN VALUE</H3></dt><dd>On success 0 is returned.On failure a negative value is returned as described below.</dd></dl><dl><dt><H3>ERRORS</H3></dt><dd>	<dl><dt>	-EINVAL	</dt><dd>	<I>task</I> does not refer to a valid task.	</dd></dl></dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_task_resume"></A><dl><dt><H3>NAME</H3></dt><dd>rt_task_resume - resume a task</dd></dl><dl><dt><H3>SYNOPSIS</H3></dt><dd>#include "rtai_sched.h"<p><B>int rt_task_resume (RT_TASK *</B><I>task</I><B>);</B></dd></dl><dl><dt><H3>DESCRIPTION</H3></dt><dd><b>rt_task_resume</b> resumes execution of the task<I>task</I> previously suspended by <b>rt_task_suspend</b> ormakes a newly created task ready to run.</dd></dl><dl><dt><H3>RETURN VALUE</H3></dt><dd>On success 0 is returned.On failure a negative value is returned as described below.</dd></dl><dl><dt><H3>ERRORS</H3></dt><dd>	<dl><dt>	-EINVAL	</dt><dd>	<I>task</I> does not refer to a valid task.	</dd></dl></dd></dl><p align=right><A HREF="manual.html#task">[return to index]</A></p><HR ALIGN=LEFT SIZE=1 NOSHADE WIDTH="100%"><!-- -------------------------------------------------------- --><A NAME="rt_busy_sleep"></A><A NAME="rt_sleep"></A><A NAME="rt_sleep_until"></A><dl><dt><H3>NAME</H3></dt><dd>rt_busy_sleep, rt_sleep, rt_sleep_until - delay/suspend execution for a while</dd></dl><dl><dt><H3>SYNOPSIS</H3>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -