Skip to content
Snippets Groups Projects
NuttxUserGuide.html 222 KiB
Newer Older
patacongo's avatar
patacongo committed

<head>
<title>NuttX Users Manual</title>
<meta name="AUTHOR" content="Gregory Nutt">
</head>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<body background="backgd.gif">
<hr>
<hr>
<center><h1><i>Under Construction</i></h1></center>
<hr>
<hr>
<center><BIG><b>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
User's Manual
patacongo's avatar
patacongo committed
</b></BIG>
<p>
<small>by</small>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
Gregory Nutt
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
<small>Last Update: August 10, 2008</small>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<h1>1.0 <A NAME="Introduction">Introduction</a></h1>

<p>
  This manual provides general usage information for the NuttX RTOS from the
    perspective of the firmware developer.

<h2>1.1 <a name="overview">Document Overview</a></h2>
<p>
  This user's manual is divided into three sections plus a index:
</p>
<ul>
  <li>
    <b>Section 1.0, <a href="#Introduction">Introduction</a></b>:
    This section provides an overview of the NuttX user's manual.
  </li>
  <li>
    <b>Section 2.0, <a href="#OS_Interfaces">OS Interfaces</a></b>:
    This section details the program interfaces provided by NuttX.
    This section is divided into several paragraphs that describe different groups of OS interfaces:
    <ul>
      <li>Paragraph 2.1 <a href="#Task_Control">Task Control Interfaces</a></li>
      <li>Paragraph 2.2 <a href="#Task_Schedule">Task Scheduling Interfaces</a></li>
      <li>Paragraph 2.3 <a href="#Task_Switch">Task Switching Interfaces</a></li>
      <li>Paragraph 2.4 <a href="#Message_Queue">Named Message Queue Interfaces</a></li>
      <li>Paragraph 2.5 <a href="#Semaphores">Counting Semaphore Interfaces</a></li>
      <li>Paragraph 2.6 <a href="#Watchdogs">Watchdog Timer Interfaces</a></li>
      <li>Paragraph 2.7 <a href="#ClocksNTimers">Clocks and Timers</a></li>
      <li>Paragraph 2.8 <a href="#Signals">Signal Interfaces</a></li>
      <li>Paragraph 2.9 <a href="#Pthread">Pthread Interfaces</a></li>
      <li>Paragraph 2.10 <a href="#Environ">Environment Variables</a></li>
patacongo's avatar
patacongo committed
      <li>Paragraph 2.11 <a href="#FileSystem">File System Interfaces</a></li>
patacongo's avatar
patacongo committed
      <li>Paragraph 2.12 <a href="#Network">Network Interfaces</a></li>
patacongo's avatar
patacongo committed
    </ul>
  </li>
  <li>
    <b>Section 3.0, <a href="#Data_Structures">OS Data Structures</a></b>:
    This section documents the data structures that are used at the NuttX
    interface.
patacongo's avatar
patacongo committed
    <ul>
      <li>Paragraph 3.1 <a href="#ScalarType">Scalar Types</a></li>
      <li>Paragraph 3.2 <a href="#HiddenStructures">Hidden Interface Structures</a></li>
      <li>Paragraph 3.3 <a href="#ErrnoAccess">Access to the <code>errno</code> Variable</a></li>
      <li>Paragraph 3.4 <a href="#UserStructures">User Interface Structures</a></li>
    </ul>
patacongo's avatar
patacongo committed
  </li>
  <li>
patacongo's avatar
patacongo committed
    <a href="#index"><b>Index</b></a>
patacongo's avatar
patacongo committed
  </li>
</ul>

<h2>1.2 <a name="scope">Intended Audience and Scope</a></h2>
<p>
  The intended audience for this document are firmware developers who are implementing applications on NuttX.
  Specifically, this documented is limited to addressing only NuttX RTOS APIs that are available to the application developer.
  As such, this document does not focus on any technical details of the organization or implementation of NuttX.
  Those technical details are provided in the <a href="NuttxPortingGuide.html">NuttX Porting Guide</a>.
</p>
<p>
  Information about configuring and building NuttX is also needed by the application developer.
  That information can also be found in the <a href="NuttxPortingGuide.html#configandbuild">NuttX Porting Guide</a>.
</p>

<hr>

<h1>2.0 <A NAME="OS_Interfaces">OS Interfaces</a></h1>
<p>
  This section describes each C-callable interface to the NuttX
  Operating System. The description of each interface is presented
  in the following format:
<p>
<b>Function Prototype:</b> The C prototype of the interface function
patacongo's avatar
patacongo committed
is provided.
patacongo's avatar
patacongo committed
<p>
<b>Description:</b> The operation performed by the interface function
patacongo's avatar
patacongo committed
is discussed.
patacongo's avatar
patacongo committed
<p>
<b>Input Parameters:</b> All input parameters are listed along
patacongo's avatar
patacongo committed
with brief descriptions of each input parameter.
patacongo's avatar
patacongo committed
<p>
<b>Returned Values:</b> All possible values returned by the interface
patacongo's avatar
patacongo committed
function are listed. Values returned as side-effects (through
pointer input parameters or through global variables) will be
addressed in the description of the interface function.
patacongo's avatar
patacongo committed
<p>
<b>Assumptions/Limitations:</b> Any unusual assumptions made by
patacongo's avatar
patacongo committed
the interface function or any non-obvious limitations to the use
of the interface function will be indicated here.
patacongo's avatar
patacongo committed
<p>
<b>POSIX Compatibility:</b> Any significant differences between the
NuttX interface and its corresponding POSIX interface will be noted
patacongo's avatar
patacongo committed
here.
patacongo's avatar
patacongo committed
<p>
NOTE: In order to achieve an independent name space for the NuttX
patacongo's avatar
patacongo committed
interface functions, differences in function names and types are
to be expected and will not be identified as differences in these
paragraphs.
patacongo's avatar
patacongo committed
<hr>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<H2>2.1 <A NAME="Task_Control">Task Control Interfaces</a></H2>
patacongo's avatar
patacongo committed

<p>
patacongo's avatar
patacongo committed
  <b>Tasks</b>.
patacongo's avatar
patacongo committed
  NuttX is a flat address OS.  As such it does not support <i>processes</i>
patacongo's avatar
patacongo committed
  in the way that, say, Linux does.
  NuttX only supports simple threads running within the same address space.
patacongo's avatar
patacongo committed
  However, the programming model makes a distinction between <i>tasks</i>
  and <i>pthreads</i>:
patacongo's avatar
patacongo committed
</p>
patacongo's avatar
patacongo committed
<ul>
patacongo's avatar
patacongo committed
  <li><i>tasks</i> are threads which have a degree of independence
  <li><a href="#Pthread"><i>pthreads</i></a> share some resources.
patacongo's avatar
patacongo committed
</ul>
<p>
patacongo's avatar
patacongo committed
  <b>File Descriptors and Streams</b>.
  This applies, in particular, in the area of opened file descriptors and streams.
  When a task is started using the interfaces in this section, it will be created
  with at most three open files.
</p>
</p>
  If CONFIG_DEV_CONSOLE is defined, the first three file descriptors (corresponding
  to stdin, stdout, stderr) will be duplicated for the the new task.
  Since these file descriptors are duplicated, the child task can free close
  them or manipulate them in any way without effecting the parent task.
  File-related operations (open, close, etc.) within a task will have no effect
  on other tasks.
  Since the three file descriptors are duplicated, it is also possible to perform
  some level of redirection.
</p>
<p>
  pthreads, on the other hand, will always share file descriptors with the parent
  thread.  In this case, file operations will have effect only all pthreads the
  were started from the same parent thread.
</p>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
  The following task control interfaces are provided by Nuttx:
</p>
<ul>
  <li><a href="#taskcreate">2.1.1 task_create</a></li>
  <li><a href="#taskinit">2.1.2 task_init</a></li>
  <li><a href="#taskactivate">2.1.3 task_activate</a></li>
  <li><a href="#taskdelete">2.1.4 task_delete</a></li>
  <li><a href="#exit">2.1.5 exit</a></li>
  <li><a href="#taskrestart">2.1.6 task_restart</a></li>
  <li><a href="#getpid">2.1.7 getpid</a></li>
</ul>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<H3><a name="taskcreate">2.1.1 task_create</a></H3>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<p>
<b>Function Prototype:</b> 
patacongo's avatar
patacongo committed
   #include &lt;sched.h&gt;
patacongo's avatar
patacongo committed
   int task_create(char *name, int priority, int stack_size, main_t entry, const char *argv[]);
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<p>
<b>Description:</b> 
patacongo's avatar
patacongo committed
   This function creates and activates a new task with a
   specified priority and returns its system-assigned ID.
</p>

patacongo's avatar
patacongo committed
<p>The entry address entry is the address of the &quot;main&quot;
patacongo's avatar
patacongo committed
   function of the task.
   This function will be called once the C environment has been set up.
   The specified function will be called with four arguments.
   Should the specified routine return, a call to exit() will automatically be made.
</P>
<p>
   Note that an arbitrary number of arguments may be passed to the
   spawned functions.  The maximum umber of arguments is an OS
   configuration parameter (<code>CONFIG_MAX_TASK_ARGS</code>).
</p>
<p>
   The arguments are copied (via <code>strdup</code>) so that the
Loading
Loading full blame...