Processes and Threads, Mutex, Thread Synchronization
Sometimes people confuse those concepts so I decided to write about them in order to make it clear to you.
What is a Process?
A process is an OS-provided abstraction of a running program. When you write a program, it is nothing more than a lifeless file on the hard drive. When you run it, the operating system creates a process out of it.
So, a process is a type of program that executes. This implies that if you open two browser windows, even though they are both executing the same program, you will have two processes.
What is a Thread?
Within a process, a thread is the unit of execution. It’s also known as the “lightweight” method. The address space for all threads in a single process is the same. It means they’re sharing memory machine states, which means they’re not protected from each other.
A process can be partitioned into many threads of operation in modern operating systems. Except for information directly linked to execution, all process management information is shared among threads inside a process.
What is Multithreading?
Multithreading is the execution of several threads in the same or different processes.