1    /* 
     2     *  Copyright (c) 2008 Texas Instruments. All rights reserved. 
     3     *  This program and the accompanying materials are made available under the 
     4     *  terms of the Eclipse Public License v1.0 and Eclipse Distribution License
     5     *  v. 1.0 which accompanies this distribution. The Eclipse Public License is
     6     *  available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
     7     *  Distribution License is available at 
     8     *  http://www.eclipse.org/org/documents/edl-v10.php.
     9     *
    10     *  Contributors:
    11     *      Texas Instruments - initial implementation
    12     * */
    13    /*
    14     *  ======== Semaphore.xdc ========
    15     */
    16    
    17    import xdc.runtime.Assert;
    18    import xdc.runtime.Error;
    19    import xdc.runtime.knl.ISemaphore;
    20    
    21    /*!
    22     *  ======== Semaphore ========
    23     *  Provides semaphore services when an ISemaphore.Handle is available. 
    24     *  
    25     *  An application can isolate itself from ISemaphore implementations by using 
    26     *  this module. The application must first obtain an ISemaphore.Handle. 
    27     *  It make get such a handle by directly calling {@link SemThread#create} or 
    28     *  {@link SemProcess#create}. Then the application can use the generic 
    29     *  APIs provided by this module.
    30     */
    31    
    32    module Semaphore
    33    {
    34        /*!
    35         *  ======== PendStatus ========
    36         *  Error codes returned by Semaphore_pend
    37         */
    38        enum PendStatus {
    39            PendStatus_ERROR = -1,
    40            PendStatus_TIMEOUT = 0,
    41            PendStatus_SUCCESS = 1
    42        };
    43    
    44        /*! Used as the timeout value to specify wait forever */
    45        const UInt FOREVER = ISemaphore.FOREVER;
    46        
    47        /*!
    48         *  Proxy used for optimization.
    49         *
    50         *  If ALL ISemaphore.Handles were created using the same module 
    51         *  (e.g SemProcess) then setting this Proxy to SemProcess and 
    52         *  setting Semaphore.Proxy.abstractInstances$ = false, 
    53         *  Semaphore APIs can have better performance.
    54         */
    55        proxy Proxy inherits ISemaphore;
    56    
    57        /*!
    58         *  ======== pend ========
    59         *  Wait for the semaphore to have a nonzero count, then decrement it.
    60         *
    61         *  @p(blist)
    62         *  -{@link #PendStatus_ERROR} if an error occured.
    63         *  -{@link #PendStatus_TIMEOUT} denotes timeout.
    64         *  -{@link #PendStatus_SUCCESS} semaphore was decremented. 
    65         *    details.
    66         *  @p
    67         *
    68         *  @param(sem)     ISemaphore.Handle to be used
    69         *  @param(timeout) timeout in microseconds
    70         *  @param(eb)      Pointer to Error.Block
    71         *  @a(returns)     status returned. (refer to above description)
    72         */
    73        Int pend(ISemaphore.Handle sem, UInt timeout, Error.Block *eb);
    74    
    75        /*!
    76         *  ======== post ========
    77         *  Increment the semaphore count.
    78         *
    79         *  @param(sem)     ISemaphore.Handle to be used
    80         *  @param(eb)      Pointer to Error.Block
    81         *  @a(returns)     true for success, false for error in Error block.  
    82         */
    83        Bool post(ISemaphore.Handle sem, Error.Block *eb);
    84    }
    85    /*
    86     *  @(#) xdc.runtime.knl; 1, 0, 0,181; 2-10-2012 10:18:55; /db/ztree/library/trees/xdc/xdc-y21x/src/packages/
    87     */
    88