What exactly is synchronous and asynchronous???

Source: Internet
Author: User
Tags ticket

In a sense, synchronous asynchrony occurs in the following areas:

1 Computer networks.

There is synchronous communication and asynchronous communication in data communication technology. Synchronous communication The simple thing is that when you send data, I have to accept it at the same time. This process has precise clock control. Asynchronous communication is where you have to add the start and end symbols when you send data, so I can accept that asynchronous communication has no clock control. Because there is no clock control (additional hardware), the cost is low, the device is simple, but the transmission efficiency is low. (The start and Terminator take up the overhead).

The three major components of the network protocol: syntax, semantics, synchronization. Synchronization refers to the order in which events are implemented. such as the establishment of a TCP connection when the three-time handshake implementation sequence.



2 operating system.

One feature of the interrupt system is the ability to respond to asynchronous events. Asynchronous events refer to intermittent, random events with no timing relationships. Synchronization events Conversely, an event is executed from start to finish without interruption.

The relationships between processes are synchronous and mutually exclusive. Synchronization is the coordination of multiple processes to complete a task. For example, the driver and the conductor relations. The driver stopped---the conductor opened----The passenger boarded---the conductor closed---the driver drove. The task in this process is to pull the passengers. The driver and the conductor coordinate their work as two processes. Mutex refers to multiple processes competing for the same resource. At this point the resource is called a critical resource (only one process access is allowed at any time, and three threads can be at the same time a variable ichange minus 1, but at any time only one is allowed to operate, and the train ticket issue is negative if the final ticket is not synchronized. )。

In modern operating system, there are four basic features of concurrency, sharing, virtualization and uncertainty. And the implementation of the program Concurrency activity is asynchronous (a program walk-stop), concurrency control needs to use synchronization technology. (synchronized can be used to implement synchronization control in Java Multi-threading), so concurrency control requires synchronization, concurrent implementations are asynchronous, and too many synchronizations lead to deadlocks. In the concurrency realm there is a classic word that can be serialized concurrently. So what is parallelism? Parallelism is the real concurrency. Concurrency is achieved only on a different time slice.

In the I/O model, there are frequent synchronous and asynchronous, blocking and non-blocking. To understand this problem, you must know the von Neumann architecture and process state model. First understand the I/O in the computer system role.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7B/00/wKioL1bEj_iDTFmeAAAp_E8upCo299.png "title=" von Neumann system. png "alt=" Wkiol1bej_idtfmeaaap_e8upco299.png "/>



An input operation consists of two procedures:

1 wait for the data to be ready.

2 copy data from the kernel to the process.

Synchronous and asynchronous in I/O is a data access mechanism.

Synchronization refers to waiting for I/O after an active request, and reading and writing must be blocked after data is ready.

Asynchronous refers to an unsolicited request that can handle other tasks, such as when I/O is complete and notified.

Blocking refers to the data that the process accesses is not ready and the process must wait.

Non-blocking means that the process access data is not ready and the process does not have to wait.


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7B/01/wKioL1bEk96htG9mAAA2NC8eXoc008.png "title=" Process state. png "alt=" Wkiol1bek96htg9maaa2nc8exoc008.png "/>

The process generally has five states, the creation process, at this time the process in the ready queue waiting for CPU scheduling, when executed on the CPU, this is the running state, the running process may encounter the I/O request at this time into a blocking state, or the process is completed, into the death state. When the required resources are met, the blocking state is transformed into a training state. So repeated.

With the accumulation of basic knowledge above, we now look at common I/O models.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7B/01/wKiom1bEliTja2NiAAAc6I8NF5M473.png "title=" Io1.png "alt=" Wkiom1belitja2niaaac6i8nf5m473.png "/>

For the complete model, refer to "UNIX Network programming Volume 1" P127.

For example: pure concept is really difficult to understand.

If I (a process) go to the Cafeteria for dinner (Task a), go to the library after eating (Task B). can also go to the classroom. (Task C) Wait for the aunt to cook the meal well.

Blocking I/O I was waiting for my aunt to cook. Until you have dinner.

Non-blocking I/O I am waiting for the time, will always ask Aunt Rice, not until dinner.

Synchronous blocking I/O and synchronous non-blocking I/O can cause the process to block. (The task card is not moving at a)

I/O multiplexing involves the Select,poll function, which is not expected because of a lack of depth of understanding.

Signal-driven is when I am waiting, but also waiting for other signals, such as the Aunt winked at me let me eat, until dinner.

asynchronous I/O is when I am waiting, can go to the library can also go to the classroom, after dinner, aunt will ask me to eat. (The selective execution of A,b,c can be performed during the initiation of task A to the end of the notification, without blocking to task a).


Seeing so much, what exactly is synchronous and asynchronous? Must be placed in a specific environment and in the project to understand deeply.

This is what I know of synchronous and asynchronous in the computer, there are many points of view is my own understanding, may not conform to the true meaning, I hope you help me correct. Not very grateful. Personal level is really limited, there is no contribution to synchronous asynchronous code.

This is my first technical blog, I didn't expect to spend 2 hours. Find out what you understand---write it out----say it---speak out to make others understand the level of difficulty is increasing, the writing process is also a carding knowledge system and thinking process. I hope I can keep on blogging.










This article is from my blog blog, so be sure to keep this source http://thinklili.blog.51cto.com/10867130/1742869

What exactly is synchronous and asynchronous???

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.