ππππ«ππ¬π¬ ππ©πππ: Every process running on our systems has memory allocated for its address space. Which includes:
|| ππ΅π’π€π¬ β ππ’π± β ππ¦π’π± β ππ’π΅π’ β ππ¦πΉπ΅||
β’ Stack: Contains function calls, return addresses, local variables etc.
β’ Gap: That's just the empty space kept for the dynamic memory to grow.
β’ Heap: Used for dynamic memory allocation like malloc(), calloc().
β’ Data: For const, global and static variables.
β’ Text: The program code or program instructions. (Usually read-only)
-These address spaces are separate for each process and they cannot access each others. OS manages the whole thing, if something wrong happens OS throws Segmentation Fault.
-Address space is virtual. Which is mapped to physical memory by OS.
πππ: In simple words, a Process Control Block is a data structure used by OS to manage processes. Itβs like an ID Card for processes.
Which includes:
β’ Process ID (PID): Unique id for the process.
β’ Process State: New, Ready, Running, Waiting, Terminated these are the states.
β’ CPU Registers: Program Counter(PC) and other registers.
β’ Scheduling Information: Priority and queue position.
β’ Memory Information: Pointers to address space and memory limits.
β’ I/O Status Information: Open files, devices used.
-PCB is stored inside the Kernel Space inside the process table.
-OS uses PCB to manage processes, perform context switching and track process execution
Simple analogy is PCB contains everything the OS needs to identify and manage a process.
Top comments (0)