4 * $DragonFly: src/test/sysperf/mutex4.c,v 1.1 2008/05/09 15:49:42 dillon Exp $
10 #include <machine/atomic.h>
11 #include <machine/cpufunc.h>
21 typedef struct globaldata
*globaldata_t
;
24 rd_lock_contested(void)
31 atomic_set_int(mtx
, 1);
42 main(int ac
, char **av
)
50 printf("Test simple locked bus cycle mutex latency\n");
51 printf("auto-forks two processes for the test with shared memory\n");
52 printf("This test is only useful on a SMP box\n");
55 mtx
= mmap(NULL
, 4096, PROT_READ
|PROT_WRITE
, MAP_SHARED
|MAP_ANON
, -1, 0);
57 gd
.gd_cpumask
= 0x00000001;
59 while (stop_timing(0, NULL
) == 0) {
60 for (j
= 0; j
< 100; ++j
) {
70 for (count
= 0; count
< max
; count
+= 100) {
71 for (j
= 0; j
< 100; ++j
) {
73 rd_unlock(); /* release */
76 stop_timing(count
, "complex_mtx(uncontested/1cpu)");
78 if ((pid
= fork()) == 0) {
80 for (j
= 0; j
< 100; ++j
) {
82 rd_unlock(); /* release */
87 gd
.gd_cpumask
= 0x00000002;
90 for (count
= 0; count
< max
; count
+= 100) {
91 for (j
= 0; j
< 100; ++j
) {
93 rd_unlock(); /* release */
97 stop_timing(count
, "complex_mtx");
98 printf("proc1=%d proc2=%d\n", counter
[64], counter
[128]);