]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/rtl/rwlock.h
162568594edd8bcde4ff7bc9db4cf6e18c283dfb
[orte.git] / orte / include / rtl / rwlock.h
1 /*
2  *  $Id: rwlock.h,v 0.0.0.1             2003/12/19 
3  *
4  *  -------------------------------------------------------------------  
5  *                                ORTE                                 
6  *                      Open Real-Time Ethernet                       
7  *                                                                    
8  *                      Copyright (C) 2001-2006                       
9  *  Department of Control Engineering FEE CTU Prague, Czech Republic  
10  *                      http://dce.felk.cvut.cz                       
11  *                      http://www.ocera.org                          
12  *                                                                    
13  *  Author:              Petr Smolik    petr.smolik@wo.cz             
14  *  Advisor:             Pavel Pisa                                   
15  *  Project Responsible: Zdenek Hanzalek                              
16  *  --------------------------------------------------------------------
17  *
18  *  This program is free software; you can redistribute it and/or modify
19  *  it under the terms of the GNU General Public License as published by
20  *  the Free Software Foundation; either version 2 of the License, or
21  *  (at your option) any later version.
22  *  
23  *  This program is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *  GNU General Public License for more details.
27  *  
28  */
29
30 #ifndef _RWLOCK_H
31 #define _RWLOCK_H
32
33 #define PTW32_RWLOCK_MAGIC 0xfacade2
34 #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1)
35
36 typedef struct pthread_rwlock_t_ *pthread_rwlock_t;
37 typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t;
38 struct pthread_rwlock_t_ {
39   pthread_mutex_t   mtxExclusiveAccess;
40   pthread_mutex_t   mtxSharedAccessCompleted;
41   pthread_cond_t    cndSharedAccessCompleted;
42   int               nSharedAccessCount;
43   int               nExclusiveAccessCount;
44   int               nCompletedSharedAccessCount;
45   int               nMagic;
46 };
47               
48 struct pthread_rwlockattr_t_ {
49   int               pshared;
50 };
51 extern void ptw32_rwlock_cancelwrwait(void * arg);
52
53 extern int
54 ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
55
56 extern int pthread_rwlock_init(pthread_rwlock_t *lock,
57                                const pthread_rwlockattr_t *attr);
58
59 extern int pthread_rwlock_destroy(pthread_rwlock_t *lock);
60
61 extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
62
63 extern int pthread_rwlock_trywrlock(pthread_rwlock_t *);
64
65 extern int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
66
67 extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
68                                       const struct timespec *abstime);
69
70 extern int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
71
72 extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
73                                       const struct timespec *abstime);
74
75 extern int pthread_rwlock_unlock(pthread_rwlock_t *lock);
76
77 extern int pthread_rwlockattr_init(pthread_rwlockattr_t * attr);
78
79 extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * attr);
80
81 extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * attr,
82                                           int *pshared);
83
84 extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
85                                           int pshared);
86
87
88 #endif /* _RWLOCK_H */