Pre-2.0 release, MFC firewire disk changes to properly detach SIMs.
[dragonfly.git] / test / sysperf / loop4.c
blob4006721d05b38280e81a2d01cd6774585294658f
1 /*
2 * loop4.c
4 * Used to test syscall mpsafeness, with editing
6 * $DragonFly: src/test/sysperf/loop4.c,v 1.1 2008/05/09 15:49:42 dillon Exp $
7 */
9 #include "blib.h"
10 #include <fcntl.h>
12 #define INNER 100
14 void doloop(int count);
15 void func_nop1(void);
16 void func_nop2(void);
18 int
19 main(int ac, char **av)
21 int i;
22 int fd;
23 int count;
24 int nfork;
25 pid_t pid;
27 if (ac > 1)
28 nfork = strtoul(av[1], NULL, 0);
30 printf("SMP contention, dup() + close(), Run just one\n");
32 start_timing();
33 count = 0;
34 while (stop_timing(0, NULL) == 0) {
35 doloop(1000);
36 count += 1000;
38 printf("loop %d times\n", count);
40 start_timing();
41 for (i = 1; i < nfork; ++i) {
42 if (fork() == 0) {
43 doloop(count);
44 _exit(1);
47 doloop(count);
48 while (wait(NULL) > 0)
50 stop_timing(count * INNER, "loop2/2xfork");
51 return(0);
54 void
55 doloop(int count)
57 int i;
58 int j;
59 int fd = open("/usr/share/dict/words", O_RDONLY);
60 register void (*func)(void) = func_nop1;
62 if (fd < 0)
63 perror("open");
64 for (i = count; i > 0; --i) {
65 for (j = INNER; j > 0; --j) {
66 getuid();
69 close(fd);
72 void
73 func_nop1(void)
77 void
78 func_nop2(void)