diff --git a/.blocksize.go.swp b/.blocksize.go.swp new file mode 100644 index 0000000..d406db0 Binary files /dev/null and b/.blocksize.go.swp differ diff --git a/blocksize b/blocksize index f51619b..20bc95f 100755 Binary files a/blocksize and b/blocksize differ diff --git a/blocksize.go b/blocksize.go index 7179560..a9f2402 100644 --- a/blocksize.go +++ b/blocksize.go @@ -33,13 +33,13 @@ func main() { if dasd == "" { // no dasd type was input fmt.Println("\nBLK205R No DASD type entered. ") - fmt.Println("\nBLK206R pls enter DASD type or restart with -h for list of DASD types") + fmt.Println("BLK206R pls enter DASD type or restart with -h for list of DASD types") fmt.Scan(&dasd) } if lrecl == 0 { // no lrecl was input fmt.Printf("\nBLK201R lrecl command line argument is not included.\n") - fmt.Println("\nBLK202R Please enter lrecl length: ") + fmt.Println("BLK202R Please enter lrecl length: ") fmt.Scan(&lrecl) } if *helpPtr { // user asked for help diff --git a/concurrency b/concurrency new file mode 100755 index 0000000..eabb86a Binary files /dev/null and b/concurrency differ diff --git a/concurrency.go b/concurrency.go new file mode 100644 index 0000000..e07315e --- /dev/null +++ b/concurrency.go @@ -0,0 +1,72 @@ +package main + +/* 2017 copyright by moshix + with Apache license */ +import ( + "flag" + "fmt" + "time" +) + +func ta(tamsec int) { + for i := 0; i < 9999999; i++ { + fmt.Println("Thread A: counter: ", i) + time.Sleep(time.Duration(tamsec) * time.Millisecond) + } +} +func tb(tbmsec int) { + + for i := 0; i < 9999999; i++ { + fmt.Println("Thread B counter: ", i) + time.Sleep(time.Duration(tbmsec) * time.Millisecond) + } +} +func timeoutfunc(t chan bool, toutsec int) { + time.Sleep(time.Duration(toutsec) * time.Second) + t <- true +} + +func main() { + + var tamsec int = 300 + var tbmsec int = 100 + var toutsec int = 15 + + threadaPtr := flag.Int("tamsec", 300, "thread A millisecond wait time") + threadbPtr := flag.Int("tbmsec", 100, "thread B millisecond wait time") + toutPtr := flag.Int("tout", 15, "timeout period") + helpPtr := flag.Bool("help", false, "help flag") + flag.Parse() + + if *helpPtr { //user asked for help... + fmt.Println("\nconcurrency is a Golang concurrency testing tool by moshix") + fmt.Println("Two parameters are needed, and a flag is optional:") + fmt.Println("-tamsec=nnn hundreds of milliseconds for thread A to wait") + fmt.Println("-tbmsec=nnn hundreds of milliseconds for thread B to wait") + fmt.Println("-tout=nn tens of seconds for time-out of all threads.") + fmt.Println("-help for this help dialog") + fmt.Println("\nconcurrency will in any case time out after 15 seconds") + fmt.Println("you can determine the relative and absolute veleocity of each thread by assigning sensible values in tamsec and tbmsec. Have fun!") + + return + } + + tamsec = *threadaPtr //assign argument of thread A wait time in msec + tbmsec = *threadbPtr //assign argument of thread B wait time in msec + toutsec = *toutPtr // assign time out in seconds + t := make(chan bool) + go timeoutfunc(t, toutsec) + + go ta(tamsec) + go tb(tbmsec) + + for { + + tend := <-t + if tend == true { + fmt.Println("time-out from control and timing thread!") + return + } + + } +}