Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e3d62627d1d1aab7ab1be2dd7f65a872 > files > 270

ecl-10.4.1-1.fc14.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;4.&#160;Multithreading</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="pt02.html" title="Part&#160;II.&#160;Extensions and libraries"><link rel="prev" href="ch18s05.html" title="3.5.&#160;FFI Reference"><link rel="next" href="ch19s02.html" title="4.2.&#160;MP Reference"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;4.&#160;Multithreading</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch18s05.html">Prev</a>&#160;</td><th width="60%" align="center">Part&#160;II.&#160;Extensions and libraries</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch19s02.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&#160;4.&#160;Multithreading"><div class="titlepage"><div><div><h2 class="title"><a name="mp"></a>Chapter&#160;4.&#160;Multithreading</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ch19.html#ext.mp.threads">4.1. Tasks, threads or processes</a></span></dt><dt><span class="section"><a href="ch19s02.html">4.2. MP Reference</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="re15.html"><code class="function">mp:all-processes</code></a></span><span class="refpurpose"> &#8212; Return the list of active processes.</span></dt><dt><span class="refentrytitle"><a href="re16.html"><code class="function">mp:exit-process</code></a></span><span class="refpurpose"> &#8212; Exit the task from which it is invoked.</span></dt><dt><span class="refentrytitle"><a href="re17.html"><code class="function">mp:interrupt-process</code></a></span><span class="refpurpose"> &#8212; Interrupt a task.</span></dt><dt><span class="refentrytitle"><a href="re18.html"><code class="function">mp:get-lock</code></a></span><span class="refpurpose"> &#8212; Try to obtain a lock.</span></dt><dt><span class="refentrytitle"><a href="re19.html"><code class="function">mp:giveup-lock</code></a></span><span class="refpurpose"> &#8212; Release a lock we have obtained before.</span></dt><dt><span class="refentrytitle"><a href="re20.html"><code class="function">mp:make-lock</code></a></span><span class="refpurpose"> &#8212; Create a new lock.</span></dt><dt><span class="refentrytitle"><a href="re21.html"><code class="function">mp:make-process</code></a></span><span class="refpurpose"> &#8212; Create a new thread.</span></dt><dt><span class="refentrytitle"><a href="re22.html"><code class="function">mp:process-active-p</code></a></span><span class="refpurpose"> &#8212; Determine whether a task is running.</span></dt><dt><span class="refentrytitle"><a href="re23.html"><code class="function">mp:process-enable</code></a></span><span class="refpurpose"> &#8212; Start up a task which was not running.</span></dt><dt><span class="refentrytitle"><a href="re24.html"><code class="function">mp:process-kill</code></a></span><span class="refpurpose"> &#8212; Try to stop a running task.</span></dt><dt><span class="refentrytitle"><a href="re25.html"><code class="function">mp:process-name</code></a></span><span class="refpurpose"> &#8212; Return the name of a task.</span></dt><dt><span class="refentrytitle"><a href="re26.html"><code class="function">mp:process-preset</code></a></span><span class="refpurpose"> &#8212; Associate a function to a process.</span></dt><dt><span class="refentrytitle"><a href="re27.html"><code class="function">mp:process-run-function</code></a></span><span class="refpurpose"> &#8212; Create a task and execute a function in it.</span></dt><dt><span class="refentrytitle"><a href="re28.html"><code class="function">mp:with-lock</code></a></span><span class="refpurpose"> &#8212; Synchronize a piece of code between different tasks.</span></dt></dl></dd></dl></div><div class="section" title="4.1.&#160;Tasks, threads or processes"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ext.mp.threads"></a>4.1.&#160;Tasks, threads or processes</h2></div></div></div><p>On most platforms, <span class="application">ECL</span> supports native multithreading. That means
   there can be several tasks executing lisp code on parallel and sharing
   memory, variables and files. The interface for multitasting in <span class="application">ECL</span>, like
   those of most other implementations, is based on a set of functions and
   types that resemble the multiprocessing capabilities of old Lisp Machines.
   </p><p>This backward compatibility is why tasks or threads are called
   "processes". However, they should not be confused with operating system
   processes, which are made of programs running in separate contexts and
   without access to each other's memory.</p><p>The implementation of threads in <span class="application">ECL</span> is purely native and based on
   Posix Threads wherever avaiable. The use of native threads has
   advantanges. For instance, they allow for non-blocking file operations,
   so that while one task is reading a file, a different one is performing
   a computation.</p><p>As mentioned above, tasks share the same memory, as well as the set of
   open files and sockets. This manifests on two features. First of all,
   different tasks can operate on the same lisp objects, reading and writing
   their slots, or manipulating the same arrays. Second, while threads share
   global variables, constants and function definitions they can also have
   thread-local bindings to special variables that are not seen by other
   tasks.</p><p>The fact that different tasks have access to the same set of data
   allows both for flexibility and a greater risk. In order to control access
   to different resources, <span class="application">ECL</span> provides the user with locks, as explained in
   the next section.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch18s05.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="pt02.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch19s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.5.&#160;FFI Reference&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;4.2.&#160;MP Reference</td></tr></table></div></body></html>