Could not understant the meaning of thread and Global interpreter lock, and also if due to GIL only one thread can execute in our core then how does it support parrallel programming?
Regarding threading
Hello @i.m.anand_31, okay first of all taking the difference between the process and the thread.
Suppose you want to search a query on the internet.
You will open the browser in your system and then search for the query. (Opening the browser is the process.)
And now you want to search one more thing and now you open the one more window of the browser and then search for the query. (In this case, you have 2 opened processes)
But suppose, instead of opening the separate browser you just open the new tab in the first one and then search for the query on that. (So, in that case, the opened browser is your process and then the process has two children,i.e., two tabs and these are known as the threads)
And by cores, we can say that they are the threads and as shown by the sir his computer has 4 core cpu. And parallel programming we can say in terms of different processes but in case of c-python it is limited to only single thread not with all of them.
Now taking an example,
Suppose you are using a website and it is asking for some permission then it is just limited to that thread and it won’t span across different processes.
And now, some accessibility or some extension you want to apply for your browser so that will span across all the threads.
@i.m.anand_31, I know this is little bit confusing and hard to understand but it will take some time to understand it more clearly as you progress ahead.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
The processes and threads are independent sequences of execution, the typical difference is that threads run in a shared memory space, while processes run in separate memory spaces.
-
A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space.
-
Threads exist within a process — every process has at least one. Threads share the process’s resources, including memory and open files. This makes for efficient, but potentially problematic, communication.
An example keeping the average person in mind:
On your computer, open Microsoft Word and a web browser. We call these two processes.
In Microsoft Word, you type something and it gets automatically saved. Now, you have observed editing and saving happens in parallel - editing on one thread and saving on the other thread.