~ubuntu-branches/ubuntu/karmic/ocaml-doc/karmic

« back to all changes in this revision

Viewing changes to ocaml.html/manual037.html

  • Committer: Bazaar Package Importer
  • Author(s): Vanicat Rémi
  • Date: 2002-02-05 10:51:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020205105143-a061tunf8tev07ne
Tags: 3.04-4
* New debian maintainer
* Split doc-base file
* Move to non-free
* Change the copyright file to the copyright of the documentation
* remove FAQs (their license prohibit their redistribution)
* corrected the examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 
2
            "http://www.w3.org/TR/REC-html40/loose.dtd">
 
3
<HTML>
 
4
<HEAD>
 
5
 
 
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
7
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
 
8
<TITLE>
 
9
 The threads library
 
10
</TITLE>
 
11
</HEAD>
 
12
<BODY TEXT=black BGCOLOR=white>
 
13
<A HREF="manual036.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
 
14
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
15
<A HREF="manual038.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
 
16
<HR>
 
17
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
18
<TR><TD BGCOLOR="#2de52d"><DIV ALIGN=center><TABLE>
 
19
<TR><TD><A NAME="htoc228"><B><FONT SIZE=6>Chapter&nbsp;23</FONT></B></A></TD>
 
20
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=6>The threads library</FONT></B></TD>
 
21
</TR></TABLE></DIV></TD>
 
22
</TR></TABLE>
 
23
<A NAME="c:threads"></A>
 
24
<BR>
 
25
The <TT>threads</TT> library allows concurrent programming in Objective Caml.
 
26
It provides multiple threads of control (also called lightweight
 
27
processes) that execute concurrently in the same memory space. Threads
 
28
communicate by in-place modification of shared data structures, or by
 
29
sending and receiving data on communication channels.<BR>
 
30
<BR>
 
31
The <TT>threads</TT> library is implemented by time-sharing on a single
 
32
processor. It will not take advantage of multi-processor machines.
 
33
Using this library will therefore never make programs run
 
34
faster. However, many programs are easier to write when structured as
 
35
several communicating processes.<BR>
 
36
<BR>
 
37
 
 
38
&nbsp;&nbsp;<FONT COLOR=purple>Unix:</FONT>
 
39
<BLOCKQUOTE>
 
40
Programs that use the <TT>threads</TT> library must be linked as follows:
 
41
<PRE>
 
42
        ocamlc -thread <I>other options</I> threads.cma <I>other files</I>
 
43
</PRE>
 
44
The <TT>-thread</TT> option selects a special, thread-safe version of
 
45
the standard library (see chapter&nbsp;<A HREF="manual022.html#c:camlc">8</A>). The <TT>-thread</TT>
 
46
option must also be given when compiling any source file that
 
47
references modules from the thread library (<TT>Thread</TT>, <TT>Mutex</TT>, ...).<BR>
 
48
<BR>
 
49
The default thread implementation cannot be used in native-code
 
50
programs compiled with <TT>ocamlopt</TT>. If your operating system provides
 
51
POSIX 1003.1c compliant threads, you can select an alternate
 
52
implementation when configuring Objective Caml (use the
 
53
<TT>-with-pthread</TT> option to <TT>configure</TT>) which also supports native-code
 
54
programs. Programs that use this alternate implementation of the
 
55
<TT>threads</TT> library must be linked as follows:
 
56
<PRE>
 
57
        ocamlc -thread <I>other options</I> threads.cma <I>other files</I>
 
58
        ocamlopt -thread <I>other options</I> threads.cmxa <I>other files</I>
 
59
</PRE>
 
60
Depending on the operating system, extra system libraries can be
 
61
necessary. For instance, under Solaris 2.5, add <TT>-cclib -lposix4</TT>
 
62
at the end of the command line.
 
63
</BLOCKQUOTE>
 
64
 
 
65
&nbsp;&nbsp;<FONT COLOR=purple>Windows:</FONT>
 
66
<BLOCKQUOTE>
 
67
Programs that use the <TT>threads</TT> library must be linked as follows:
 
68
<PRE>
 
69
        ocamlc -thread <I>other options</I> threads.cma <I>other files</I>
 
70
</PRE>
 
71
All object files on the command line must also have been compiled with
 
72
the <TT>-thread</TT> option, which selects a special, thread-safe version of
 
73
the standard library (see chapter&nbsp;<A HREF="manual022.html#c:camlc">8</A>).
 
74
</BLOCKQUOTE>
 
75
 
 
76
<ul>
 
77
<li><a HREF=libref/Thread.html> Module <tt>Thread</tt>: lightweight threads</a></li>
 
78
<li><a HREF=libref/Mutex.html> Module <tt>Mutex</tt>: locks for mutual exclusion</a></li>
 
79
<li><a HREF=libref/Condition.html> Module <tt>Condition</tt>: condition variables to synchronize between threads</a></li>
 
80
<li><a HREF=libref/Event.html> Module <tt>Event</tt>: first-class synchronous communication</a></li>
 
81
<li><a HREF=libref/ThreadUnix.html> Module <tt>ThreadUnix</tt>: thread-compatible system calls</a></li>
 
82
</ul>
 
83
 
 
84
<BR>
 
85
<BR>
 
86
<HR>
 
87
<A HREF="manual036.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
 
88
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
89
<A HREF="manual038.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
 
90
</BODY>
 
91
</HTML>