linearizability revisited
play

Linearizability, revisited Radha Jagadeesan Gustavo Petri Corin - PowerPoint PPT Presentation

Linearizability, revisited Radha Jagadeesan Gustavo Petri Corin Pitcher James Riely DePaul University Purdue University ESOP 2010, FOSSACS 2012, TLDI 2012, ESOP 2013 Linearizability, revisited ESOP 2010, FOSSACS 2012,


  1. Linearizability, revisited Radha Jagadeesan ∗ Gustavo Petri † Corin Pitcher ∗ James Riely ∗ ∗ DePaul University † Purdue University ESOP 2010, FOSSACS 2012, TLDI 2012, ESOP 2013 Linearizability, revisited ESOP 2010, FOSSACS 2012,

  2. Reminiscing 1 1991 August — 1993 June Linearizability, revisited ESOP 2010, FOSSACS 2012,

  3. Reminiscing 2 Guru Brahma Guru Vishnu Guru Devo Maheshwaraha Guru Saakshat Para Brahma Tasmai Sree Gurave Namaha Guru is verily the representative of Brahma, Vishnu and Shiva. He creates, sustains knowledge and destroys the weeds of ignorance. I salute thee, Guru. Linearizability, revisited ESOP 2010, FOSSACS 2012,

  4. Reminiscing 2 Guru Brahma Guru Vishnu Guru Devo Maheshwaraha Guru Saakshat Para Brahma Tasmai Sree Gurave Namaha Guru is verily the representative of Brahma, Vishnu and Shiva. He creates, sustains knowledge and destroys the weeds of ignorance. I salute thee, Guru. Linearizability, revisited ESOP 2010, FOSSACS 2012,

  5. Reminiscing 2 Guru Brahma Guru Vishnu Guru Devo Maheshwaraha Guru Saakshat Para Brahma Tasmai Sree Gurave Namaha Guru is verily the representative of Brahma, Vishnu and Shiva. He creates, sustains knowledge and destroys the weeds of ignorance. I salute thee, Guru. Linearizability, revisited ESOP 2010, FOSSACS 2012,

  6. Linearizability, revisited What is the interface of a concurrent object? implicit causality via absence of interleavings . . . What changes to account for weak memory? . . . explicit causality via happens-before Linearizability, revisited ESOP 2010, FOSSACS 2012,

  7. Linearizability, revisited What is the interface of a concurrent object? implicit causality via absence of interleavings . . . What changes to account for weak memory? . . . explicit causality via happens-before Linearizability, revisited ESOP 2010, FOSSACS 2012,

  8. Refer to papers for appropriate and complete references Linearizability, revisited ESOP 2010, FOSSACS 2012,

  9. Spin lock (Library) Implementation var v = 1 ; (Initially locked) fun rel () { v = 0 ; } (Strong memory) fun acq () { do skip until v . cas ( 0 , 1 ); } Trace of release � ? call rel � � wr v 0 � � ! ret rel � (Lock’s viewpoint) � �� � � �� � � �� � (Input) (Output) (Write) (Take control) (Give control) Trace of acquire � ? call acq � � rd v 1 �� rd v 1 � ··· � rd v 1 � � cas v 0 1 �� ! ret acq � � �� � (Unsuccessful cas treated as read) Linearizability, revisited ESOP 2010, FOSSACS 2012,

  10. Spin lock (Library) Implementation var v = 1 ; (Initially locked) fun rel () { v = 0 ; } (Strong memory) fun acq () { do skip until v . cas ( 0 , 1 ); } Trace of release � ? call rel � � wr v 0 � � ! ret rel � (Lock’s viewpoint) � �� � � �� � � �� � (Input) (Output) (Write) (Take control) (Give control) Trace of acquire � ? call acq � � rd v 1 �� rd v 1 � ··· � rd v 1 � � cas v 0 1 �� ! ret acq � � �� � (Unsuccessful cas treated as read) Linearizability, revisited ESOP 2010, FOSSACS 2012,

  11. Spin lock (Library) Implementation var v = 1 ; (Initially locked) fun rel () { v = 0 ; } (Strong memory) fun acq () { do skip until v . cas ( 0 , 1 ); } Trace of release � ? call rel � � wr v 0 � � ! ret rel � (Lock’s viewpoint) � �� � � �� � � �� � (Input) (Output) (Write) (Take control) (Give control) Trace of acquire � ? call acq � � rd v 1 �� rd v 1 � ··· � rd v 1 � � cas v 0 1 �� ! ret acq � � �� � (Unsuccessful cas treated as read) Linearizability, revisited ESOP 2010, FOSSACS 2012,

  12. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Possible interleaving (Color = thread) � ? call acq �� rd v 1 �� ? call rel �� wr v 0 �� cas v 0 1 �� ! ret acq �� ! ret rel � Impossible interleaving � ? call acq �� rd v 1 �� cas v 0 1 �� ! ret acq �� ? call rel �� wr v 0 �� ! ret rel � Looking only at I/O actions: � ? call rel � must precede � ! ret acq � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  13. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Possible interleaving (Color = thread) � ? call acq �� rd v 1 �� ? call rel �� wr v 0 �� cas v 0 1 �� ! ret acq �� ! ret rel � Impossible interleaving � ? call acq �� rd v 1 �� cas v 0 1 �� ! ret acq �� ? call rel �� wr v 0 �� ! ret rel � Looking only at I/O actions: � ? call rel � must precede � ! ret acq � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  14. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Possible interleaving (Color = thread) � ? call acq �� rd v 1 �� ? call rel �� wr v 0 �� cas v 0 1 �� ! ret acq �� ! ret rel � Impossible interleaving � ? call acq �� rd v 1 �� cas v 0 1 �� ! ret acq �� ? call rel �� wr v 0 �� ! ret rel � Looking only at I/O actions: � ? call rel � must precede � ! ret acq � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  15. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Abbreviate   � ? call rel �� ! ret rel �� ? call acq �� ! ret acq �       � ? call rel �� ? call acq �� ! ret rel �� ! ret acq �     � ? call rel �� ? call acq �� ! ret acq �� ! ret rel �   � ? call acq �� ? call rel �� ! ret rel �� ! ret acq �         � ? call acq �� ? call rel �� ! ret acq �� ! ret rel � � ? call acq �� ! ret acq �� ? call rel �� ! ret rel � as � ? call rel � � ? call acq � constrains interleavings � ! ret rel � � ! ret acq � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  16. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Interface: set of traces obeying � ? call rel � ··· � ? call rel � � ? call acq � � ? call rel � ··· � ? call rel � � ? call acq � � ! ret rel � ··· � ! ret rel � ··· � ! ret acq � ··· � ! ret rel � � ! ret rel � � ! ret acq � constrains interleavings imposed by Lock What about client? Linearizability, revisited ESOP 2010, FOSSACS 2012,

  17. Spin lock (Two threads) Implementation var v = 1 ; fun rel () { v = 0 ; } fun acq () { do skip until v . cas ( 0 , 1 ); } Interface: set of traces obeying � ? call rel � ··· � ? call rel � � ? call acq � � ? call rel � ··· � ? call rel � � ? call acq � � ! ret rel � ··· � ! ret rel � ··· � ! ret acq � ··· � ! ret rel � � ! ret rel � � ! ret acq � constrains interleavings imposed by Lock What about client? Linearizability, revisited ESOP 2010, FOSSACS 2012,

  18. Spin lock (Client constraints) Implementation var v = 0 ; fun rel () { v = 0 ; } (Initially unlocked) fun acq () { do skip until v . cas ( 0 , 1 ); } Example of client order Multiple calls from single thread � ? call acq � Two kinds of constraints � ! ret acq � � ? call acq � Imposed by library ? ! (In → out) � ? call rel � � ! ret acq � Imposed by client ! ? (Out → in) � ! ret rel � � ? call rel � � ! ret rel � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  19. Spin lock (Client constraints) Implementation var v = 0 ; fun rel () { v = 0 ; } (Initially unlocked) fun acq () { do skip until v . cas ( 0 , 1 ); } Example of client order Multiple calls from single thread � ? call acq � Arrows constrain interleavings � ! ret acq � � ? call acq � More arrows = smaller set � ? call rel � � ! ret acq � Fully constrained = singleton, sequential � ! ret rel � � ? call rel � � ! ret rel � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  20. Spin lock (Client constraints) Implementation var v = 0 ; fun rel () { v = 0 ; } (Initially unlocked) fun acq () { do skip until v . cas ( 0 , 1 ); } Example of client order Multiple calls from single thread � ? call acq � Arrows constrain interleavings � ! ret acq � � ? call acq � More arrows = smaller set � ? call rel � � ! ret acq � No constraints = all allowed interleavings � ! ret rel � � ? call rel � � ! ret rel � Linearizability, revisited ESOP 2010, FOSSACS 2012,

  21. Two locks (for one place buffer) (Initially locked) (Initially unlocked) var v full = 1 ; var v emp = 0 ; fun rel full () { v full = 0 ; } fun rel emp () { v emp = 0 ; } fun acq full () { ··· v full . cas ( 0 , 1 ); } fun acq emp () { ··· v emp . cas ( 0 , 1 ); } Locks are independent � ? call acq full � � ? call acq emp � � ? call rel full � � ? call rel emp � � ! ret acq full � � ! ret acq emp � � ! ret rel full � � ! ret rel emp � Client may create dependency Linearizability, revisited ESOP 2010, FOSSACS 2012,

Recommend


More recommend