Browse code

Documentation updates

- Including locking.txt in doxygen
- Updating other files (ser -> sip-router)

oej authored on 21/10/2009 08:09:03
Showing 4 changed files
... ...
@@ -1,24 +1,26 @@
1 1
 # $Id$
2 2
 #
3
-# SER cvs commit rules
3
+# SIP-router git commit rules
4 4
 
5 5
 
6
-1. Changing other people code:
7
- - send a patch to the code/module mantainer and/or serdev (don't commit changes to code you don't own if you don't have the mantainer's approval)
6
+1. Changing other people's code:
7
+--------------------------------
8
+ - send a patch to the code/module mantainer and/or sr-dev (don't commit changes to code you don't own if you don't have the mantainer's approval)
8 9
 Exceptions:
9 10
  a. compilation (this includes warning) fixes
10 11
  b. bug fixes
11 12
  c. api changes (some external functions definitions change)
12 13
  d. small changes due to a new release in the very near future (allowed only for the release manager)
13 14
 
14
-
15 15
 2. Code requirements
16
+--------------------
16 17
 2.1 Unstable branch:
17 18
  - the code must compile (at least on one arhitecture). If the code does not compile, but you still want to commit it, comment it out (#if 0 ... #endif)
18 19
  - the code should compile without warnings (with -Wall) (exceptions: very difficult to avoid warnings)
19
- - follow ser coding style
20
+ - follow SIP-router coding style
20 21
 
21 22
 2.2. Stable branch (everything for unstable branch +)
23
+------------------------------------------------------
22 24
  - the code must compile on all the arhitectures (this currently includes
23 25
    linux, freebsd, netbsd, openbsd, solaris >= 8; x86, ultrasparc, strongarm;
24 26
     gcc 2.95, 3.x, icc, sun cc >=5.3).
... ...
@@ -5,8 +5,8 @@
5 5
 # 2006-09-08  created by andrei
6 6
 #
7 7
 
8
-Overview
8
+Destination blacklist Overview
9
+------------------------------
9 10
 
10 11
  The destination blacklist (dst_blacklist) is used to try to mark bad
11 12
  destinations and avoid possible future expensive send operation to them.
... ...
@@ -6,23 +6,41 @@
6 6
 #  2006-04-04  minor archs updates, added lock_try(..)  (andrei)
7 7
 
8 8
 
9
-SER locking interface
9
+SIP-router locking interface
10 10
 
11 11
 
12 12
 1. Why use it?
13
-   ----------
14
-
15
- The main reason in creating it was to have a single transparent interface to various locking methods. For example right now ser uses the following locking methods, depending on their availability on the target system:
16
- FAST_LOCK - fast inline assembly locks, defined in fast_lock.h. They are currently available for x86, x86_64, sparc, sparc64, arm , armv6 (no smp mode supported yet), ppc, ppc64, mips, mips64 and alpha . In general if the assembly code exists for a given arhitecture and the compiler knows inline assembly (for example sun cc does not) FAST_LOCK is prefered. The main advantage of using FAST_LOCK is very low memory overhead and extremely fast lock/unlock operations (like 20 times faster then SYSV semaphores on linux & 40 times on solaris). The only thing that comes close to them are pthread mutexes (which are about 3-4 times slower).
17
- PTHREAD_MUTEX - uses pthread_mutex_lock/unlock. They are quite fast but they work between processes only on some systems (they do not work on linux).
18
- POSIX_SEM  - uses posix semaphores (sem_wait/sem_post). They are slower then the previous methods but still way faster then SYSV sempahores. Unfortunately they also do not work on all the systems (e.g. linux).
19
- SYSV_SEM - this is the most portable but also the slowest locking method. Another problem is that the number of semaphores that can be alocated by a process is limited. One also has to free them before exiting.
13
+--------------
14
+
15
+The main reason for creating it was to have a single transparent interface to various locking methods. 
16
+For example right now SIP-router uses the following locking methods, depending on their availability on the 
17
+target system:
18
+	FAST_LOCK - fast inline assembly locks, defined in fast_lock.h. They are currently available for 
19
+	x86, x86_64, sparc, sparc64, arm , armv6 (no smp mode supported yet), ppc, ppc64, mips, mips64 
20
+	and alpha . In general if the assembly code exists for a given arhitecture and the compiler 
21
+	knows inline assembly (for example sun cc does not) FAST_LOCK is prefered. The main 
22
+	advantage of using FAST_LOCK is very low memory overhead and extremely fast lock/unlock 
23
+	operations (like 20 times faster then SYSV semaphores on linux & 40 times on solaris). 
24
+	The only thing that comes close to them are pthread mutexes (which are about 3-4 times slower).
25
+
26
+	PTHREAD_MUTEX - uses pthread_mutex_lock/unlock. They are quite fast but they work between 
27
+	processes only on some systems (they do not work on linux).
28
+
29
+	POSIX_SEM  - uses posix semaphores (sem_wait/sem_post). They are slower then the previous 
30
+	methods but still way faster then SYSV sempahores. Unfortunately they also do not work on 
31
+	all the systems (e.g. linux).
32
+	
33
+	SYSV_SEM - this is the most portable but also the slowest locking method. Another problem is 
34
+	that the number of semaphores that can be alocated by a process is limited. One also has to 
35
+	free them before exiting.
20 36
 
21 37
 
22 38
 2. How to use it?
23 39
 -----------------
24 40
 
25
-First of all you have to include locking.h. Then when compiling the code one or all of FAST_LOCK, USE_PTHREAD_MUTEX, USE_PTHREAD_SEM or USE_SYSV_SEM must be defined (the ser Makefile.defs takes care of this, you should need to change it only for new arhitectures or compilers).
41
+First of all you have to include locking.h. Then when compiling the code one or all of FAST_LOCK, 
42
+USE_PTHREAD_MUTEX, USE_PTHREAD_SEM or USE_SYSV_SEM must be defined (the SIP-router Makefile.defs takes 
43
+care of this, you should need to change it only for new arhitectures or compilers).
26 44
 
27 45
 locking.h defines 2 new types: gen_lock_t and lock_set_t.
28 46
 
... ...
@@ -56,7 +74,8 @@ if (lock_init(lock)==0){
56 74
 }
57 75
 ...
58 76
 
59
-Lock allocation can be skipped in some cases: if the lock is already in shared memory you don't need to allocate it again, you can initialize it directly, but keep in mind that the lock MUST be in shared memory.
77
+Lock allocation can be skipped in some cases: if the lock is already in shared memory you don't need to
78
+allocate it again, you can initialize it directly, but keep in mind that the lock MUST be in shared memory.
60 79
 
61 80
 Example:
62 81
 
... ...
@@ -78,13 +97,15 @@ Destroying & deallocating the locks:
78 97
   void    lock_destroy(gen_lock_t* lock);
79 98
   void    lock_dealloc(gen_lock_t* lock);
80 99
  
81
- The lock_destroy function must be called first. It removes the resources associated with the lock, but it does not also free the lock shared memory part. Think of sysv rmid.
82
- Please don't forget to call this function, or you can leave allocated resources in some cases (e.g sysv semaphores). Be carefull to call it in your module destroy function if you use any global module locks.
100
+The lock_destroy function must be called first. It removes the resources associated with the 
101
+lock, but it does not also free the lock shared memory part. Think of sysv rmid.
102
+Please don't forget to call this function, or you can leave allocated resources in some cases 
103
+(e.g sysv semaphores). Be carefull to call it in your module destroy function if you use any 
104
+global module locks.
83 105
 
84 106
 Example:
85
-lock_destroy(lock);
86
-lock_dealloc(lock);
87
-
107
+	lock_destroy(lock);
108
+	lock_dealloc(lock);
88 109
 
89 110
 Of course you don't need to call lock_dealloc if your lock was not allocated with lock_alloc.
90 111
 
... ...
@@ -104,34 +125,36 @@ int     lock_try(gen_lock_t* lock);      - tries to lock and returns 0
104 125
 ------------
105 126
 
106 127
 The lock sets are kind of sysv semaphore sets equivalent. The type is lock_set_t.
107
-Use them when you need a lot of mutexes. In some cases they waste less system resources than arrays of gen_lock_t (e.g. sys v semaphores).
128
+Use them when you need a lot of mutexes. In some cases they waste less system 
129
+resources than arrays of gen_lock_t (e.g. sys v semaphores).
108 130
 
109 131
 Allocating & initializing:
110 132
 --------------------------
111 133
 
112
-lock_set_t* lock_set_alloc(int no);
113
-lock_set_t* lock_set_init(lock_set_t* set);
134
+	lock_set_t* lock_set_alloc(int no);
135
+	lock_set_t* lock_set_init(lock_set_t* set);
114 136
 
115 137
 Both functions return 0 on failure.
116 138
 
117
-WARNING: expect the allocation function to fail for large numbers. It depends on the locking method used & the system available resources (again the sysv semaphores example).
139
+WARNING: expect the allocation function to fail for large numbers. It depends on the locking 
140
+method used & the system available resources (again the sysv semaphores example).
118 141
 
119 142
 Example:
120 143
 
121
-lock_set_t *lock_set;
144
+	lock_set_t *lock_set;
122 145
 
123
-lock_set=lock_set_alloc(100);
124
-if (lock_set==0) goto error;
125
-if (lock_set_init(lock_set)==0){
126
-   lock_set_dealloc(lock_set);
127
-   goto error;
128
-}
146
+	lock_set=lock_set_alloc(100);
147
+	if (lock_set==0) goto error;
148
+	if (lock_set_init(lock_set)==0){
149
+   		lock_set_dealloc(lock_set);
150
+   		goto error;
151
+	}
129 152
 
130 153
 or
131
- if ((lock_set=lock_set_alloc(100))==0) || (lock_set_init(lock_set)==0)){
132
-   if (lock_set) lock_set_dealloc(lock_set);
133
-   goto error;
134
- }
154
+ 	if ((lock_set=lock_set_alloc(100))==0) || (lock_set_init(lock_set)==0)){
155
+   		if (lock_set) lock_set_dealloc(lock_set);
156
+   		goto error;
157
+ 	}
135 158
 
136 159
 
137 160
 Destroying & deallocating:
... ...
@@ -161,5 +184,5 @@ lock_set_release(lock_set, 2);
161 184
 When to use lock_set_t & when to use gen_lock_t
162 185
 -----------------------------------------------
163 186
 If you use lots of semaphores and GEN_LOCK_T_PREFERED is undefined then use
164
- lock_set_t. If GEN_LOCK_T_PREFERED is defined you can safely use gen_lock_t 
165
- arrays instead.
187
+lock_set_t. If GEN_LOCK_T_PREFERED is defined you can safely use gen_lock_t 
188
+arrays instead.
... ...
@@ -28,9 +28,20 @@
28 28
  * \file
29 29
  * \brief SIP-router core :: 
30 30
  * \ingroup core
31
+ *
31 32
  * Module: \ref core
33
+ *
34
+ * Reference:
35
+ * - \ref LockingDoc
32 36
  */
33 37
 
38
+/*!
39
+ * \page LockingDoc Documentation of locking
40
+ * \verbinclude locking.txt
41
+ *
42
+ */
43
+
44
+
34 45
 
35 46
 #include "ut.h"
36 47
 #include "dprint.h"