Changeset e4a2198 for doc/theses
- Timestamp:
- Jun 1, 2023, 12:22:39 PM (19 months ago)
- Branches:
- ast-experimental, master
- Children:
- 3eeeb88
- Parents:
- 4897ffa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/channels.tex
r4897ffa re4a2198 125 125 The deadlock detection in the \CFA channels is fairly basic but detects a very common channel mistake during termination. 126 126 That is, it detects the case where threads are blocked on the channel during channel deallocation. 127 This case is guaranteed to deadlock since there are no producer threads to supply values needed by the waiting consumerthreads.128 Only if a user maintained a separate reference to the consumerthreads and manually unblocks them outside the channel could the deadlock be avoid.129 However, without special consumer semantics, this unblocking would generate other runtime errors where the consumerattempts to access non-existing channel data or even a deallocated channel.127 This case is guaranteed to deadlock since there are no other threads to supply or consume values needed by the waiting threads. 128 Only if a user maintained a separate reference to the blocked threads and manually unblocks them outside the channel could the deadlock be avoid. 129 However, without special semantics, this unblocking would generate other runtime errors where the unblocked thread attempts to access non-existing channel data or even a deallocated channel. 130 130 More robust deadlock detection needs to be implemented separate from channels since it requires knowledge about the threading system and other channel/thread state. 131 131 132 132 \subsection{Program Shutdown} 133 133 Terminating concurrent programs is often one of the most difficult parts of writing concurrent code, particularly if graceful termination is needed. 134 The difficulty for graceful termination often arises from the usage ofsynchronization primitives that need to be handled carefully during shutdown.134 Graceful termination can be difficult to achieve with synchronization primitives that need to be handled carefully during shutdown. 135 135 It is easy to deadlock during termination if threads are left behind on synchronization primitives. 136 136 Additionally, most synchronization primitives are prone to \gls{toctou} issues where there is race between one thread checking the state of a concurrent object and another thread changing the state. … … 179 179 For exceptions thrown from @remove@, the buffer element pointer is null. 180 180 For exceptions thrown from @insert@, the element pointer points to the buffer element that the thread attempted to insert. 181 Utility routines @bool is_insert( channel_closed & e );@ and @bool is_remove( channel_closed & e );@ are provided for convenient checking of the element pointer. 181 182 This element pointer allows the handler to know which operation failed and also allows the element to not be lost on a failed insert since it can be moved elsewhere in the handler. 182 183 Furthermore, due to \CFA's powerful exception system, this data can be used to choose handlers based on which channel and operation failed. … … 288 289 Flag variables are common in Go-channel shutdown-code to avoid panics on a channel, meaning the channel shutdown has to be communicated with threads before it occurs. 289 290 Hence, the two flags @cons_done@ and @prod_done@ are used to communicate with the producers and consumers, respectively. 290 Furthermore, producers and consumers need separate shutdown channels soproducers terminate before the channel is closed to avoid panicking, and to avoid the case where all the consumers terminate first, which can result in a deadlock for producers if the channel is full.291 Furthermore, producers and consumers need to shutdown separately to ensure that producers terminate before the channel is closed to avoid panicking, and to avoid the case where all the consumers terminate first, which can result in a deadlock for producers if the channel is full. 291 292 The producer flag is set first; 292 293 then after all producers terminate, the consumer flag is set and the channel is closed leaving elements in the buffer.
Note: See TracChangeset
for help on using the changeset viewer.