concurrency

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package concurrency implements a framework for systematic testing of concurrent vanadium Go programs. The framework implements the ideas described in "Systematic and Scalable Testing of Concurrent Programs":

http://repository.cmu.edu/cgi/viewcontent.cgi?article=1291&context=dissertations

Abstractly, the systematic testing framework divides execution of concurrent threads into coarse-grained transitions, by interposing on events of interest (e.g. thread creation, mutex acquisition, or channel communication).

The interposed events suspended and a centralized user-level scheduler is used to serialize the concurrent execution by advancing allowing only one concurrent transition to execute at any given time. In addition to controlling the scheduling, this centralized scheduler keeps track of the alternative scheduling choices. This information is then used to explore a different sequence of transitions next time the test body is executed.

The framework is initialized through the Init(setup, body, cleanup) function which specifies the test setup, body, and cleanup respectively. To start a systematic exploration, one invokes one of the following functions: Explore(), ExploreN(n), or ExploreFor(d). These functions repeatedly execute the test described through Init(), systematically enumerating the different ways in which different executions sequence concurrent transitions of the test. Finally, each systematic exploration should end by invoking the Finish() function.

See mutex_test.go for an example on how to use this framework to test concurrent access to mutexes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit()

Exit implements the logic related to modeling and scheduling thread termination.

func Finish

func Finish()

Cleanup destroys the existing instance of the tester.

func Start

func Start(fn func())

Start implements the logic related to modeling and scheduling an execution of "go fn()".

func TIDGenerator

func TIDGenerator() func() TID

TIDGenerator is used for generating unique thread identifiers.

Types

type IncreasingDepth

type IncreasingDepth []*state

IncreasingDepth is used to sort states in the increasing order of their depth.

func (IncreasingDepth) Len

func (states IncreasingDepth) Len() int

func (IncreasingDepth) Less

func (states IncreasingDepth) Less(i, j int) bool

func (IncreasingDepth) Swap

func (states IncreasingDepth) Swap(i, j int)

type IncreasingTID

type IncreasingTID []TID

Increasing is used to sort thread identifiers in an increasing order.

func (IncreasingTID) Len

func (tids IncreasingTID) Len() int

func (IncreasingTID) Less

func (tids IncreasingTID) Less(i, j int) bool

func (IncreasingTID) Swap

func (tids IncreasingTID) Swap(i, j int)

type TID

type TID int

TID is the thread identifier type.

type Tester

type Tester struct {
	// contains filtered or unexported fields
}

Tester represents an instance of the systematic test.

func Init

func Init(setup, body, cleanup func()) *Tester

Setup sets up a new instance of the tester.

func T

func T() *Tester

T returns the global instance of the tester.

func (*Tester) Explore

func (t *Tester) Explore() (int, error)

Explore explores the space of possible test schedules until the state space is fully exhausted.

func (*Tester) ExploreFor

func (t *Tester) ExploreFor(d time.Duration) (int, error)

ExploreFor explores the space of possible test schedules until the state space is fully exhausted or the given duration elapses, whichever occurs first.

func (*Tester) ExploreN

func (t *Tester) ExploreN(n int) (int, error)

ExploreN explores the space of possible test schedules until the state space is fully exhausted or the given number of schedules is explored, whichever occurs first.

func (*Tester) MutexLock

func (t *Tester) MutexLock(m *sync.Mutex)

MutexLock implements the logic related to modeling and scheduling an execution of "m.Lock()".

func (*Tester) MutexUnlock

func (t *Tester) MutexUnlock(m *sync.Mutex)

MutexUnlock implements the logic related to modeling and scheduling an execution of "m.Unlock()".

func (*Tester) RWMutexLock

func (t *Tester) RWMutexLock(rw *sync.RWMutex)

RWMutexLock implements the logic related to modeling and scheduling an execution of "rw.Lock()".

func (*Tester) RWMutexRLock

func (t *Tester) RWMutexRLock(rw *sync.RWMutex)

RWMutexRLock implements the logic related to modeling and scheduling an execution of "rw.RLock()".

func (*Tester) RWMutexRUnlock

func (t *Tester) RWMutexRUnlock(rw *sync.RWMutex)

RWMutexRUnlock implements the logic related to modeling and scheduling an execution of "rw.RUnlock()".

func (*Tester) RWMutexUnlock

func (t *Tester) RWMutexUnlock(rw *sync.RWMutex)

RWMutexUnlock implements the logic related to modeling and scheduling an execution of "rw.Unlock()".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL