Foundations of Multithreaded, Parallel, and Distributed Programming

Gregory R. Andrews

Mentioned 2

Foundations of Multithreaded, Parallel, and Distributed Programming covers, and then applies, the core concepts and techniques needed for an introductory course in this subject. Its emphasis is on the practice and application of parallel systems, using real-world examples throughout. Greg Andrews teaches the fundamental concepts of multithreaded, parallel and distributed computing and relates them to the implementation and performance processes. He presents the appropriate breadth of topics and supports these discussions with an emphasis on performance.Features Emphasizes how to solve problems, with correctness the primary concern and performance an important, but secondary, concern Includes a number of case studies which cover such topics as pthreads, MPI, and OpenMP libraries, as well as programming languages like Java, Ada, high performance Fortran, Linda, Occam, and SR Provides examples using Java syntax and discusses how Java deals with monitors, sockets, and remote method invocation Covers current programming techniques such as semaphores, locks, barriers, monitors, message passing, and remote invocation Concrete examples are executed with complete programs, both shared and distributed Sample applications include scientific computing and distributed systems 0201357526B04062001

More on Amazon.com

Mentioned in questions and answers.

I am a beginner on Stack Overflow. I am working on a Unix platform in C/C++. Knowing basic programming in these regards how could I start with multithreading?

Multithreading seems to be very interesting and I want to grow my knowledge in this regard.

How could I get started with multithreading and what are the best techniques/books/ebooks/articles available to grab the concepts as early as possible?

Everything depends on you goals. There is plenty of code and articles with common multi-threading problems solved based on POSIX threads framework (I see number of recommendations of good articles here). The main question is what do you want to build. For some tasks it is not recommended to go multi-threading at all.

Here is book "Foundations of Multithreaded, Parallel, and Distributed Programming" which is related to discussed topic and which I'd like to recommend. The most significant advantage of it is 'relatively easy to read' style but no hard linkage to POSIX threads ideology (which is common problem).

My book presents a simple example which I'm a bit confused about:

It says, "consider the following program, and assume that the fine-grained atomic actions are reading and writing the variables:"

int y = 0, z = 0;
co x = y+z; // y=1; z=2; oc;

"If x = y + z is implemented by loading a register with y and then adding z to it, the final value of x can be 0,1,2, or 3. "

2? How does 2 work?

Note: co starts a concurrent process and // denote parallel-running statements

In your program there are two parallel sequences:

Sequence 1: x = y+z;

Sequence 2: y=1; z=2;

The operations of sequence 1 are:

  1. y Copy the value of y into a register.
  2. + z Add the value of z to the value in the register.
  3. x = Copy the value of the register into x.

The operations of sequence 2 are:

  1. y=1; Set the value of y to 1.
  2. z=2; Set the value of z to 2.

These two sequences are running at the same time, though the steps within a sequence must occur in order. Therefore, you can get an x value of '2' in the following sequence:

  1. y=0
  2. z=0
  3. y Copy the value of y into a register. (register value is now '0')
  4. y=1; Set the value of y to 1. (has no effect on the result, we've already copied y to the register)
  5. z=2; Set the value of z to 2.
  6. + z Add the value of z to the value in the register. (register value is now '2')
  7. x = Copy the value of the register into x. (the value of x is now '2')