The path of Architecture learning (I.)--Concurrent programming

Source: Internet
Author: User

Have to have a hand in the work, also need to look at the lost period of the big guy's learning route, he can have ascension.
This article link: http://342104628.iteye.com/blog/2422044

Key Concepts

Context Switches

1. Concept: The CPU passes the time slice algorithm, assigns the running time to the running thread, the switch between different threads need to save the state of the current thread and reply to the thread state information that will be executed, this process is the context switch.

2. How can I reduce or avoid context switching?

• Lock-free concurrent programming
· CAS algorithm
• Use minimal threads
• Co-process

Dead lock

1. Concept: Two or more threads hold each other's waiting lock

2. How do I avoid deadlocks?

• Prevent one thread from acquiring multiple locks at the same time
• Prevent a thread from consuming multiple resources within a lock, and try to ensure that each lock occupies only one resource
• Try to use a timed lock
• For database locks, lock and unlock must be in a database connection

Go concurrency mechanism
https://i6448038.github.io/2017/12/04/golang-concurrency-principle/

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.