2 * $Id: rwlock.h,v 0.0.0.1 2003/12/19
4 * -------------------------------------------------------------------
6 * Open Real-Time Ethernet
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
13 * Author: Petr Smolik petr@smoliku.cz
15 * Project Responsible: Zdenek Hanzalek
16 * --------------------------------------------------------------------
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.
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.
33 #define PTW32_RWLOCK_MAGIC 0xfacade2
34 #define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)-1)
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;
48 struct pthread_rwlockattr_t_ {
52 ptw32_rwlock_cancelwrwait(void *arg);
55 ptw32_rwlock_check_need_init(pthread_rwlock_t *rwlock);
58 pthread_rwlock_init(pthread_rwlock_t *lock,
59 const pthread_rwlockattr_t *attr);
62 pthread_rwlock_destroy(pthread_rwlock_t *lock);
65 pthread_rwlock_tryrdlock(pthread_rwlock_t *);
68 pthread_rwlock_trywrlock(pthread_rwlock_t *);
71 pthread_rwlock_rdlock(pthread_rwlock_t *lock);
74 pthread_rwlock_timedrdlock(pthread_rwlock_t *lock,
75 const struct timespec *abstime);
78 pthread_rwlock_wrlock(pthread_rwlock_t *lock);
81 pthread_rwlock_timedwrlock(pthread_rwlock_t *lock,
82 const struct timespec *abstime);
85 pthread_rwlock_unlock(pthread_rwlock_t *lock);
88 pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
91 pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
94 pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr,
98 pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
102 #endif /* _RWLOCK_H */