TAILIEUCHUNG - Concepts, Techniques, and Models of Computer Programming - Chapter 8

Shared-State Concurrency Các mô hình nhà nước đồng thời chia sẻ một phần mở rộng đơn giản để mô hình đồng thời khai báo cho biết thêm rằng nhà nước rõ ràng trong hình thức của các tế bào, mà là một loại thay đổi biến. Mô hình này là tương đương trong biểu cảm đến các thông điệp đi qua mô hình đồng thời Chương 5, bởi vì các tế bào có thể được thực hiện có hiệu quả với các cảng và ngược lại. Trong thực tế, tuy nhiên, mô hình nhà nước chia sẻ khó khăn. | Chapter 8 Shared-State Concurrency The shared-state concurrent model is a simple extension to the declarative concurrent model that adds explicit state in the form of cells which are a kind of mutable variable. This model is equivalent in expressiveness to the message-passing concurrent model of Chapter 5 because cells can be efficiently implemented with ports and vice versa. In practice however the shared-state model is harder to program than the message-passing model. Let us see what the problem is and how we can solve it. The inherent difficulty of the model Let us first see exactly why the shared-state model is so difficult. Execution consists of multiple threads all executing independently and all accessing shared cells. At some level a thread s execution can be seen as a sequence of atomic instructions. For a cell these are @ access assignment and Exchange. Because of the interleaving semantics all execution happens as if there was one global order of operations. All operations of all threads are therefore interleaved to make this order. There are many possible interleavings their number is limited only by data dependencies calculations needing results of others . Any particular execution realizes an interleaving. Because thread scheduling is nondeterministic there is no way to know which interleaving will be chosen. But just how many interleavings are possible Let us consider a simple case two threads each doing k cell operations. Thread T1 does the operations a1 a2 . ak and thread T2 does b1 b2 . bk. How many possible executions are there interleaving all these operations It is easy to see that the number is Any interleaved execution consists of 2k operations of which each thread takes 2k k. k. Consider these operations as integers from 1 to 2k put in a set. Then T1 takes k integers from this set and T2 gets the others. This number is exponential in For three or more threads the number of interleavings is even bigger see Exercises . 1Using Stirling s .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.