aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
Diffstat (limited to 'csource')
-rw-r--r--csource/csource.go9
1 files changed, 5 insertions, 4 deletions
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")