summaryrefslogtreecommitdiff
path: root/test/ken/chan.go
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-12-18 20:06:28 -0800
committerKen Thompson <ken@golang.org>2008-12-18 20:06:28 -0800
commit991baa30c0b8db65f41c9f5ca62fe83fe8cea2ab (patch)
treeaf8fd515f015109ff244c5550e6890cb5abfe0da /test/ken/chan.go
parent5533ac65097837514737f6c37579a0fcb6425584 (diff)
downloadgolang-991baa30c0b8db65f41c9f5ca62fe83fe8cea2ab.tar.gz
arrays
R=r OCL=21564 CL=21564
Diffstat (limited to 'test/ken/chan.go')
-rw-r--r--test/ken/chan.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/ken/chan.go b/test/ken/chan.go
index 73f4a8bb1..64758537e 100644
--- a/test/ken/chan.go
+++ b/test/ken/chan.go
@@ -6,7 +6,18 @@
package main
-import rand "rand"
+
+var randx int;
+
+func
+nrand(n int) int
+{
+ randx += 10007;
+ if randx >= 1000000 {
+ randx -= 1000000;
+ }
+ return randx%n;
+}
type Chan
struct
@@ -31,7 +42,7 @@ init()
}
func
-mkchan(c,n int) *[]*Chan
+mkchan(c,n int) []*Chan
{
ca := new([]*Chan, n);
for i:=0; i<n; i++ {
@@ -76,7 +87,7 @@ send(c *Chan)
{
nproc++; // total goroutines running
for {
- for r:=rand.nrand(10); r>=0; r-- {
+ for r:=nrand(10); r>=0; r-- {
sys.gosched();
}
c.sc <- c.sv;
@@ -107,7 +118,7 @@ recv(c *Chan)
nproc++; // total goroutines running
for {
- for r:=rand.nrand(10); r>=0; r-- {
+ for r:=nrand(10); r>=0; r-- {
sys.gosched();
}
v = <-c.rc;
@@ -136,7 +147,7 @@ sel(r0,r1,r2,r3, s0,s1,s2,s3 *Chan)
if s3.sc != nil { a++ }
for {
- for r:=rand.nrand(5); r>=0; r-- {
+ for r:=nrand(5); r>=0; r-- {
sys.gosched();
}