Embody the data item with the ability-control access to itself

Source: Internet
Author: User

Computer Science an overview _j Glenn brookshear _11th Edition

Such communication needs have long been a topic of study among computer scientists, and many newer programming languages R Eflect various approaches to thread interaction problems. As an example, let us consider the communication problems encountered when both threads manipulate the same data. (This example was presented in more detail in the optional section 3.4.) If Each of the threads this is executing concurrently need to add the value three to a common item of data, a method is n Eeded to ensure this one thread is allowed to complete its transaction before the and is allowed to perform its task. Otherwise they could both start their individual computations with the same initial value,which would mean that the final Result would is incremented by only three rather than six. Data that can being accessed by only one thread at a time was said to has mutually exclusive access.

One-to-implement mutually exclusive access is-write the program units this describe the threads involved so that WH En a thread is the using shared data, it blocks other threads from accessing, the data until such access is safe. (This was the approach described in the optional section 3.4, where we identified the portion of a process that accesses SH Ared data as a critical region.) Experience have shown that this approach have the drawback of distributing the task of ensuring mutual exclusion throughout Various parts of the Program-each program unit accessing the data must being properly designed to enforce mutual exclusion, a nd thus a mistake in a single segment can corrupt the entire system. For this reason many argue, a better solution is to embody the data item with the ability-control access to itself. In short, instead of relying on the threads. Access the data to guard against multiple access, the data item itself I S assigned this responsibility. The result is this contrOl of access is concentrated at a single point in the program rather than dispersed among many program units. A data item augmented with the ability-control access to itself is often called a monitor.

We conclude that the design of programming languages for parallel processing involves developing ways to express such thin GS as the creation of threads, the pausing and restarting of threads, the identification of critical regions, and the comp Osition of monitors.

Embody the data item with the ability-control access to itself

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.