Program vs Process
What is a program and process?
A process refers to a program that is currently in execution. To illustrate, consider a .cpp file, which is a source code file written in C++. This file must be compiled into machine language by a compiler, resulting in an executable file. The executable file contains the code in a format that the computer can directly execute, making it a program. The source code file (.cpp) itself is not a program because it needs to be compiled first. Once compiled, the executable file is what gets stored on disk and is used to create a process when it is run. OS is responsible for converting a program into a process. When you click on the TikTok app icon on your phone, it starts as a program residing on the disk. Clicking on it prompts the operating system to convert this program into a running process.
- What Happens: The operating system (OS) loads the program from the storage (like a hard disk) into the main memory (RAM).
- What Happens: The OS allocates memory for the process, including different regions like the stack and heap.
- Stack: Allocates memory for the stack, which is used to manage function calls, local variables, and the execution flow.
- Heap: Allocates memory for the heap, which is used for dynamic memory allocation (where the process can request, and release memory as needed during execution).



Well written
ReplyDelete