Skip to content
Snippets Groups Projects
NuttxUserGuide.html 241 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>
<table width ="100%">
  <tr align="center" bgcolor="#e4e4e4">
    <td>
      <h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1>
      <p><small>by</small></p>
      <p>Gregory Nutt<p>
patacongo's avatar
patacongo committed
      <p>Last Updated: May 22, 2009</p>
    </td>
  </tr>
</table>
<hr><hr>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="Introduction"><h1>1.0 Introduction</h1></a>
  </td>
  </tr>
</table>
patacongo's avatar
patacongo committed

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

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="overview"><h2>1.1 Document Overview</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<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>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="scope"><h2>1.2 Intended Audience and Scope</h2></a>
  </td>
  </tr>
</table>

patacongo's avatar
patacongo committed
<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>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="OS_Interfaces"><h1>2.0 OS Interfaces</h1></a>
  </td>
  </tr>
</table>
patacongo's avatar
patacongo committed

<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

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="Task_Control"><h2>2.1 Task Control Interfaces</h2></a>
  </td>
  </tr>
</table>
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 new task.
patacongo's avatar
patacongo committed
  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:
patacongo's avatar
patacongo committed
</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

Loading
Loading full blame...