Process in Layman’s terms
Hemal Shah explained these. I did a more formal rigorous study through SE350.
You should now look into Thread.
Process vs. Thread?
Processes are what actually execute the program. Each process is able to run concurrent subtasks called threads.
- Threads are sub-tasks of processes and if synchronized correctly can give the illusion that your application is performing everything at once. Without threads you would have to write one program per task, run them as processes and synchronize them through the operating system.
Also see Multithreading.
Each program has a main thread. If you don’t program multithreading into a program, when it launches as a process, it will always run on a single thread.
Processes vs. Threads
As explained by Hemal Shah…
- Processes can be on multiple threads
- A thread cannot own multiple processes. A thread is owned by a process
A process is just a program is being executed from a binary file (a sequence of 0s and 1s). All operating systems have their own binaries that they can execute (window is .exe
, Apple is .dmg
, etc)
- At the lowest level, there is code and data. In Von Neumann architecture you have the saying that Code is data. Remember what you learned for MIPS, like an
add
operation. Theadd
is the code, and the data is the two registers that you want to add together - So at the lowest level, that is all there is to a binary being executed.
Now, how this relates to threads? Well, each software thread is just a process running from a binary.
But Hemal also talked about how a single process can run on multiple threads.
- So if you have two processes that run multithreading, it might actually slow both programs down
- The OS can take care of doing some optimization to finish the multithreaded job faster if possible
- this page is good https://www.geeksforgeeks.org/thread-in-operating-system/
More Context
So threads share CPU time. The technique is called Context Switching.
Also, the main memory is just RAM.