msp_ucrit.h File Reference

Userspace critical section support for the MultiServices PIC SDK. More...


Data Structures

struct  msp_ucrit_attr
 Ucrit attribute structure. More...

Typedefs

typedef msp_ucrit_attr msp_ucrit_attr_t
 Ucrit attribute structure.

Functions

int msp_ucrit_attr_init (msp_ucrit_attr_t *)
 Initialize a msp_ucrit_attr.
int msp_ucrit_attr_destroy (msp_ucrit_attr_t *)
 Destroy a msp_ucrit_attr.
int msp_ucrit_attr_setmaxthreads (msp_ucrit_attr_t *, int)
 Set the maximum threads to be supported by the user critical subsystem.
int msp_ucrit_attr_getmaxthreads (msp_ucrit_attr_t *, int *)
 Return the number of threads a msp_ucrit_attr has been initialized to.
int msp_ucrit_init_proc (msp_ucrit_attr_t *)
 Initialize the user critical subsystem for a process.
int msp_ucrit_init_thread (void)
 Initialize a ucrit subsystem for a thread.
void msp_ucrit_enter (void)
 Enter a critical region.
void msp_ucrit_exit (void)
 Exit a critical region.
int msp_ucrit_shouldyield (void)
 Test if we should call yield.
void msp_ucrit_yield (void)
 Yield the cpu.
int msp_ucrit_spinlock_lock (msp_spinlock_t *)
 Lock a spinlock and enter a critical region.
int msp_ucrit_spinlock_unlock (msp_spinlock_t *)
 Unlock a spinlock and exit critical region.


Detailed Description

Userspace critical section support for the MultiServices PIC SDK.

This file contains critical section functions that can be used in userspace.

It is assumed that critical sections will be used for short intervals and that threads making use of them MUST be bound to a cpu for them to be effective, see msp_process_bind().


Typedef Documentation

typedef struct msp_ucrit_attr msp_ucrit_attr_t
 

Ucrit attribute structure.

Do not access directly, use accessors functions "msp_ucrit_attr_*" below.


Function Documentation

int msp_ucrit_attr_destroy msp_ucrit_attr_t  ) 
 

Destroy a msp_ucrit_attr.

Must be called after using a msp_ucrit_attr.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • no error codes defined yet.

int msp_ucrit_attr_getmaxthreads msp_ucrit_attr_t ,
int * 
 

Return the number of threads a msp_ucrit_attr has been initialized to.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • no error codes defined yet.

int msp_ucrit_attr_init msp_ucrit_attr_t  ) 
 

Initialize a msp_ucrit_attr.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • no error codes defined yet.

int msp_ucrit_attr_setmaxthreads msp_ucrit_attr_t ,
int 
 

Set the maximum threads to be supported by the user critical subsystem.

Returns:
MSP_OK on success; otherwise, returns an error code:
  • no error codes defined yet.

void msp_ucrit_enter void   ) 
 

Enter a critical region.

No other user level processing will be allowed on this cpu until msp_ucrit_exit() is called.

Can be nested.

void msp_ucrit_exit void   ) 
 

Exit a critical region.

Will yield the cpu if not inside a nested critical region and the kernel has attempted to schedule while critical.

int msp_ucrit_init_proc msp_ucrit_attr_t  ) 
 

Initialize the user critical subsystem for a process.

Should only be called once per process.

Returns:
MSP_OK on success; otherwise, returns unix errno.

int msp_ucrit_init_thread void   ) 
 

Initialize a ucrit subsystem for a thread.

Should be called at startup by any thread that wishes to make use of critical sections or critical spinlocks.

Returns:
MSP_OK on success; otherwise, returns unix errno.

int msp_ucrit_shouldyield void   ) 
 

Test if we should call yield.

Returns:
0 if no yield is needed; otherwise returns non-zero.

int msp_ucrit_spinlock_lock msp_spinlock_t  ) 
 

Lock a spinlock and enter a critical region.

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

int msp_ucrit_spinlock_unlock msp_spinlock_t  ) 
 

Unlock a spinlock and exit critical region.

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

void msp_ucrit_yield void   ) 
 

Yield the cpu.

If called in a nested critical context will still yield.


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