os/ossrv/genericopenlibs/openenvcore/libpthread/src/mutexgeneric.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Name       : mutexgeneric.cpp
    15 // Part of    : PThread library
    16 // APIs needed for implementing pthread mutex APIs 
    17 // are implemented.
    18 // Version    :
    19 //
    20 
    21 
    22 
    23 #include "threadglobals.h"
    24 #include "threadcreate.h"
    25 
    26 int _pthread_atomicMutexLock(void *tlsPtr)
    27 {
    28     _pthread_node_t *selfNodePtr;
    29     _global_data_t *glbPtr;
    30     
    31     THR_PRINTF("[pthread] Begin _pthread_atomicMutexLock\n");
    32     if (NULL == tlsPtr)
    33     {
    34         THR_PRINTF("[pthread] FATAL: TLS is NULL\n");
    35         return -1;
    36     }
    37     
    38     selfNodePtr = (_pthread_node_t *)tlsPtr;
    39     
    40     // Global data strcuture Pointer 
    41     glbPtr = selfNodePtr->glbDataPtr;
    42     
    43     glbPtr->globalLockForMutex.Wait(); 
    44     THR_PRINTF("[pthread] End _pthread_atomicMutexLock\n");    
    45     return 0;
    46 }
    47 
    48 int _pthread_atomicMutexUnlock(void *tlsPtr)
    49 {
    50     _pthread_node_t *selfNodePtr;
    51     _global_data_t *glbPtr;
    52     
    53     THR_PRINTF("[pthread] Begin _pthread_atomicMutexUnlock\n");
    54     if (NULL == tlsPtr)
    55     {
    56         THR_PRINTF("[pthread] FATAL: TLS is NULL\n");
    57         return -1;
    58     }
    59     
    60     selfNodePtr = (_pthread_node_t *)tlsPtr;
    61     
    62     // Global data strcuture Pointer 
    63     glbPtr = selfNodePtr->glbDataPtr;
    64     
    65     glbPtr->globalLockForMutex.Signal(); 
    66     
    67     THR_PRINTF("[pthread] End _pthread_atomicMutexUnlock\n");
    68     return 0;
    69 }
    70 
    71 // End of file