Rendezvous

Implements a thread synchronization module. It can be used for synchronizing the initialization of a number of threads. When a thread is done initializing it calls Rendezvous_meet(), and when all threads has called this method they will all be unblocked to continue execution. Example below:. More...

Data Structures

struct  Rendezvous_Attrs
 Attributes used to create a Rendezvous. More...

Defines

#define Rendezvous_INFINITE   -1

Typedefs

typedef struct Rendezvous_Object * Rendezvous_Handle
 Handle through which to reference a Rendezvous Object.

Functions

Rendezvous_Handle Rendezvous_create (Int count, Rendezvous_Attrs *attrs)
 Creates a Rendezvous Object. Must be called before a Rendezvous_Handle can be used in subsequent operations.
Void Rendezvous_meet (Rendezvous_Handle hRv)
 Called by a thread when it's ready to meet up with other threads. This will register that the thread is ready, and will block the calling thread until a total number of count threads have called this function on this Rendezvous object. When this happens, all threads are unblocked at once and the Rendezvous object will be reset to it's original count.
Void Rendezvous_force (Rendezvous_Handle hRv)
 This call forces all threads blocking in Rendezvous_meet to unblock no matter what the state of the Rendezvous object. Useful for e.g. error cleanup. To reuse a Rendezvous object after this call, Rendezvous_reset must be called.
Void Rendezvous_reset (Rendezvous_Handle hRv)
 This call resets the Rendezvous object to it's original count at opening time.
Void Rendezvous_forceAndReset (Rendezvous_Handle hRv)
 This call is equivalent to calling Rendezvous_force followed by Rendezvous_reset in a single operation. This will ensure that calls to Rendezvous_meet will not fail to block in-between the calls to Rendezvous_force and Rendezvous_reset if they were called separately.
Int Rendezvous_delete (Rendezvous_Handle hRv)
 Deletes a previously created Rendezvous object.

Variables

const Rendezvous_Attrs Rendezvous_Attrs_DEFAULT
 Default attributes for a Rendezvous.

Detailed Description

Implements a thread synchronization module. It can be used for synchronizing the initialization of a number of threads. When a thread is done initializing it calls Rendezvous_meet(), and when all threads has called this method they will all be unblocked to continue execution. Example below:.

 main:
   #include <xdc/std.h>
   #include <ti/sdo/dmai/Dmai.h>
   #include <ti/sdo/dmai/Rendezvous.h>

   Rendezvous_Attrs rzvAttrs = Rendezvous_Attrs_DEFAULT;
   Dmai_init();
   // We want to synchronize 2 threads:
   Rendezvous_Handle hRv = Rendezvous_create(2, &rzvAttrs);

 thread1:
   extern Rendezvous_Handle hRv;
   // Do thread initialization
   // Thread will block here until thread2 is done with init also:
   Rendezvous_meet(hRv);
   // Do main loop when both threads are done initializing.

 thread2:
   extern Rendezvous_Handle hRv;
   // Do thread initialization
   // Thread will block here until thread1 is done with init also:
   Rendezvous_meet(hRv);
   // Do main loop when both threads are done initializing.

Define Documentation

#define Rendezvous_INFINITE   -1


Typedef Documentation

typedef struct Rendezvous_Object* Rendezvous_Handle

Handle through which to reference a Rendezvous Object.


Function Documentation

Rendezvous_Handle Rendezvous_create ( Int  count,
Rendezvous_Attrs attrs 
)

Creates a Rendezvous Object. Must be called before a Rendezvous_Handle can be used in subsequent operations.

Parameters:
count Number of threads to synchronize. Use Rendezvous_INFINITE for a Rendezvous that can only be unblocked with Rendezvous_force or Rendezvous_forceAndReset.
[in] attrs Rendezvous_Attrs to use for creating the Rendezvous instance.
Return values:
Handle for use in subsequent operations (see Rendezvous_Handle)
NULL for failure.

Void Rendezvous_meet ( Rendezvous_Handle  hRv  ) 

Called by a thread when it's ready to meet up with other threads. This will register that the thread is ready, and will block the calling thread until a total number of count threads have called this function on this Rendezvous object. When this happens, all threads are unblocked at once and the Rendezvous object will be reset to it's original count.

Parameters:
hRv The Rendezvous_Handle in which to meet.
Remarks:
Rendezvous_create must be called before this function.

Void Rendezvous_force ( Rendezvous_Handle  hRv  ) 

This call forces all threads blocking in Rendezvous_meet to unblock no matter what the state of the Rendezvous object. Useful for e.g. error cleanup. To reuse a Rendezvous object after this call, Rendezvous_reset must be called.

Parameters:
hRv The Rendezvous_Handle to force.
Remarks:
Rendezvous_create must be called before this function.

Void Rendezvous_reset ( Rendezvous_Handle  hRv  ) 

This call resets the Rendezvous object to it's original count at opening time.

Parameters:
hRv The Rendezvous_Handle to reset.
Remarks:
Rendezvous_create must be called before this function.

Void Rendezvous_forceAndReset ( Rendezvous_Handle  hRv  ) 

This call is equivalent to calling Rendezvous_force followed by Rendezvous_reset in a single operation. This will ensure that calls to Rendezvous_meet will not fail to block in-between the calls to Rendezvous_force and Rendezvous_reset if they were called separately.

Parameters:
hRv The Rendezvous_Handle to force.
Remarks:
Rendezvous_create must be called before this function.

Int Rendezvous_delete ( Rendezvous_Handle  hRv  ) 

Deletes a previously created Rendezvous object.

Parameters:
hRv The Rendezvous_Handle to delete.
Return values:
Dmai_EOK for success.
Negative value for failure, see Dmai.h.
Remarks:
Rendezvous_create must be called before this function.


Variable Documentation

Default attributes for a Rendezvous.


Copyright 2011, Texas Instruments Incorporated