python interview had to know the point --GIL

# Baidu search: python interview had to know the point --GIL 
# Taken: https: //blog.csdn.net/weixin_41594007/article/details/79485847


# Fully multi-threaded and does not call the two the CPU
# multiple processes are completely two call the CPU


# GIL Global Interpreter Lock (global interpreter lock), each thread needs to get GIL in execution time, guarantee the same time only a thread can execute code that only one thread at a time using the CPU, meaning that once the multi-threaded execution is not the true sense of
time # Guido van Rossum (Guido van Rossum) create python will only take into account the single-core the CPU
# GIL is a super lock. cpython when resolving multiple threads, at GIL lock, to ensure that only one thread holding the lock.
# Because cpython resolved only allowed to have a global parser GIL lock in order to run the program, thus ensuring the same time allowing only one thread can use the CPU


# So, we changed GIL lock how to solve problems?
# 1. Replace cpython is jpython (not recommended)
# 2. Use the multi-process multi-threaded task completion
# 3. Use of multiple threads can use c language to achieve
#
# The following is a problem encountered several interviews:
#
# question 1: when the lock is released Gil
# a:
# 1 encountered such a situation would result in the case of idle time cpu idle Gil releases like i / o operations
# 2 will have a specialized ticks are counted once the ticks value reaches 100 this time the competition began between the release of Gil Gil lock lock thread
# (Description: ticks this value can be set to extend or reduce the time to get Gil thread lock using the cpu)


Guess you like

Origin www.cnblogs.com/LiuYanYGZ/p/12219795.html
GIL