Learn

When a process is initialized, its layout within memory has four distinct sections:

  • A text section for the compiled code
  • A data section for initialized variables
  • A stack for local variables defined within functions
  • A heap for dynamic memory allocation

Processes are also initialized with a Process Control Block that is required by the operating system for managing the process. This contains:

  • A unique process ID and the ID of any parent processes that launched the current one
  • The current process state
  • How long the process has been running and any time limits the process may have
  • Allowed system resources and other permissions
  • The priority of the process
  • The program counter for the address of the instruction currently being executed
  • The address of other registers within the CPU holding intermediate values
  • Information required for memory management such as page and segment tables

Additionally, when one process launches another, the original enters a parent-child relationship with the newly-launched process that shares much of the above data. For example, when an existing music player process starts a new process for scanning the user’s music library, both of these processes generally share the same system resources and permissions. Parent processes usually also wait for their children to complete before terminating themselves, unless the child was created specifically to run independently in the background.

Instructions

What other information may be useful to store on the Process Control Block?

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?