Symbian3/PDK/Source/GUID-AF07AD54-86F1-5DB7-80FF-633A559DA4BD.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-AF07AD54-86F1-5DB7-80FF-633A559DA4BD" xml:lang="en"><title>Creating
       
    13 Processes and Threads </title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <section id="GUID-6E0A2832-98BA-54AF-B7A7-28DFFD5FEC76"><title>Introduction</title> <p>Process
       
    15 creation on Unix-like machines is normally done in two stages. Firstly, <codeph>fork()</codeph> is
       
    16 called. This creates a child process, which is a clone of the calling (parent)
       
    17 process. The child process is identical (except for a few details) to the
       
    18 parent. Secondly, a call to one of the <codeph>exec()</codeph> family functions
       
    19 is invoked by the child which changes the program being executed by that process.
       
    20 For more information about <codeph>fork()</codeph> or <codeph>exec()</codeph>,
       
    21 see <xref href="http://www.opengroup.org" scope="external">Open Group</xref>. </p> <p>P.I.P.S.
       
    22 does not support <codeph>fork()</codeph> and <codeph>exec()</codeph> and the
       
    23 reasons for the same are described in the following sections. However, there
       
    24 are industry standard alternatives supported by P.I.P.S. and are detailed
       
    25 in the following sections: </p> <ul>
       
    26 <li><p><xref href="GUID-ADB9AD91-37A2-4FE6-B378-C43CD0A7B513.dita">Alternatives
       
    27 to <codeph>fork()</codeph> and <codeph>exec()</codeph> for creating child
       
    28 processes</xref></p></li>
       
    29 <li><p><xref href="GUID-545DA961-217E-49CA-A90E-7A41E2C03A99.dita">Forking without <codeph>exec()</codeph></xref></p></li>
       
    30 <li><p><xref href="GUID-B58D282E-E6EC-4AE1-96DB-30A5FB850563.dita"><codeph>exec()</codeph> without
       
    31 forking using <apiname>posix_spawn()</apiname></xref></p></li>
       
    32 </ul> <p><b>Omission of fork()</b> </p> <p>A Unix-like kernel
       
    33 is designed with the two stage process creation in mind. On Symbian platform
       
    34 (and Microsoft Windows®) the kernel was designed to create a process, which
       
    35 runs a single executable, in a single step. </p> <p>P.I.P.S. does not implement
       
    36 the <codeph>fork()</codeph> operation because this would require an entirely
       
    37 new way of dealing with processes in the kernel and memory model. For example,
       
    38 duplicating the address space of an existing process was not something that
       
    39 was considered in the Symbian platform kernel's design. Symbian took this
       
    40 decision as the effort involved in customising this feature would be more
       
    41 than the benefit of providing the <codeph>fork()</codeph> function, especially
       
    42 in the provision of Pthreads. For more information about Pthreads, see the <xref href="http://en.wikipedia.org/wiki/POSIX_Threads" scope="external">Pthread
       
    43 Wikipage</xref>. </p> <p><b>Omission of exec()</b> </p> <p>On Unix-like systems, <codeph>exec()</codeph> is
       
    44 the standard way to load a process image into memory. Only the initialisation
       
    45 process is loaded directly into a new address space (special case code in
       
    46 the kernel), all other processes are loaded into an existing address space
       
    47 which was initially created by forking. </p> <p>On Symbian platform, the only
       
    48 way to load a process image into memory is using the loader. It assumes that
       
    49 the image is being loaded as a new process - one that owns no resources, has
       
    50 no open handles and so on. The change to the loader and any associated kernel
       
    51 changes, to support the <codeph>exec()</codeph> function were deemed to be
       
    52 too risky. </p> <p><b>Generic IPC</b> </p> <p>P.I.P.S. supports two types
       
    53 of Inter-Process Communication (IPC) between processes or threads: </p> <ul>
       
    54 <li><p> <b>Pipes (named and unnamed):</b> Unnamed pipes are created using <xref href="GUID-EC7F85FF-FD4E-324C-8D01-EF6F7E7A79FE.dita"><apiname>pipe()</apiname></xref> and
       
    55 named pipes are created using <xref href="GUID-F4749DAA-1B29-3D1D-A3AA-0D52B851E501.dita"><apiname>mkfifo()</apiname></xref>. Pipe-based communication
       
    56 is also possible between a parent and a child process when the child is created
       
    57 using <xref href="GUID-A9DB6E7C-B8D6-377A-BBE6-39E0A7A09E5D.dita"><apiname>popen()</apiname></xref> or <xref href="GUID-A1E2E172-C4E4-30FB-99CF-E4140E31DF59.dita"><apiname>popen3()</apiname></xref>. </p></li>
       
    58 <li><p> <b>Local file sockets:</b> These correspond to sockets created with <codeph>AF_LOCAL/PF_LOCAL/AF_UNIX</codeph> as
       
    59 the address family. The semantics of their use are similar to those of their
       
    60 Unix equivalents. </p></li>
       
    61 </ul> </section>
       
    62 </conbody><related-links>
       
    63 <link href="GUID-6590B534-D976-5305-BE95-48DD05120DFB.dita#GUID-6590B534-D976-5305-BE95-48DD05120DFB/GUID-3CA8FF29-79B4-5D43-8A23-EDB136BF7A8F">
       
    64 <linktext>One Definition Rule - warning</linktext></link>
       
    65 </related-links></concept>