Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf ·...
Transcript of Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf ·...
![Page 1: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/1.jpg)
Shared Session Types for Safe, Practical Concurrency1
Stephanie Balzer Carnegie Mellon University
Typelevel Summit Philadelphia 2019
1 Supported by a Mozilla Research Grant and NSF Grant No. CCF-1718267
![Page 2: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/2.jpg)
Concurrency is ubiquitous
�2
![Page 3: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/3.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 4: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/4.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 5: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/5.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 6: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/6.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 7: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/7.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 8: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/8.jpg)
Concurrency is ubiquitous
The world surrounding us is inherently concurrent
�2
![Page 9: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/9.jpg)
Concurrency is ubiquitous
�3
The world surrounding us is inherently concurrent
![Page 10: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/10.jpg)
Concurrency is ubiquitous
Many programming problems demand concurrency • Flight booking system, online store, search engines, etc.
�3
The world surrounding us is inherently concurrent
![Page 11: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/11.jpg)
Concurrency is ubiquitous
Many programming problems demand concurrency • Flight booking system, online store, search engines, etc.
Computing devices themselves are concurrent • Run various apps concurrently
�3
The world surrounding us is inherently concurrent
![Page 12: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/12.jpg)
Concurrency is ubiquitous
Many programming problems demand concurrency • Flight booking system, online store, search engines, etc.
Computing devices themselves are concurrent • Run various apps concurrently
�3
programming languages must support concurrency
The world surrounding us is inherently concurrent
![Page 13: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/13.jpg)
Concurrency is ubiquitous
Many programming problems demand concurrency • Flight booking system, online store, search engines, etc.
Computing devices themselves are concurrent • Run various apps concurrently
�3
programming languages must support concurrency
concurrent programming is notoriously difficult and error-prone
The world surrounding us is inherently concurrent
![Page 14: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/14.jpg)
Two models for concurrent programming
�4
![Page 15: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/15.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
![Page 16: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/16.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
message
Message-passing
![Page 17: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/17.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
message
Message-passing
• computation by reading fromand writing to shared data
![Page 18: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/18.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
message
Message-passing
• computation by reading fromand writing to shared data
• computation by exchangeof messages
![Page 19: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/19.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
message
Message-passing
• computation by reading fromand writing to shared data
• computation by exchangeof messages
message-passing offers higher-level of abstraction
![Page 20: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/20.jpg)
Two models for concurrent programming
�4
Legend: concurrently executing component
shared dataread/write
Shared memory
message
Message-passing
• computation by reading fromand writing to shared data
• computation by exchangeof messages
message-passing offers higher-level of abstraction
message-passing adopted by practical languages such as Erlang, Go, and Rust.
![Page 21: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/21.jpg)
My research
�5
![Page 22: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/22.jpg)
My research
�5
Goal: make concurrent programming safe and practical
![Page 23: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/23.jpg)
My research
�5
Goal: make concurrent programming safe and practical
message-passing model
session types to express protocols of message exchange and reason sequentially about communicating parties
![Page 24: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/24.jpg)
My research
�5
Goal: make concurrent programming safe and practical
message-passing model
Contributions:
session types to express protocols of message exchange and reason sequentially about communicating parties
![Page 25: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/25.jpg)
My research
�5
Goal: make concurrent programming safe and practical
message-passing model
Contributions:shared session types
session types to express protocols of message exchange and reason sequentially about communicating parties
![Page 26: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/26.jpg)
My research
�5
Goal: make concurrent programming safe and practical
message-passing model
Contributions:shared session types
accommodate real-world programming scenarios
guarantee protocol adherence, data-race-freedom, and deadlock-freedom
session types to express protocols of message exchange and reason sequentially about communicating parties
![Page 27: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/27.jpg)
Session types, what are they? Why do we need them in practice?
�6
![Page 28: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/28.jpg)
Message-passing concurrency in Servo
�7
![Page 29: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/29.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
![Page 30: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/30.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
Image loader:
![Page 31: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/31.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
ImageCache
Image loader:
![Page 32: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/32.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
ImageCache Client
CmdReceiver
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 33: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/33.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
ResourceThread ImageCache Client
CmdReceiver
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 34: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/34.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 35: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/35.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�7
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
request
Image loader:
![Page 36: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/36.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�8
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 37: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/37.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�8
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
exit
Image loader:
![Page 38: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/38.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�9
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 39: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/39.jpg)
Message-passing concurrency in Servo
• Servo is Mozilla’s next-generation browser engine under development and implemented in Rust.
• Servo uses message-passing concurrency for maximal parallelization of tasks, such as loading and rendering of webpage elements.
�9
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
kill
Image loader:
![Page 40: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/40.jpg)
Message-passing concurrency in Servo
�10
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 41: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/41.jpg)
Message-passing concurrency in Servo
�10
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
To restrict the kinds of messages that can be sent over a channel, Rust channels are typed with enumeration types.
Image loader:
![Page 42: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/42.jpg)
Message-passing concurrency in Servo
�10
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
To restrict the kinds of messages that can be sent over a channel, Rust channels are typed with enumeration types.
Image loader:
Example: enumeration for ImageCache
![Page 43: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/43.jpg)
Message-passing concurrency in Servo
�11
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
Image loader:
![Page 44: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/44.jpg)
Message-passing concurrency in Servo
�11
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
Image loader:
![Page 45: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/45.jpg)
Message-passing concurrency in Servo
�11
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
Image loader:
![Page 46: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/46.jpg)
Message-passing concurrency in Servo
�11
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
one variant for each message
Image loader:
![Page 47: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/47.jpg)
Message-passing concurrency in Servo
�12
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
Image loader:
![Page 48: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/48.jpg)
Message-passing concurrency in Servo
�12
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
Image loader:
![Page 49: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/49.jpg)
Message-passing concurrency in Servo
�12
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocolImage loader:
![Page 50: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/50.jpg)
Message-passing concurrency in Servo
�12
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: channelcomponent, runs in separate thread
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocolImage loader:
protocol breaches result in proliferation of panic! and
infinite waiting
![Page 51: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/51.jpg)
Message-passing concurrency in Servo
�13
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocol
protocol breaches result in proliferation of panic! and
infinite waiting
![Page 52: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/52.jpg)
Message-passing concurrency in Servo
�13
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocol
enumeration types ensure that only defined messages can be communicated along a channel
protocol breaches result in proliferation of panic! and
infinite waiting
![Page 53: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/53.jpg)
Message-passing concurrency in Servo
�13
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocol
enumeration types ensure that only defined messages can be communicated along a channel
enumeration types fail to ensure that messages are sent according to the intended protocol
protocol breaches result in proliferation of panic! and
infinite waiting
![Page 54: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/54.jpg)
Message-passing concurrency in Servo
�13
pub enum ImageCacheCommand { RequestImage (Url, ImageCacheChan, Option<ImageResponder>), GetImageIfAvailable (Url, UsePlaceholder, IpcSender<Result<Arc<Image>, ImageState>>), StoreDecodeImage (Url, Vec<u8>), … // Clients must wait for a response before shutting down ResourceThread Exit () }
implicit protocol
enumeration types ensure that only defined messages can be communicated along a channel
enumeration types fail to ensure that messages are sent according to the intended protocol
let’s use session types!
protocol breaches result in proliferation of panic! and
infinite waiting
![Page 55: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/55.jpg)
Session types
�14
![Page 56: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/56.jpg)
Session types
�14
Session types define protocols of message exchange.
![Page 57: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/57.jpg)
Session types
�14
Session types define protocols of message exchange.
“protocol = sequence of actions”
![Page 58: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/58.jpg)
Session types
�14
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 59: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/59.jpg)
Session types
�14
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
client chooses among sending
one of the labels li
![Page 60: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/60.jpg)
Session types
�15
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 61: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/61.jpg)
Session types
�15
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
provider chooses among sending
one of the labels li
![Page 62: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/62.jpg)
Session types
�16
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 63: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/63.jpg)
Session types
�16
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
client sends channel reference of
type A
![Page 64: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/64.jpg)
Session types
�17
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 65: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/65.jpg)
Session types
�17
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
provider sends channel reference of
type A
![Page 66: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/66.jpg)
Session types
�18
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 67: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/67.jpg)
Session types
�18
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .provider terminates
![Page 68: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/68.jpg)
Session types
�18
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 69: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/69.jpg)
Session types
�19
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 70: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/70.jpg)
Session types
�19
Session types define protocols of message exchange.
“protocol = sequence of actions”
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
support communication of
values
![Page 71: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/71.jpg)
Session type for image loader
�20
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
![Page 72: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/72.jpg)
Session type for image loader
�20
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 73: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/73.jpg)
Session type for image loader
�21
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 74: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/74.jpg)
Session type for image loader
�22
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 75: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/75.jpg)
Session type for image loader
�23
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 76: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/76.jpg)
Session type for image loader
�24
A,B , N{li : Ai} external choice
�{li : Ai} internal choice
A ( B channel input
A⌦B channel output
1 termination
T ! A value input
T ⇥A value output
T , int | string | . . .
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 77: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/77.jpg)
Session type for image loader
�25
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 78: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/78.jpg)
Session type for image loader
�25
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 79: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/79.jpg)
Session type for image loader
�25
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 80: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/80.jpg)
Session type for image loader
�25
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
![Page 81: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/81.jpg)
Session type for image loader
�25
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
RequestImage
ImgCacheCmd
![Page 82: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/82.jpg)
Session type for image loader
�26
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 83: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/83.jpg)
Session type for image loader
�26
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
string ! Requester ( ImgCacheCmd
![Page 84: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/84.jpg)
Session type for image loader
�26
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
“http://…”
string ! Requester ( ImgCacheCmd
![Page 85: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/85.jpg)
Session type for image loader
�27
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Requester ( ImgCacheCmd
![Page 86: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/86.jpg)
Session type for image loader
�27
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
c
Requester ( ImgCacheCmd
![Page 87: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/87.jpg)
Session type for image loader
�28
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
![Page 88: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/88.jpg)
Session type for image loader
�28
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Exit
ImgCacheCmd
![Page 89: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/89.jpg)
Session type for image loader
�29
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
�{Running : ImgCacheCmd,Done : ResourceThread⌦ 1}
![Page 90: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/90.jpg)
Session type for image loader
�29
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Running
�{Running : ImgCacheCmd,Done : ResourceThread⌦ 1}
![Page 91: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/91.jpg)
Session type for image loader
�30
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
![Page 92: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/92.jpg)
Session type for image loader
�30
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
![Page 93: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/93.jpg)
Session type for image loader
�31
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
components change their session type along with message exchange
![Page 94: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/94.jpg)
Taking stock
�32
![Page 95: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/95.jpg)
Taking stock
• Session types make explicit the protocols of message exchange between concurrently executing components.
�32
![Page 96: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/96.jpg)
Taking stock
• Session types make explicit the protocols of message exchange between concurrently executing components.
• Typing ensures protocol adherence.
�32
![Page 97: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/97.jpg)
Taking stock
• Session types make explicit the protocols of message exchange between concurrently executing components.
• Typing ensures protocol adherence.
• Types make explicit interdependencies between components, enabling sequential reasoning about a component.
�32
![Page 98: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/98.jpg)
Taking stock
• Session types make explicit the protocols of message exchange between concurrently executing components.
• Typing ensures protocol adherence.
• Types make explicit interdependencies between components, enabling sequential reasoning about a component.
�32
Session types are the types of message-passing concurrency.
![Page 99: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/99.jpg)
Session types in research and practice
�33
![Page 100: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/100.jpg)
Session types in research and practice
Research • active research area since inception in 90s [Honda 1993] • logical reconstruction based on linear logic, providing strong
guarantees [Caires & Pfenning 2010, Wadler 2012] • extension of logical session types to sharing [Balzer & Pfenning ICFP
2017, Balzer et al. CONCUR 2018, Balzer et al. ESOP 2019]
�33
![Page 101: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/101.jpg)
Session types in research and practice
Research • active research area since inception in 90s [Honda 1993] • logical reconstruction based on linear logic, providing strong
guarantees [Caires & Pfenning 2010, Wadler 2012] • extension of logical session types to sharing [Balzer & Pfenning ICFP
2017, Balzer et al. CONCUR 2018, Balzer et al. ESOP 2019]
Practice • Lightweight integration of session types or session libraries (with
varying static guarantees) into Scala, Java, Haskell, OCaml, Go, Rust, Python.
• Collaboration with Mozilla Research on integrating our work.
�33
![Page 102: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/102.jpg)
Session types in research and practice
Research • active research area since inception in 90s [Honda 1993] • logical reconstruction based on linear logic, providing strong
guarantees [Caires & Pfenning 2010, Wadler 2012] • extension of logical session types to sharing [Balzer & Pfenning ICFP
2017, Balzer et al. CONCUR 2018, Balzer et al. ESOP 2019]
Practice • Lightweight integration of session types or session libraries (with
varying static guarantees) into Scala, Java, Haskell, OCaml, Go, Rust, Python.
• Collaboration with Mozilla Research on integrating our work.
�33
![Page 103: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/103.jpg)
Logic-based shared session types
�34
![Page 104: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/104.jpg)
Linear logic session types
�35
![Page 105: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/105.jpg)
Linear logic session types
Provide strong guarantees: • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
�35
![Page 106: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/106.jpg)
Linear logic session types
Provide strong guarantees: • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
�35
exactly one client
![Page 107: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/107.jpg)
Linear logic session types
Provide strong guarantees: • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
�35
exactly one client
processes graph forms a tree at run-time
![Page 108: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/108.jpg)
Linear logic session types
Provide strong guarantees • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
But, they rule out sharing
�36
![Page 109: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/109.jpg)
Linear logic session types
Provide strong guarantees • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
But, they rule out sharing
�36
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 110: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/110.jpg)
Linear logic session types
Provide strong guarantees • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
But, they rule out sharing
�36
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
both CmdReceiver and Client communicate with
ImageCache
![Page 111: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/111.jpg)
Linear logic session types
Provide strong guarantees • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
But, they rule out sharing
�37
Linear logic session types cannot accommodate certain practical programming scenarios.
![Page 112: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/112.jpg)
Linear logic session types
Provide strong guarantees • Data-race-freedom • Protocol adherence (a.k.a. session fidelity, preservation) • Deadlock-freedom (a.k.a. progress)
But, they rule out sharing
�37
Let’s introduce sharing while maintaining above guarantees.
Linear logic session types cannot accommodate certain practical programming scenarios.
![Page 113: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/113.jpg)
Challenges of sharing
�38
![Page 114: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/114.jpg)
Challenges of sharing
�38
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 115: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/115.jpg)
Challenges of sharing
�38
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
ImgCacheCmd
![Page 116: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/116.jpg)
Challenges of sharing
�38
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
RequestImage
ImgCacheCmd
![Page 117: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/117.jpg)
Challenges of sharing
�39
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
string ! Requester ( ImgCacheCmd
![Page 118: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/118.jpg)
Challenges of sharing
�39
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ImageCache:
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Exit
string ! Requester ( ImgCacheCmd
protocol violated!
![Page 119: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/119.jpg)
Challenges of sharing
�40
ImgCacheCmd = N {RequestImage : string ! Requester ( ImgCacheCmd,. . .Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
How to restore protocol adherence in the presence of sharing (a.k.a. aliasing)?
![Page 120: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/120.jpg)
Idea: acquire-release
�41
![Page 121: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/121.jpg)
Idea: acquire-release
�41
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
![Page 122: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/122.jpg)
Idea: acquire-release
�41
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
![Page 123: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/123.jpg)
Idea: acquire-release
�41
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
![Page 124: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/124.jpg)
Idea: acquire-release
�42
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel
![Page 125: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/125.jpg)
Idea: acquire-release
�42
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel
acquire
![Page 126: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/126.jpg)
Idea: acquire-release
�43
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
![Page 127: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/127.jpg)
Idea: acquire-release
�43
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
critical section
![Page 128: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/128.jpg)
Idea: acquire-release
�43
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
release
Legend: shared channel linear channel
critical section
![Page 129: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/129.jpg)
Idea: acquire-release
�44
Clients of shared channels must communicate along that channel in mutual exclusion from each other.
Acquiring a shared channel gives exclusive access, releasing an acquired channel relinquishes exclusive access.
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
![Page 130: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/130.jpg)
Have we restored protocol adherence?
�45
![Page 131: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/131.jpg)
Have we restored protocol adherence?
�45
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 132: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/132.jpg)
Have we restored protocol adherence?
�45
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache: ImgCacheCmd
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 133: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/133.jpg)
Have we restored protocol adherence?
�45
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
acquire
ImageCache: ImgCacheCmd
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 134: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/134.jpg)
Have we restored protocol adherence?
�46
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache: ImgCacheCmd
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
![Page 135: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/135.jpg)
Have we restored protocol adherence?
�46
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache: ImgCacheCmd
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
RequestImage
![Page 136: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/136.jpg)
Have we restored protocol adherence?
�47
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
string ! Requester ( ImgCacheCmd
![Page 137: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/137.jpg)
Have we restored protocol adherence?
�47
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
release
string ! Requester ( ImgCacheCmd
![Page 138: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/138.jpg)
Have we restored protocol adherence?
�48
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
string ! Requester ( ImgCacheCmd
![Page 139: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/139.jpg)
Have we restored protocol adherence?
�48
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
string ! Requester ( ImgCacheCmd
acquire
![Page 140: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/140.jpg)
Have we restored protocol adherence?
�49
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
string ! Requester ( ImgCacheCmd
![Page 141: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/141.jpg)
Have we restored protocol adherence?
�49
ResourceThread ImageCache Client
CmdReceiver
Decoder1 Decodern
Legend: shared channel linear channel
ImageCache:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Running : ImgCacheCmd,
Done : ResourceThread⌦ 1}}
string ! Requester ( ImgCacheCmd
Exit
protocol violated!
![Page 142: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/142.jpg)
Idea: equi-synchronizing
�50
![Page 143: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/143.jpg)
Idea: equi-synchronizing
�50
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
![Page 144: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/144.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
![Page 145: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/145.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
![Page 146: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/146.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
![Page 147: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/147.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
![Page 148: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/148.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release✓
![Page 149: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/149.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
✓
![Page 150: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/150.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
✓
✓
![Page 151: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/151.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
release ✓
✓
![Page 152: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/152.jpg)
Idea: equi-synchronizing
�50
i.e., shared channels must be released back to the same type at which they were acquired, if released.
In addition to imposing acquire-release on shared channels, shared channels must be equi-synchronizing:
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
release ✓✗
✓
![Page 153: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/153.jpg)
Taking stock
�51
![Page 154: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/154.jpg)
Taking stock
�51
Acquire-release + equi-synchronizing:
![Page 155: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/155.jpg)
Taking stock
�51
Acquire-release + equi-synchronizing:
restore protocol adherence;
![Page 156: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/156.jpg)
Taking stock
�51
Acquire-release + equi-synchronizing:
restore protocol adherence;
guarantee freedom of (high-level) data races because execution between acquire-release is atomic.
![Page 157: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/157.jpg)
Taking stock
�51
Acquire-release + equi-synchronizing:
restore protocol adherence;
guarantee freedom of (high-level) data races because execution between acquire-release is atomic.
We could state the policy of acquire-release and equi-synchronizing as a programming methodology.
![Page 158: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/158.jpg)
Taking stock
�51
Acquire-release + equi-synchronizing:
restore protocol adherence;
guarantee freedom of (high-level) data races because execution between acquire-release is atomic.
We could state the policy of acquire-release and equi-synchronizing as a programming methodology.
But, why not lift this policy to the type level and have it enforced statically?
![Page 159: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/159.jpg)
Manifest sharing
�52
![Page 160: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/160.jpg)
Manifest sharing
�52
![Page 161: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/161.jpg)
Manifest sharing
�52
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
![Page 162: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/162.jpg)
Manifest sharing
�52
acquire
ImgCacheCmd = N{RequestImage : string ! Requester ( ImgCacheCmd,Exit : � {Done : ResourceThread⌦ 1,
Running : ImgCacheCmd}}
release
release
Legend: shared phase linear phase
![Page 163: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/163.jpg)
Manifest sharing
�53
![Page 164: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/164.jpg)
Manifest sharing
�53
Stratify session types into a linear and shared layer
![Page 165: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/165.jpg)
Manifest sharing
�53
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Stratify session types into a linear and shared layer
![Page 166: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/166.jpg)
Manifest sharing
�53
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Stratify session types into a linear and shared layer
Connect layers with modalities going back and forth
![Page 167: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/167.jpg)
Manifest sharing
�53
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Stratify session types into a linear and shared layer
Connect layers with modalities going back and forth
![Page 168: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/168.jpg)
Manifest sharing
�53
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Stratify session types into a linear and shared layer
Connect layers with modalities going back and forth
Support communication of shared channels
![Page 169: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/169.jpg)
Manifest sharing
�53
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Stratify session types into a linear and shared layer
Connect layers with modalities going back and forth
Support communication of shared channels
![Page 170: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/170.jpg)
Manifest sharing
�54
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
![Page 171: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/171.jpg)
Manifest sharing
�54
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
ImgCacheCmd = "S
L N{RequestImage : string ! Requester ( #S
L ImgCacheCmd,
Exit : � {Done : ResourceThread⌦ 1,
Running : #S
L ImgCacheCmd}}
![Page 172: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/172.jpg)
Manifest sharing
�54
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
ImgCacheCmd = "S
L N{RequestImage : string ! Requester ( #S
L ImgCacheCmd,
Exit : � {Done : ResourceThread⌦ 1,
Running : #S
L ImgCacheCmd}}
![Page 173: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/173.jpg)
Manifest sharing
�54
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
ImgCacheCmd = "S
L N{RequestImage : string ! Requester ( #S
L ImgCacheCmd,
Exit : � {Done : ResourceThread⌦ 1,
Running : #S
L ImgCacheCmd}}
![Page 174: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/174.jpg)
Manifest sharing
�54
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Up and down shifts denote acquire and release, resp.
ImgCacheCmd = "S
L N{RequestImage : string ! Requester ( #S
L ImgCacheCmd,
Exit : � {Done : ResourceThread⌦ 1,
Running : #S
L ImgCacheCmd}}
![Page 175: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/175.jpg)
Typing judgments
�55
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
![Page 176: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/176.jpg)
Typing judgments
�55
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
![Page 177: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/177.jpg)
Typing judgments
�55
�; � �⌃ P ∶∶ (xL ∶ AL)� �⌃ P ∶∶ (xS ∶ AS)
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
![Page 178: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/178.jpg)
Typing judgments
�55
�; � �⌃ P ∶∶ (xL ∶ AL)� �⌃ P ∶∶ (xS ∶ AS)
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
“Process P provides session of type Am along xm using channels in (� and) �.”
![Page 179: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/179.jpg)
Typing judgments
�55
�; � �⌃ P ∶∶ (xL ∶ AL)� �⌃ P ∶∶ (xS ∶ AS)
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
“Process P provides session of type Am along xm using channels in (� and) �.”
shared (structural) context
![Page 180: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/180.jpg)
Typing judgments
�56
�; � �⌃ P ∶∶ (xL ∶ AL)� �⌃ P ∶∶ (xS ∶ AS)
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
“Process P provides session of type Am along xm using channels in (� and) �.”
![Page 181: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/181.jpg)
Typing judgments
�56
�; � �⌃ P ∶∶ (xL ∶ AL)� �⌃ P ∶∶ (xS ∶ AS)
AS � ↑SLAL
AL,BL � ⊕{l ∶ AL} � AL ⊗BL � 1 � ∃x∶AS.BL �N{l ∶ AL} � AL � BL � ↓SLAS � ⇧x∶AS.BL
Based on correspondence between intuitionistic linear logic and session-typed pi-calculus:
“Process P provides session of type Am along xm using channels in (� and) �.”
linear (substructural) context
![Page 182: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/182.jpg)
Typing of acquire
�57
![Page 183: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/183.jpg)
Typing of acquire
�57
�, xS ∶↑SL AL; �, xL ∶ AL �⌃ QxL ∶∶ (zL ∶ CL)�, xS ∶↑SL AL; � �⌃ xL ← acquire xS ;QxL ∶∶ (zL ∶ CL) (T-↑SLL)
![Page 184: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/184.jpg)
Typing of acquire
�57
�, xS ∶↑SL AL; �, xL ∶ AL �⌃ QxL ∶∶ (zL ∶ CL)�, xS ∶↑SL AL; � �⌃ xL ← acquire xS ;QxL ∶∶ (zL ∶ CL) (T-↑SLL)
![Page 185: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/185.jpg)
Typing of acquire
�57
�, xS ∶↑SL AL; �, xL ∶ AL �⌃ QxL ∶∶ (zL ∶ CL)�, xS ∶↑SL AL; � �⌃ xL ← acquire xS ;QxL ∶∶ (zL ∶ CL) (T-↑SLL)
�; ⋅ �⌃ PxL ∶∶ (xL ∶ AL)� �⌃ xL ← accept xS ;PxL ∶∶ (xS ∶↑SL AL) (T-↑SLR)
![Page 186: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/186.jpg)
Typing of acquire
�57
�, xS ∶↑SL AL; �, xL ∶ AL �⌃ QxL ∶∶ (zL ∶ CL)�, xS ∶↑SL AL; � �⌃ xL ← acquire xS ;QxL ∶∶ (zL ∶ CL) (T-↑SLL)
�; ⋅ �⌃ PxL ∶∶ (xL ∶ AL)� �⌃ xL ← accept xS ;PxL ∶∶ (xS ∶↑SL AL) (T-↑SLR)
![Page 187: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/187.jpg)
Typing of release
�58
![Page 188: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/188.jpg)
Typing of release
�58
�, xS ∶ AS; � �⌃ QxS ∶∶ (zL ∶ CL)�; �, xL ∶↓SL AS �⌃ xS ← release xL ;QxS ∶∶ (zL ∶ CL) (T-↓SLL)
![Page 189: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/189.jpg)
Typing of release
�58
�, xS ∶ AS; � �⌃ QxS ∶∶ (zL ∶ CL)�; �, xL ∶↓SL AS �⌃ xS ← release xL ;QxS ∶∶ (zL ∶ CL) (T-↓SLL)
![Page 190: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/190.jpg)
Typing of release
�58
�, xS ∶ AS; � �⌃ QxS ∶∶ (zL ∶ CL)�; �, xL ∶↓SL AS �⌃ xS ← release xL ;QxS ∶∶ (zL ∶ CL) (T-↓SLL)
� �⌃ PxS ∶∶ (xS ∶ AS)�; ⋅ �⌃ xS ← detach xL ;PxS ∶∶ (xL ∶↓SL AS) (T-↓SLR)
![Page 191: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/191.jpg)
Typing of release
�58
�, xS ∶ AS; � �⌃ QxS ∶∶ (zL ∶ CL)�; �, xL ∶↓SL AS �⌃ xS ← release xL ;QxS ∶∶ (zL ∶ CL) (T-↓SLL)
� �⌃ PxS ∶∶ (xS ∶ AS)�; ⋅ �⌃ xS ← detach xL ;PxS ∶∶ (xL ∶↓SL AS) (T-↓SLR)
![Page 192: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/192.jpg)
Taking stock
�59
![Page 193: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/193.jpg)
Taking stock
�59
We have a session type system that allows shared and linear channels to coexist and guarantees:
data-race-freedom (low-level and high-level)
protocol adherence
![Page 194: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/194.jpg)
Taking stock
�59
We have a session type system that allows shared and linear channels to coexist and guarantees:
data-race-freedom (low-level and high-level)
protocol adherence
What about deadlock-freedom?
![Page 195: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/195.jpg)
Why are linear session types deadlock-free?
�60
![Page 196: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/196.jpg)
Why are linear session types deadlock-free?
�60
Linearity (“exactly one client”) turns process graph into a tree.
![Page 197: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/197.jpg)
Why are linear session types deadlock-free?
�60
a
b c d
e f g
parent: client
child: provider
Linearity (“exactly one client”) turns process graph into a tree.
Legend: linear channel
![Page 198: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/198.jpg)
Why are linear session types deadlock-free?
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 199: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/199.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 200: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/200.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 201: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/201.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 202: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/202.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not• client ready to synchronize, provider not
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 203: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/203.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not• client ready to synchronize, provider not
• Let’s visualize this waiting dependency with a green arrow
�61
a
b c d
e f g
Legend: linear channel
Linearity (“exactly one client”) turns process graph into a tree.
![Page 204: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/204.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not• client ready to synchronize, provider not
• Let’s visualize this waiting dependency with a green arrow
�61
a
b c d
e f g
Legend: linear channel a b “a waits for b”
Linearity (“exactly one client”) turns process graph into a tree.
![Page 205: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/205.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not• client ready to synchronize, provider not
• Let’s visualize this waiting dependency with a green arrow
�61
a
b c d
e f g
Legend: linear channel a b “a waits for b”
Linearity (“exactly one client”) turns process graph into a tree.
![Page 206: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/206.jpg)
Why are linear session types deadlock-free?
What are the threats to progress?• Two scenarios:
• provider ready to synchronize, client not• client ready to synchronize, provider not
• Let’s visualize this waiting dependency with a green arrow
�61
a
b c d
e f g
Legend: linear channel a b “a waits for b”
No green cycles: green arrows can only go along linear channels, and client and provider cannot both be waiting for each other.
Linearity (“exactly one client”) turns process graph into a tree.
![Page 207: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/207.jpg)
Let’s add sharing
�62
![Page 208: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/208.jpg)
Let’s add sharing
�62
We get a graph of linear and shared processes, with a linear tree inside.
![Page 209: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/209.jpg)
Let’s add sharing
�62
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
![Page 210: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/210.jpg)
Let’s add sharing
�62
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
![Page 211: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/211.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
![Page 212: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/212.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”
![Page 213: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/213.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies
![Page 214: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/214.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow
![Page 215: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/215.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow
a b “a waits for b to release resource”
![Page 216: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/216.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow
a b “a waits for b to release resource”
![Page 217: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/217.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow
a b “a waits for b to release resource”
![Page 218: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/218.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow
a b “a waits for b to release resource”
![Page 219: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/219.jpg)
Let’s add sharing
�63
a
b c d
e f g
We get a graph of linear and shared processes, with a linear tree inside.
Legend: linear channel linear process
shared channel
shared process
Acquire-release amounts to “locking”• Possibility of cyclic dependencies• Let’s visualize this waiting dependency
with a red arrow• Note: red arrows can connect arbitrary
nodes
a b “a waits for b to release resource”
![Page 220: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/220.jpg)
Can we re-establish deadlock-freedom?
�64
![Page 221: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/221.jpg)
Can we re-establish deadlock-freedom?
An enticing solution: “locking up” • Impose a partial order on resources. • Ensure that resources are acquired (“locked”) in increasing order.
�64
![Page 222: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/222.jpg)
Can we re-establish deadlock-freedom?
An enticing solution: “locking up” • Impose a partial order on resources. • Ensure that resources are acquired (“locked”) in increasing order.
�64
However, cyclic dependencies between acquire requests are not the only source of deadlock!
![Page 223: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/223.jpg)
Can we re-establish deadlock-freedom?
An enticing solution: “locking up” • Impose a partial order on resources. • Ensure that resources are acquired (“locked”) in increasing order.
�64
However, cyclic dependencies between acquire requests are not the only source of deadlock!
Two Forms of waiting dependencies:
![Page 224: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/224.jpg)
Can we re-establish deadlock-freedom?
An enticing solution: “locking up” • Impose a partial order on resources. • Ensure that resources are acquired (“locked”) in increasing order.
�64
However, cyclic dependencies between acquire requests are not the only source of deadlock!
Two Forms of waiting dependencies:• waiting to synchronize: a b “a waits for b to synchronize”
![Page 225: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/225.jpg)
Can we re-establish deadlock-freedom?
An enticing solution: “locking up” • Impose a partial order on resources. • Ensure that resources are acquired (“locked”) in increasing order.
�64
However, cyclic dependencies between acquire requests are not the only source of deadlock!
Two Forms of waiting dependencies:• waiting to synchronize:• waiting to release:
a b “a waits for b to synchronize”a b “a waits for b to release resource”
![Page 226: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/226.jpg)
Can we re-establish deadlock-freedom?
�65
Two Forms of waiting dependencies: • waiting to synchronize: • waiting to release:
a b “a waits for b to synchronize”a b “a waits for b to release resource”
![Page 227: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/227.jpg)
Can we re-establish deadlock-freedom?
�65
Two Forms of waiting dependencies: • waiting to synchronize: • waiting to release:
a b “a waits for b to synchronize”a b “a waits for b to release resource”
a
b c d
e f g
![Page 228: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/228.jpg)
Can we re-establish deadlock-freedom?
�65
Two Forms of waiting dependencies: • waiting to synchronize: • waiting to release:
a b “a waits for b to synchronize”a b “a waits for b to release resource”
a
b c d
e f g
a
b d d
e f g
![Page 229: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/229.jpg)
Can we re-establish deadlock-freedom?
�65
Two Forms of waiting dependencies: • waiting to synchronize: • waiting to release:
a b “a waits for b to synchronize”a b “a waits for b to release resource”
a
b c d
e f g
a
b d d
e f g
Cycles can consist of red arrows only or a combination of red and green arrows.
![Page 230: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/230.jpg)
Idea: competitors and collaborators
�66
![Page 231: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/231.jpg)
Idea: competitors and collaborators
�66
Competitors: overlap in set of resources acquired
![Page 232: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/232.jpg)
Idea: competitors and collaborators
�66
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
![Page 233: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/233.jpg)
Idea: competitors and collaborators
�66
Notice: a resource acquired becomes a child of the acquirer
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
![Page 234: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/234.jpg)
Idea: competitors and collaborators
�66
a
Notice: a resource acquired becomes a child of the acquirer
b c
12
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
![Page 235: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/235.jpg)
Idea: competitors and collaborators
�67
a
Notice: a resource acquired becomes a child of the acquirer
b c
1
2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
![Page 236: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/236.jpg)
Idea: competitors and collaborators
�68
a
Notice: a resource acquired becomes a child of the acquirer
b c
1 2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
![Page 237: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/237.jpg)
Idea: competitors and collaborators
�69
a
Notice: a resource acquired becomes a child of the acquirer
b c
1 2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
competitors tend to be siblings
![Page 238: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/238.jpg)
Idea: competitors and collaborators
�69
a
Notice: a resource acquired becomes a child of the acquirer
b c
1 2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
competitors tend to be siblings
{b, c}
![Page 239: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/239.jpg)
Idea: competitors and collaborators
�69
a
Notice: a resource acquired becomes a child of the acquirer
b c
1 2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
collaborators tend to be in the same branch
competitors tend to be siblings
{b, c}
![Page 240: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/240.jpg)
Idea: competitors and collaborators
�69
a
Notice: a resource acquired becomes a child of the acquirer
b c
1 2
Competitors: overlap in set of resources acquired
Collaborators: do not overlap in set of resources acquired
collaborators tend to be in the same branch
competitors tend to be siblings
{a, b, 1} {a, b, 2} {a, c}
{b, c}
![Page 241: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/241.jpg)
Manifest deadlock-freedom
�70
![Page 242: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/242.jpg)
Manifest deadlock-freedom
�70
Define type system enforcing the following invariants:
collaborators
a
b c
1 2
competitors
![Page 243: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/243.jpg)
Manifest deadlock-freedom
�70
Define type system enforcing the following invariants:
collaborators
a
b c
1 2
competitors
competitors employ locking-up for resources they compete forA
![Page 244: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/244.jpg)
Manifest deadlock-freedom
�70
Define type system enforcing the following invariants:
collaborators
a
b c
1 2
competitors
collaborators acquire mutually disjoint sets of resourcesB
competitors employ locking-up for resources they compete forA
![Page 245: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/245.jpg)
Manifest deadlock-freedom
�70
Define type system enforcing the following invariants:
collaborators
a
b c
1 2
competitors
collaborators acquire mutually disjoint sets of resourcesB
competitors employ locking-up for resources they compete forA
competitors have released all acquired resources when synchronizing with other competitors (“tallking-up”)
C
![Page 246: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/246.jpg)
Manifest deadlock-freedom
�70
Define type system enforcing the following invariants:
collaborators
a
b c
1 2
competitors
collaborators acquire mutually disjoint sets of resourcesB
competitors employ locking-up for resources they compete forA
competitors have released all acquired resources when synchronizing with other competitors (“tallking-up”)
C
A rules out red-arrow cycles, B and C rule out red-green-arrow cycles.
![Page 247: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/247.jpg)
Manifest deadlock-freedom
�71
![Page 248: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/248.jpg)
Manifest deadlock-freedom
�71
Introduce a world, an abstract value equipped with a partial order.
![Page 249: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/249.jpg)
Manifest deadlock-freedom
�71
Every process invariantly resides at a world.
Introduce a world, an abstract value equipped with a partial order.
![Page 250: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/250.jpg)
Manifest deadlock-freedom
�71
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
![Page 251: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/251.jpg)
Manifest deadlock-freedom
�71
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 252: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/252.jpg)
Manifest deadlock-freedom
�71
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 253: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/253.jpg)
Manifest deadlock-freedom
�71
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
worlds associated with process
![Page 254: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/254.jpg)
Manifest deadlock-freedom
�72
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 255: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/255.jpg)
Manifest deadlock-freedom
�72
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 256: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/256.jpg)
Manifest deadlock-freedom
�72
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
self-world: world at which process
resides
![Page 257: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/257.jpg)
Manifest deadlock-freedom
�73
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 258: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/258.jpg)
Manifest deadlock-freedom
�73
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 259: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/259.jpg)
Manifest deadlock-freedom
�73
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
min-world: world of minimal resource
to be acquired
![Page 260: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/260.jpg)
Manifest deadlock-freedom
�74
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 261: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/261.jpg)
Manifest deadlock-freedom
�74
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 262: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/262.jpg)
Manifest deadlock-freedom
�74
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
max-world: world of maximal resource to be
acquired
![Page 263: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/263.jpg)
Manifest deadlock-freedom
�75
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 264: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/264.jpg)
Manifest deadlock-freedom
�75
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 265: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/265.jpg)
Manifest deadlock-freedom
�75
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
world order
![Page 266: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/266.jpg)
Manifest deadlock-freedom
�76
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 267: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/267.jpg)
Manifest deadlock-freedom
�76
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 268: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/268.jpg)
Manifest deadlock-freedom
�76
Every process invariantly resides at a world.
Every process indicates the range of worlds it may acquire.
Introduce a world, an abstract value equipped with a partial order.
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
possibly “aliased” linear channels
![Page 269: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/269.jpg)
Manifest deadlock-freedom
�77
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
![Page 270: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/270.jpg)
Manifest deadlock-freedom
�77
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
![Page 271: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/271.jpg)
Manifest deadlock-freedom
�77
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
![Page 272: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/272.jpg)
Manifest deadlock-freedom
�77
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
![Page 273: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/273.jpg)
Manifest deadlock-freedom
�77
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
collaborators
a
b c
1 2
competitors
no vertical red arrows
![Page 274: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/274.jpg)
Manifest deadlock-freedom
�78
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
![Page 275: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/275.jpg)
Manifest deadlock-freedom
�78
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
![Page 276: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/276.jpg)
Manifest deadlock-freedom
�78
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
collaborators
a
b c
1 2
competitors
no red cycles
![Page 277: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/277.jpg)
Manifest deadlock-freedom
�79
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
![Page 278: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/278.jpg)
Manifest deadlock-freedom
�79
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
for right-rule: Φ must be empty
![Page 279: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/279.jpg)
Manifest deadlock-freedom
�79
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
for right-rule: Φ must be empty
collaborators
a
b c
1 2
competitors
no ingoing red and up-going green arrow
![Page 280: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/280.jpg)
Manifest deadlock-freedom
�80
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
for right-rule: Φ must be empty
![Page 281: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/281.jpg)
Manifest deadlock-freedom
�80
; � `⌃ P :: (xS : AS[!kl!n!l
]) (where + irreflexive)
; �; �; � `⌃ P :: (xL : AL[!kl!n!l
]) (where + irreflexive)
Express invariants A, B, and C in terms of:
min(parent) ≤ self(acquired_child) ≤ max(parent)
max(parent) < min(child)
for an acquire: lock-up
for right-rule: Φ must be empty
These low-level invariants are enforced by typing.
![Page 282: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/282.jpg)
Taking stock
�81
![Page 283: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/283.jpg)
Taking stock
�81
We have a session type system that allows shared and linear channels to coexist and guarantees:
data-race-freedom (low-level and high-level)
protocol adherence
deadlock-freedom
![Page 284: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/284.jpg)
Taking stock
�81
We have a session type system that allows shared and linear channels to coexist and guarantees:
data-race-freedom (low-level and high-level)
protocol adherence
deadlock-freedom
We have increased practicality of linear session types while maintaining their guarantees.
![Page 285: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/285.jpg)
Current & future work
�82
![Page 286: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/286.jpg)
Digital contracts (with Hoffmann, Pfenning, and Das)
�83
![Page 287: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/287.jpg)
Digital contracts (with Hoffmann, Pfenning, and Das)
�83
Unique application field for shared session types:
![Page 288: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/288.jpg)
Digital contracts (with Hoffmann, Pfenning, and Das)
�83
Unique application field for shared session types:
auction = "S
L � {running : N{bid : id ! money ( #S
Lauction,cancel : #S
Lauction},ended : id ! �{won : lot⌦ #S
Lauction,lost : money ⌦ #S
Lauction}}
![Page 289: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/289.jpg)
Digital contracts (with Hoffmann, Pfenning, and Das)
�83
Unique application field for shared session types:
auction = "S
L � {running : N{bid : id ! money ( #S
Lauction,cancel : #S
Lauction},ended : id ! �{won : lot⌦ #S
Lauction,lost : money ⌦ #S
Lauction}}
Resource analysis for static prediction of execution cost.
![Page 290: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/290.jpg)
Digital contracts (with Hoffmann, Pfenning, and Das)
�83
Unique application field for shared session types:
auction = "S
L � {running : N{bid : id ! money ( #S
Lauction,cancel : #S
Lauction},ended : id ! �{won : lot⌦ #S
Lauction,lost : money ⌦ #S
Lauction}}
Resource analysis for static prediction of execution cost.
Under development: Nomos, a digital contract language based on resource-aware shared session types.
![Page 291: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/291.jpg)
Unifying parallelism and concurrency
�84
![Page 292: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/292.jpg)
Unifying parallelism and concurrency
�84
Shared session types recover expressiveness of untyped asynchronous pi-calculus [Balzer et al. CONCUR 2018]
![Page 293: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/293.jpg)
Unifying parallelism and concurrency
�84
Shared session types recover expressiveness of untyped asynchronous pi-calculus [Balzer et al. CONCUR 2018]
introduce nondeterminism
![Page 294: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/294.jpg)
Unifying parallelism and concurrency
�84
Shared session types recover expressiveness of untyped asynchronous pi-calculus [Balzer et al. CONCUR 2018]
introduce nondeterminism
linear logic session types are deterministic
![Page 295: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/295.jpg)
Unifying parallelism and concurrency
�84
Shared session types recover expressiveness of untyped asynchronous pi-calculus [Balzer et al. CONCUR 2018]
introduce nondeterminism
linear logic session types are deterministic
Opportunity for unifying framework that combines both deterministic (parallel) and nondeterministic (concurrent) computation.
![Page 296: Shared Session Types for Safe, Practical Concurrencybalzers/publications/safe_concurrency.pdf · Concurrency is ubiquitous Many programming problems demand concurrency • Flight](https://reader036.fdocuments.us/reader036/viewer/2022062604/5fc2dc97037b8b36b45f113b/html5/thumbnails/296.jpg)
Thank you for your attention!
Papers for this talk: • Stephanie Balzer and Frank Pfenning: Manifest Sharing with Session
Types. ICFP 2017. • Stephanie Balzer, Bernardo Toninho, and Frank Pfenning: Manifest
Deadlock-Freedom for Shared Session Types. ESOP 2019. • Stephanie Balzer, Frank Pfenning, and Bernardo Toninho: A Universal
Session Type for Untyped Asynchronous Communication. CONCUR 2019.
�85