Model-oriented software architecture 2-concurrent and networked object model Reading Notes (2)-concurrent and networked object 2

Source: Internet
Author: User

2.3 concurrency

Concurrency is a term that involves a series of policies and mechanisms that enable one or more threads or processes to simultaneously execute their service processing tasks. Many network applicationsProgramIn particular, servers must concurrently process requests from multiple clients.

The modern operating system overcomes the limitations of a Single-threaded process by providing a multi-thread concurrency mechanism. This mechanism supports the creation of multiple processes, and each process can contain multiple concurrent threads. In these operating systems, in the address space protected by hardware, processes act as protection and resource allocation units, and threads act as execution units. It has the following advantages:

1) They use parallel processing capabilities of hardware and software platforms to transparently improve performance.

2) They allow programmers to overlap computing and Communication Service Processing, significantly improving performance.

3) They associate different service processing tasks with independent threads in an application to improve the perceptible response time for interactive applications (such as GUI.

4) They simplify application design by allowing multiple service processing tasks to run independently using synchronous programming abstraction (such as bidirectional method calls.

 

Inherent complexity of concurrent application development:

1) In a concurrent application, determine an effective application concurrency architecture, which minimizes the context exchange, synchronization, data replication/mobile overhead of the concurrent application.

2) Design a complex concurrent system that includes synchronous and asynchronous services to process tasks without reducing execution efficiency to simplify programming.

3) select appropriate synchronization primitives to Improve the Performance of concurrent multi-processor applications, prevent resource waste and reduce maintenance costs.

4) eliminate unnecessary threads and locks in concurrent or real-time applications. In the case that the correctness is not compromised, deadlock occurs, or application processing is overly blocked, improves performance or simplifies resource management.

These patterns are components, and subsystems and the entire application define various types of concurrency architectures. Including active object, monitor object, semi-synchronous/semi-asynchronous (half-sync/half-async), leader/follower) and thread-specific storage ).

 

2.4 Synchronization

Concurrent threads can simultaneously access the same object or variable, which may damage their internal state. To prevent this problem, it should not be executed simultaneously in objects or functions.CodeIt can be synchronized within the range of the critical section.

A common method to implement the critical section in an object-oriented program is to hard encode a type of lock object into a class or component. For example, a mutual exclusion (mutex) object is a lock that must be obtained and released serially.

There are two disadvantages to using the low-level operating system API to write these locking technologies:

1) error-prone. It is quite difficult to obtain a lock explicitly before entering the critical section and release it explicitly when exiting the critical section.

2) inflexible and inefficient. Depending on the context in which the application is running, different lock types are required for implementing the critical section. However, if the lock primitive is hard-coded to the software in every place in use, it is completely unnecessary and time-consuming to change the primitive.

These modes can alleviate the above problems to simplify serialization and locking in parallel systems. These modes are scoped locking, strategized locking, thread-safe interface, and double-checked locking optimization ).

 

2.5 Other challenges of networked Software

Dependability ). One reason for adopting the network architecture is to improve reliability and prevent single point of failure. However, networked applications often require a lot of work to obtain the same reliability as those provided by independent applications.

There are several techniques to improve application dependencies:

1) reactivation ). Applications and services can be run under the control of the monitor daemon. If the server terminates unexpectedly, these daemon will detect and automatically restart the server.

2) replication ). Applications and Services can run under the control of replicamanager on multiple locations over the network. The copy manager can use "active replication" to continuously update service copies, or use "passive replication" when a primary service fails ". The replication framework provides a variety of monitoring, membership, consistency, and messaging mechanisms to help increase application dependencies.

 

Service name and location selection. Independent applications usually identify their components through objects and Function Memory addresses, while networked applications require more elaborate mechanisms to name, locate, and select their remote services.

Distributed Object Computing and RPC middleware provide location brokers, which allow clients to access services through higher-level naming rather than through their lower-layer IP addresses and TCP port numbers. Location proxies simplify network system management by automating the following tasks and provide a more flexible and dynamic service layout throughout the network:

1) name binding. This task binds the service name to the current host/process location.

2) service positioning. Services or resources can often run on multiple locations of the entire network through replication to improve reliability. In this case, the application can use a location proxy to determine which service provider is more suitable.

Related Article

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.