Remove outdated hammer.txt.
[dragonfly.git] / test / sysperf / quicksw1.c
blob7e10731efe2a051cbbeabddbcc2e45f539717a46
1 /*
2 * quicksw1.c
4 * $DragonFly: src/test/sysperf/quicksw1.c,v 1.1 2003/08/12 02:29:44 dillon Exp $
5 */
7 #include "blib.h"
9 void qswitch(int **oldsw, int *newsw);
10 void qstart(int *newsw);
11 int *qinit(void *topstk, void *func, void *arg);
13 static void do_task1(void *arg);
14 static void do_task2(void *arg);
16 int *task1;
17 int *task2;
18 char stk1[16384];
19 char stk2[16384];
20 int count;
22 int
23 main(int ac, char **av)
25 #if USE_ALL
26 printf("userthread switching test (nonfp) using pushal/popal\n");
27 #elif USE_CALLU1
28 printf("userthread switching test (nonfp) using pushl (call-save only)\n");
29 #elif USE_CALLU2
30 printf("userthread switching test (nonfp) using subl $N,%%esp;movl (call-save only)\n");
31 #else
32 #error "The switch method wasn't defined with -D"
33 #endif
35 task1 = qinit(stk1 + sizeof(stk1), do_task1, NULL);
36 task2 = qinit(stk2 + sizeof(stk2), do_task2, NULL);
37 start_timing();
38 qstart(task1);
41 static void
42 do_task1(void *arg)
44 for (;;) {
45 qswitch(&task1, task2);
46 if (++count > 10000000) {
47 stop_timing(count, "uthread_switch");
48 exit(0);
53 static void
54 do_task2(void *arg)
56 for (;;) {
57 ++count;
58 qswitch(&task2, task1);