Symbian3/PDK/Source/GUID-EAA6A9FB-A470-550C-B7B4-FF68A733A2D5.dita
changeset 12 80ef3a206772
parent 9 59758314f811
child 14 578be2adaf3e
equal deleted inserted replaced
11:5072524fcc79 12:80ef3a206772
    86 you do not because the thread is not blocked until after the kernel lock is
    86 you do not because the thread is not blocked until after the kernel lock is
    87 released. </p> <p>Be aware however that there may be situations where you
    87 released. </p> <p>Be aware however that there may be situations where you
    88 already have the kernel lock, or in the case of IDFCs, you do not need to
    88 already have the kernel lock, or in the case of IDFCs, you do not need to
    89 acquire it as no preemption can occur. In these cases, you just call <xref href="GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953.dita#GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953/GUID-76E5AE32-9A70-344A-9E6B-5B439622715A"><apiname>NFastMutex::Wait()</apiname></xref> and <xref href="GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953.dita#GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953/GUID-CA8C65D8-E59A-385A-92B8-2B22A4A2F1CB"><apiname>NFastMutex::Signal()</apiname></xref>. </p> <p>The following diagram illustrates the general principle: </p> <fig id="GUID-30A0EA62-83CF-5AB9-A07E-525D0972E55B">
    89 acquire it as no preemption can occur. In these cases, you just call <xref href="GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953.dita#GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953/GUID-76E5AE32-9A70-344A-9E6B-5B439622715A"><apiname>NFastMutex::Wait()</apiname></xref> and <xref href="GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953.dita#GUID-D5B555DA-3D17-3ED2-A931-CB35BD93A953/GUID-CA8C65D8-E59A-385A-92B8-2B22A4A2F1CB"><apiname>NFastMutex::Signal()</apiname></xref>. </p> <p>The following diagram illustrates the general principle: </p> <fig id="GUID-30A0EA62-83CF-5AB9-A07E-525D0972E55B">
    90 <title>Fast mutex</title>
    90 <title>Fast mutex</title>
    91 <image href="GUID-3AFE0D8B-FB9B-5355-A63B-FB71DD13E7D0_d0e300993_href.png" placement="inline"/>
    91 <image href="GUID-3AFE0D8B-FB9B-5355-A63B-FB71DD13E7D0_d0e306985_href.png" placement="inline"/>
    92 </fig> <p>There are a number of assumptions here, one of which is that the
    92 </fig> <p>There are a number of assumptions here, one of which is that the
    93 priorities are such that thread T1 does not run until a reschedule occurs,
    93 priorities are such that thread T1 does not run until a reschedule occurs,
    94 after T2 has been interrupted. </p> <p id="GUID-111E74A3-8442-5598-8BB9-F78E2A77610A"><b>Example
    94 after T2 has been interrupted. </p> <p id="GUID-111E74A3-8442-5598-8BB9-F78E2A77610A"><b>Example
    95 using NFastmutex to protect a critical region</b> </p> <p>The file <filepath>...\f32test\nkern\d_implicit.cpp</filepath> is
    95 using NFastmutex to protect a critical region</b> </p> <p>The file <filepath>...\f32test\nkern\d_implicit.cpp</filepath> is
    96 a device driver that contains 3 threads and 3 separate sub-tests. The third
    96 a device driver that contains 3 threads and 3 separate sub-tests. The third
   487 platform semaphore operations are protected by the <xref href="GUID-EAA6A9FB-A470-550C-B7B4-FF68A733A2D5.dita#GUID-EAA6A9FB-A470-550C-B7B4-FF68A733A2D5/GUID-A0FB7718-F39C-5FB3-B67C-430B490F6430">system lock</xref> fast mutex rather than by locking the kernel. To guarantee
   487 platform semaphore operations are protected by the <xref href="GUID-EAA6A9FB-A470-550C-B7B4-FF68A733A2D5.dita#GUID-EAA6A9FB-A470-550C-B7B4-FF68A733A2D5/GUID-A0FB7718-F39C-5FB3-B67C-430B490F6430">system lock</xref> fast mutex rather than by locking the kernel. To guarantee
   488 this, semaphore operations are done through kernel functions. </p> <p>Although
   488 this, semaphore operations are done through kernel functions. </p> <p>Although
   489 somewhat artificial, and not based on real code, the following diagram nevertheless
   489 somewhat artificial, and not based on real code, the following diagram nevertheless
   490 shows the basic idea behind Symbian platform semaphores. </p> <fig id="GUID-505BC4A5-BBCB-5A63-9795-C751719661BB">
   490 shows the basic idea behind Symbian platform semaphores. </p> <fig id="GUID-505BC4A5-BBCB-5A63-9795-C751719661BB">
   491 <title>Symbian platform semaphore</title>
   491 <title>Symbian platform semaphore</title>
   492 <image href="GUID-0FE0B646-A62F-55A8-A6E6-587D0909CE19_d0e301860_href.png" placement="inline"/>
   492 <image href="GUID-0FE0B646-A62F-55A8-A6E6-587D0909CE19_d0e307852_href.png" placement="inline"/>
   493 </fig> <p id="GUID-6131CDB0-6249-5B9A-A969-9B25F8BCECF5"><b>Rules</b> </p> <p>There
   493 </fig> <p id="GUID-6131CDB0-6249-5B9A-A969-9B25F8BCECF5"><b>Rules</b> </p> <p>There
   494 are a few rules about the use of Symbian platform semaphores: </p> <ul>
   494 are a few rules about the use of Symbian platform semaphores: </p> <ul>
   495 <li id="GUID-B850F00A-D7E6-5542-9D9D-F07F2625E29B"><p>Only Symbian platform
   495 <li id="GUID-B850F00A-D7E6-5542-9D9D-F07F2625E29B"><p>Only Symbian platform
   496 threads are allowed to use Symbian platform semaphores </p> </li>
   496 threads are allowed to use Symbian platform semaphores </p> </li>
   497 <li id="GUID-C848306E-7407-5397-8638-DB6AB7250A4E"><p>An IDFC is not allowed
   497 <li id="GUID-C848306E-7407-5397-8638-DB6AB7250A4E"><p>An IDFC is not allowed