From 1f9bd1e845b86c5cff81c8593fefc4a9e0568bd0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 28 Aug 2016 16:37:24 +0200 Subject: csource: make collide mode more random Update #59 --- csource/csource.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'csource') diff --git a/csource/csource.go b/csource/csource.go index 28be9e22a..9bd349b7c 100644 --- a/csource/csource.go +++ b/csource/csource.go @@ -75,19 +75,20 @@ int main() fmt.Fprintf(w, "int main()\n{\n") fmt.Fprintf(w, "\tlong i;\n") - fmt.Fprintf(w, "\tpthread_t th[%v];\n", len(calls)) + fmt.Fprintf(w, "\tpthread_t th[%v];\n", 2*len(calls)) fmt.Fprintf(w, "\n") fmt.Fprintf(w, "install_segv_handler();\n") fmt.Fprintf(w, "\tmemset(r, -1, sizeof(r));\n") + fmt.Fprintf(w, "\tsrand(getpid());\n") fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", len(calls)) fmt.Fprintf(w, "\t\tpthread_create(&th[i], 0, thr, (void*)i);\n") fmt.Fprintf(w, "\t\tusleep(10000);\n") fmt.Fprintf(w, "\t}\n") if opts.Collide { fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", len(calls)) - fmt.Fprintf(w, "\t\tpthread_create(&th[i], 0, thr, (void*)i);\n") - fmt.Fprintf(w, "\t\tif (i%%2==0)\n") - fmt.Fprintf(w, "\t\t\tusleep(10000);\n") + fmt.Fprintf(w, "\t\tpthread_create(&th[%v+i], 0, thr, (void*)i);\n", len(calls)) + fmt.Fprintf(w, "\t\tif (rand()%%2)\n") + fmt.Fprintf(w, "\t\t\tusleep(rand()%%10000);\n") fmt.Fprintf(w, "\t}\n") } fmt.Fprintf(w, "\tusleep(100000);\n") -- cgit mrf-deployment