05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.4. Common Approaches to Concurrent and Parallel Programming<br />

The observations for concurrent programming concepts are different. Conventional<br />

approaches based on mutexes require sequential execution of activities<br />

that work on a shared resource in or<strong>de</strong>r to enforce correctness. Programs<br />

using these concepts typically consist of multiple activities that have different<br />

purposes but require a common resource. In such systems, interactions are<br />

resource-centric, without a common purpose, and require that the invariants<br />

for the shared resources hold. Rea<strong>de</strong>r/writer locks for instance exclu<strong>de</strong> only<br />

conflicting operations from using the same resource. Software transactional<br />

memory (cf. Sec. 2.4.3) goes further by removing the need for managing resources<br />

manually. In contrast, event-loop concurrency mo<strong>de</strong>ls (cf. Sec. 2.4.4)<br />

promote resources to active entities that are responsible for managing their<br />

consistency and allow clients to interact via an asynchronous interface only.<br />

Thus, the main commonality of these concepts is the protection of invariants<br />

of shared resources to guarantee correctness, while permitting interaction of<br />

in<strong>de</strong>pen<strong>de</strong>nt activities at runtime.<br />

The following section discusses these approaches in more <strong>de</strong>tail.<br />

2.3.3. Conclusion<br />

To conclu<strong>de</strong>, the <strong>de</strong>finitions of concurrency and parallelism as found in the<br />

literature can be inappropriate when it comes to categorizing concepts.<br />

In contrast, the alternative <strong>de</strong>finitions for concurrent programming and parallel<br />

programming given <strong>here</strong> categorize concepts in two disjoint sets. Instead of<br />

focusing on the execution mo<strong>de</strong>l, these <strong>de</strong>finitions focus on the aspect of programming<br />

and relate to the intent and goal of a programming concept. T<strong>here</strong>fore,<br />

concurrent programming concepts coordinate modifications of shared<br />

resources, while parallel programming concepts coordinate parallel activities<br />

to compute a common result.<br />

2.4. Common Approaches to Concurrent and Parallel<br />

Programming<br />

This section gives an overview of common concepts in the field of concurrent<br />

and parallel programming to provi<strong>de</strong> a foundation for our later discussions.<br />

Note that this section introduces Clojure agents, which are used in later chapters<br />

as running examples and t<strong>here</strong>fore discussed <strong>here</strong> in more <strong>de</strong>tail.<br />

23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!