The concept of synchronous Asynchronization (ajax is asynchronous, C # is synchronous ),
Process Synchronization is used to achieve reproducibility During Concurrent execution of programs. 1. Concepts of Process Synchronization and Asynchronization 1. Process Synchronization: When a function call is sent, the call will not be returned until the result is obtained. That is to say, you must do one thing and wait until the previous one is finished before you can do the next thing. just like after getting up in the morning, you can wash your hair first before you can eat. You can't start to eat when the shampoo is not complete. according to this definition, most functions are called synchronously (such as sin and isdigit ). But in general, when we talk about synchronization and Asynchronization, we are referring to the tasks that require the collaboration of other components or a certain amount of time. The most common example is sendmessage. This function sends a message to a window. This function does not return a message before the recipient finishes processing the message. After the other party completes processing, the function returns the lresult value returned by the message processing function to the caller. 2. Concepts of asynchronous and asynchronous synchronization. When an asynchronous process is called, the caller cannot obtain the result immediately. After the call is completed, the caller is notified by status, notification, and callback. Take the casycsocket class as an example (note that csocket is derived from casyncsocket, but its function has been converted from Asynchronous to synchronous). When a client sends a connection request by calling the connect function, the caller's thread can run down immediately. After the connection is established, the socket underlying layer sends a message to notify the object. The Execution Component and caller can return results in three ways: Status, notification, and callback. Which one can be used depends on the implementation of the execution part, unless the execution part provides multiple options, it is not controlled by the caller. If the execution part is notified by the status, the caller needs to check the status at intervals, which is very inefficient. (Some new programmers prefer to use a loop to check the value of a variable, this is actually a very serious error ). If you use the notification method, the efficiency is very high, because the execution of components almost do not need to do additional operations. As for the callback function, there is actually no much difference with the notification. The basic concept of Process Synchronization is that in computer systems, resource competition and sharing among processes are caused by limited resources. Therefore, concurrent execution of processes is not only the random execution start time of user programs, but also the result of improving resource utilization, it is also caused by resource competition and sharing, which restricts the execution process of the process. So what are the restrictions in the concurrent execution of processes? II. synchronous and asynchronous transmission: 1. asynchronous transmission is generally a unit of character transmission. Each character must be appended with a one-bit start bit and one-bit stop bit to mark the start and end of a character, in this way, data transmission is synchronized. Asynchronous transmission means that the time interval between characters and characters (from the end of a character to the start of the next character) is variable, and there is no need to strictly limit their time relationship. The Start bit corresponds to the binary value 0, which is expressed as low and occupies 1 bit of width. The stop bit corresponds to binary value 1, which is expressed in a high level and occupies 1 ~ 2-bit width. One character occupies 5 ~ 8-bit, depending on the character set used by the data. For example, the telegraph code is five characters, the ASCII code is seven characters, and the Chinese character code is eight characters. In addition, a one-bit parity bit is added. You can select the odd parity or even parity mode to implement simple error control for this character. In addition to using the same data format (number of characters, number of Stop bits, whether there is a check bits, and the verification method), the sender and receiver should also adopt the same transmission rate. Typical rates include 9 600 B/s, 19.2kb/s, and 56kb/s. Asynchronous transmission is also called the start-stop asynchronous communication mode. It has the advantages of simplicity and reliability and is suitable for character-oriented, low-speed Asynchronous Communication. For example, the communication between a computer and a Modem is in this way. Its disadvantage is that the communication overhead is high. An additional 2 ~ 3-bit, low communication efficiency. For example, when Modem is used to access the Internet, it is generally found that the speed is slow. In addition to the low transmission rate, it is also closely related to high communication overhead and low communication efficiency. 2. For synchronous transmission, data blocks are used as transmission units. A special character or bit sequence must be appended to the header and tail of each data block to mark the start and end of a data block, generally, a verification sequence (such as a 16-bit or 32-bit CRC verification code) is appended to control data block errors. The so-called synchronous transmission means that the interval between data blocks and data blocks is fixed and their time relationship must be strictly specified. 3. synchronous blocking and asynchronous blocking: Synchronous is the blocking mode, while Asynchronous is the non-blocking mode. In my understanding, synchronization is related to the running of two threads, one of which is blocked and waiting for the running of another thread. Asynchronous means that two threads are unrelated and run their own. Synchronization refers to the communication mode in which the sender sends a packet only after the receiver sends a response. Asynchronous means that the sender sends the next packet instead of sending the response from the receiver. For example, SendMessage (...) TRACE0 ("just like send"); PostMessage (...) TRACE0 ("just like WSASend using overlapped"); SendMessage does not return a message when it is called. TRACE0 is executed only after the message is returned. This is synchronization. postMessage is returned immediately after the call, and TRACE0 is executed without message response. This is asynchronous. 4. other explanations: differences between synchronous and asynchronous: Normal B/S mode (synchronous) AJAX technology (asynchronous) Synchronization: when a request is submitted, wait for the server to process it, and then return the result, the client browser cannot do anything asynchronously: the request is triggered by an event.> server processing (this is the case that the browser can still do other things) -> after the synchronization is completed, you ask me to go to dinner. When I hear it, I will go to dinner with you. If I don't hear it, you will keep calling until I tell you to hear it, to eat together. Asynchronous mode means that you call me and then eat on your own. After receiving the message, I may leave immediately or wait until I get off work. Therefore, if I want to invite you to dinner, I will use the synchronous method. If I want to invite you to dinner, I will use the asynchronous method, so that you can save money. For example, synchronous message sending during a call is asynchronous.