/home/dko/projects/mobilec/trunk/src/include/barrier.h

Go to the documentation of this file.
00001 /*[
00002  * Copyright (c) 2007 Integration Engineering Laboratory
00003                       University of California, Davis
00004  *
00005  * Permission to use, copy, and distribute this software and its
00006  * documentation for any purpose with or without fee is hereby granted,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.
00010  *
00011  * Permission to modify the software is granted, but not the right to
00012  * distribute the complete modified source code.  Modifications are to
00013  * be distributed as patches to the released version.  Permission to
00014  * distribute binaries produced by compiling modified sources is granted,
00015  * provided you
00016  *   1. distribute the corresponding source modifications from the
00017  *    released version in the form of a patch file along with the binaries,
00018  *   2. add special version identification to distinguish your version
00019  *    in addition to the base release version number,
00020  *   3. provide your name and address as the primary contact for the
00021  *    support of your modified version, and
00022  *   4. retain our contact information in regard to use of the base
00023  *    software.
00024  * Permission to distribute the released version of the source code along
00025  * with corresponding source modifications in the form of a patch file is
00026  * granted with same provisions 2 through 4 for binary distributions.
00027  *
00028  * This software is provided "as is" without express or implied warranty
00029  * to the extent permitted by applicable law.
00030 ]*/
00031 
00032 #ifndef _BARRIER_H_
00033 #define _BARRIER_H_
00034 
00035 #include"macros.h"
00036 #include"../mc_list/list.h"
00037 #include"mc_rwlock.h"
00038 
00039 typedef struct barrier_node_s {
00040     MUTEX_T* lock;
00041     COND_T* cond;
00042     int id;
00043     int num_registered;
00044     int num_waiting;
00045 } barrier_node_t;
00046 typedef barrier_node_t* barrier_node_p;
00047 
00048 typedef struct barrier_queue_s {
00049     RWLOCK_T* lock;
00050     
00051     list_p list;
00052     int size;
00053 } barrier_queue_t;
00054 typedef barrier_queue_t* barrier_queue_p;
00055 
00056 /* Node Funcs */
00057 
00058 barrier_node_p
00059 barrier_node_Initialize(int id, int num_registered);
00060 
00061 int 
00062 barrier_node_Destroy(barrier_node_p node);
00063 
00064 /* List Funcs */
00065 
00066 int 
00067 barrier_queue_Add(barrier_queue_p list, barrier_node_p node);
00068 
00069 int 
00070 barrier_queue_Delete(int id, barrier_queue_p list);
00071 
00072 int barrier_queue_Destroy(barrier_queue_p queue);
00073 
00074 barrier_node_p
00075 barrier_queue_Get(barrier_queue_p list, int id);
00076 
00077 barrier_queue_p 
00078 barrier_queue_New(void);
00079 
00080 barrier_node_p
00081 barrier_queue_Pop(barrier_queue_p queue);
00082 #endif

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4