msp_locks.h File Reference

Userspace locking functions for the MultiServices PIC SDK. More...


Data Structures

struct  msp_spinlock_s
 Spinlock data structure. More...

Typedefs

typedef msp_spinlock_s msp_spinlock_t
 Spinlock data structure.

Functions

int msp_spinlock_init (msp_spinlock_t *lock)
 Initializes the spinlock.
int msp_spinlock_lock (msp_spinlock_t *lock)
 Acquires spinlock.
int msp_spinlock_unlock (msp_spinlock_t *lock)
 Releases the spinlock.
int msp_spinlock_trylock (msp_spinlock_t *lock)
 Tries to acquire a spinlock.


Detailed Description

Userspace locking functions for the MultiServices PIC SDK.

This file provides locking functions that can be used in userspace. The first set of functions is spinlocks, implemented using atomic test_and_set instructions. The following assumptions are made about the usage:

These locks are more efficient if the memory for the lock is from OBJCACHE or SHM.

Function Documentation

int msp_spinlock_init msp_spinlock_t lock  ) 
 

Initializes the spinlock.

This function has to be called before using a spinlock. Sets the lock value to 0.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • MSP_INVALID_ARG - lock is passed as NULL.

int msp_spinlock_lock msp_spinlock_t lock  ) 
 

Acquires spinlock.

This function is called to acquire a spinlock. All assumptions listed in the spinlock description apply.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • MSP_INVALID_ARG - lock is passed as NULL.

int msp_spinlock_trylock msp_spinlock_t lock  ) 
 

Tries to acquire a spinlock.

This function is called to try to acquire a spinlock. If there is contention, the function returns an error and the application can retry or move on.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • MSP_EAGAIN on failure to acquire the spinlock, application can retry to acquire the lock.
  • MSP_INVALID_ARG - lock is passed as NULL.

int msp_spinlock_unlock msp_spinlock_t lock  ) 
 

Releases the spinlock.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • MSP_INVALID_ARG - lock is passed as NULL.


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:24:47 2010 for libmp-sdk by Doxygen 1.4.5