Browse code

- introduced the ADAPTIVE_LOCK

Andrei Pelinescu-Onciul authored on 22/02/2002 15:29:41
Showing 4 changed files
... ...
@@ -55,10 +55,22 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
55 55
 # -DFAST_LOCK
56 56
 #		uses fast arhitecture specific locking (see the arh. specific section)
57 57
 #
58
+# -DBUSY_WAIT
59
+#		uses busy waiting on the lock
60
+# -DADAPTIVE_WAIT
61
+#		try busy waiting for a while and if the lock is still held go to
62
+#		force reschedule
63
+# -DADAPTIVE_WAIT_LOOPS=number
64
+#		number of loops we busy wait, after "number" loops have elapsed we 
65
+#		force a reschedule
66
+# -DNOSMP
67
+#		don't use smp compliant locking (faster but won't work on SMP machines)
68
+#		(not yet enabled)
58 69
 
59 70
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
60 71
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
61 72
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
73
+	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
62 74
 	 -DF_MALLOC  -DUSE_SYNONIM\
63 75
 	 -DNO_DEBUG
64 76
 	 #-DEXTRA_DEBUG 
... ...
@@ -29,6 +29,7 @@ typedef  volatile int fl_lock_t;
29 29
 inline static int tsl(fl_lock_t* lock)
30 30
 {
31 31
 	volatile int val;
32
+
32 33
 #ifdef __i386
33 34
 	
34 35
 	val=1;
... ...
@@ -51,9 +52,18 @@ inline static int tsl(fl_lock_t* lock)
51 51
 
52 52
 inline static void get_lock(fl_lock_t* lock)
53 53
 {
54
+#ifdef ADAPTIVE_WAIT
55
+	int i=ADAPTIVE_WAIT_LOOPS;
56
+#endif
54 57
 	
55 58
 	while(tsl(lock)){
59
+#ifdef BUSY_WAIT
60
+#elif defined ADAPTIVE_WAIT
61
+		if (i>0) i--;
62
+		else sched_yield();
63
+#else
56 64
 		sched_yield();
65
+#endif
57 66
 	}
58 67
 }
59 68
 
... ...
@@ -88,7 +88,16 @@ static char flags[]=
88 88
 #endif
89 89
 #ifdef FAST_LOCK
90 90
 ", FAST_LOCK"
91
+#ifdef BUSY_WAIT
92
+"-BUSY_WAIT"
91 93
 #endif
94
+#ifdef ADAPTIVE_WAIT
95
+"-ADAPTIVE_WAIT"
96
+#endif
97
+#ifdef NOSMP
98
+"-NOSMP"
99
+#endif
100
+#endif /*FAST_LOCK*/
92 101
 ;
93 102
 
94 103
 static char help_msg[]= "\
... ...
@@ -129,7 +138,14 @@ Options:\n\
129 129
 /* print compile-time constants */
130 130
 void print_ct_constants()
131 131
 {
132
-	printf("MAX_RECV_BUFFER_SIZE %d, MAX_LISTEN %d, MAX_URI_SIZE %d, MAX_PROCESSES %d\n",
132
+#ifdef ADAPTIVE_WAIT
133
+	printf("ADAPTIVE_WAIT_LOOPS=%d, ", ADAPTIVE_WAIT_LOOPS);
134
+#endif
135
+#ifdef SHM_MEM
136
+	printf("SHM_MEM_SIZE=%d, ", SHM_MEM_SIZE);
137
+#endif
138
+	printf("MAX_RECV_BUFFER_SIZE %d, MAX_LISTEN %d,"
139
+			" MAX_URI_SIZE %d, MAX_PROCESSES %d\n",
133 140
 		MAX_RECV_BUFFER_SIZE, MAX_LISTEN, MAX_URI_SIZE, MAX_PROCESSES );
134 141
 }
135 142
 
... ...
@@ -15,7 +15,7 @@ log_stderror=yes # (cmd line: -E)
15 15
 #log_stderror=no	# (cmd line: -E)
16 16
 
17 17
 
18
-children=4
18
+children=2
19 19
 check_via=no     # (cmd. line: -v)
20 20
 dns=on           # (cmd. line: -r)
21 21
 rev_dns=yes      # (cmd. line: -R)