File: randomlock.tcl

package info (click to toggle)
db 2%3A2.4.14-2.7.7.1.c
  • links: PTS
  • area: main
  • in suites: potato
  • size: 12,716 kB
  • ctags: 9,382
  • sloc: ansic: 35,556; tcl: 8,564; cpp: 4,890; sh: 2,075; makefile: 1,723; java: 1,632; sed: 419; awk: 153; asm: 41
file content (42 lines) | stat: -rw-r--r-- 1,346 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996, 1997, 1998
#	Sleepycat Software.  All rights reserved.
#
#	@(#)randomlock.tcl	10.3 (Sleepycat) 4/10/98
#
# Exercise multi-process aspects of lock.  Generate a bunch of parallel
# testers that try to randomly obtain locks.
proc lock005 { dir {iter 500} {max 1000} {procs 5} {ldegree 5} {objs 75} \
    {reads 65} {wait 1} {conflicts { 0 0 0 0 0 1 0 1 1}} {seeds {}} } {
source ./include.tcl
	puts "Lock005: Multi-process random lock test"

# Clean up after previous runs
	lock_cleanup $dir

	# Open/create the lock region
	set lp [lock_open "" $DB_CREATE 0644 -maxlocks $max]
	error_check_bad lock_open $lp NULL
	error_check_good lock_open [is_substr $lp lockmgr] 1

	# Now spawn off processes
	set pidlist {}
	for { set i 0 } {$i < $procs} {incr i} {
		set s -1
		if { [llength $seeds] == $procs } {
			set s [lindex $seeds $i]
		}
		puts "exec ./dbtest ../test/lockscript.tcl $dir $iter \
		    $objs $wait $ldegree $reads $s > $dir/$i.lockout &"
		set p [exec ./dbtest ../test/lockscript.tcl $dir $iter \
		    $objs $wait $ldegree $reads $s > $dir/$i.lockout & ]
		lappend pidlist $p
	}
	puts "Lock005: $procs independent processes now running"
	watch_procs $pidlist
	# Remove log files
	for { set i 0 } {$i < $procs} {incr i} {
		exec $RM -f $dir/$i.lockout
	}
}