livingmylivetothefullest

It's about life

Chapter 13

Concurrency

Assignment from Tri Djoko Wahjono

Review Questions

1. What are the three possible levels of concurrency in programs?
Instruction level, Statement level, and Unit level

2. Describe the logical architecture of an SIMD computer.
Computers that have multiple processors that execute the same instruction simultaneously

3. Describe the logical architecture of an MIMD computer.
Computers that have multiple processors that operate independently but whose operations can be synchronized

4. What level of program concurrency is best supported by SIMD computers?
Instruction concurrency level

5. What level of program concurrency is best supported by MIMD computers?
Unit concurrency level.

6. Describe the logical architecture of a vector processor.
Vector processors have groups of registers that store the operands of a vector operation in which the same instruction is executed on the whole group of operands simultaneously

7. What is the difference between physical and logical concurrency?
Physical concurrency ā€“ Multiple independent processors (multiple threads of control)
Logical concurrency ā€“ The appearance of physical concurrency is presented by time-sharing one processor (software can be designed as if there were multiple threads of control)

8. What is a thread of control in a program?
A thread of control in a program is the sequence of program points reached as control flows through the program

12. What is a heavyweight task? What is a lightweight task?
Heavyweight tasks execute in their own address space. Lightweight tasks all run in the same address space ā€“ more efficient

Problem Set

1. Explain clearly why competition synchronization is not a problem in a programming environment that supports coroutines but not concurrency.
Competition synchronization is not necessary when no actual concurrency takes place simply because there can be no concurrent contention for shared resources. Two nonconcurrent processes cannot arrive at a resource at the same time.

2. What is the best action a system can take when deadlock is detected?
When deadlock occurs, assuming that only two program units are causing the deadlock, one of the involved program units should be gracefully terminated, thereby allowed the other to continue.

3. Busy waiting is a method whereby a task waits for a given event by continuously checking for that event to occur. What is the main problem with this approach?
The main problem with busy waiting is that machine cycles are wasted in the process.

4. In the producer-consumer example of Section 13.3, suppose that we incorrectly replaced the release(access) in the consumer process with wait(access). What would be the result of this error on execution of the system?
Deadlock would occur if the release(access) were replaced by a wait(access) in the consumer process, because instead of relinquishing access control, the consumer would wait for control that it already had.

6. Suppose two tasks, A and B, must use the shared variable Buf_Size. Task A adds 2 to Buf_Size, and task B subtracts 1 from it. Assume that such arithmetic operations are done by the three-step process of fetching the current value, performing the arithmetic, and putting the new value back. In the absence of competition synchronization, what sequences of events are possible and what values result from these operations? Assume that the initial value of Buf_Size is 6.
Sequence 1: A fetches the value of BUF_SIZE (6)

A adds 2 to the value (8)

A puts 8 in BUF_SIZE

B fetches the value of BUF_SIZE (8)

B subtracts 1 (7)

B put 7 in BUF_SIZE

BUF_SIZE = 7

Sequence 2: A fetches the value of BUF_SIZE (6)

B fetches the value of BUF_SIZE (6)

A adds 2 (8)

B subtracts 1 (5)

A puts 8 in BUF_SIZE

B puts 5 in BUF_SIZE

BUF_SIZE = 5

Sequence 3: A fetches the value of BUF_SIZE (6)

B fetches the value of BUF_SIZE (6)

A adds 2 (8)

B subtracts 1 (5)

B puts 5 in BUF_SIZE

A puts 8 in BUF_SIZE

BUF_SIZE = 8

Many other sequences are possible, but all produce the values 5, 7, or 8.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on June 28, 2013 by and tagged .
June 2013
M T W T F S S
« Apr   Sep »
 12
3456789
10111213141516
17181920212223
24252627282930

Blog Stats

  • 6,909 hits
%d bloggers like this: