~vkolesnikov/pbxt/pbxt-preload-test-bug

« back to all changes in this revision

Viewing changes to src/locklist_xt.h

  • Committer: Vladimir Kolesnikov
  • Date: 2009-01-21 13:55:57 UTC
  • mto: This revision was merged to the branch mainline in revision 533.
  • Revision ID: vladimir@primebase.org-20090121135557-gyzk4wo3kj126jda
added thread lock lists

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2009 PrimeBase Technologies GmbH
 
2
 *
 
3
 * PrimeBase XT
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 * 2009-01-20   Vladimir Kolesnikov
 
20
 *
 
21
 * H&G2JCtL
 
22
 */
 
23
 
 
24
#ifndef __xt_locklist_h__
 
25
#define __xt_locklist_h__
 
26
 
 
27
#ifdef DEBUG
 
28
#define XT_THREAD_LOCK_INFO
 
29
#endif
 
30
 
 
31
#include "xt_defs.h"
 
32
 
 
33
struct XTThread;
 
34
struct XTSpinLock;
 
35
struct XTRWMutex;
 
36
struct xt_mutex_struct;
 
37
struct xt_rwlock_struct;
 
38
struct XTFastLock;
 
39
struct XTFastRWLock;
 
40
struct XTSpinRWLock;
 
41
 
 
42
#ifdef XT_THREAD_LOCK_INFO
 
43
 
 
44
#define LOCKLIST_ARG_SUFFIX(name) #name " in " __FUNCTION__ "() at " __FILE__ ":" QUOTE(__LINE__)
 
45
 
 
46
/*
 
47
 * An instance of this class keeps information about a lock kept by a thread.
 
48
 * There's a list of XTThreadLockInfo instances per thread. An instance can be
 
49
 * included into several thread lists in case of shared locks.
 
50
 */
 
51
typedef struct XTThreadLockInfo {
 
52
 
 
53
        enum LockType { SPIN_LOCK, RW_MUTEX, MUTEX, RW_LOCK, FAST_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK };
 
54
 
 
55
        XTThreadLockInfo *li_prev;
 
56
        LockType                  li_lock_type;
 
57
 
 
58
        union {
 
59
                XTSpinLock       *li_spin_lock;   // SPIN_LOCK
 
60
                XTRWMutex        *li_rw_mutex;    // RW_MUTEX
 
61
                XTFastLock               *li_fast_lock;   // FAST_LOCK
 
62
                XTFastRWLock     *li_fast_rwlock; // FAST_RW_LOCK
 
63
                XTSpinRWLock     *li_spin_rwlock; // SPIN_RW_LOCK
 
64
                xt_mutex_struct  *li_mutex;               // MUTEX
 
65
                xt_rwlock_struct *li_rwlock;      // RW_LOCK
 
66
        };
 
67
 
68
XTThreadLockInfoRec, *XTThreadLockInfoPtr;
 
69
 
 
70
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinLock *lock);
 
71
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTRWMutex *lock);
 
72
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastLock *lock);
 
73
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTFastRWLock *lock);
 
74
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinRWLock *lock);
 
75
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_mutex_struct *lock);
 
76
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_rwlock_struct *lock);
 
77
void xt_thread_lock_info_free(XTThreadLockInfoPtr ptr);
 
78
 
 
79
void xt_thread_lock_info_add_owner (XTThreadLockInfoPtr ptr);
 
80
void xt_thread_lock_info_release_owner (XTThreadLockInfoPtr ptr);
 
81
 
 
82
#endif // XT_THREAD_LOCK_INFO
 
83
#endif // __xt_locklist_h__