Process

  • A process is more than just program code; it includes current activity, program counter value, processor register contents, process stack, data section, and optionally, a heap.
  • A program is passive (stored instructions on disk), while a process is active (loaded into memory).
  • Processes can serve as execution environments for other code, like the Java Virtual Machine (JVM).

Process State:

  • As a process executes, it transitions through various states.
    Process states include:
    • New: The process is being created.
    • Running: Instructions are being executed.
    • Waiting: The process is awaiting some event (e.g., I/O completion).
    • Ready: The process is waiting to be assigned to a processor.
    • Terminated: The process has finished execution.

Process states may vary across operating systems, but the underlying states are common.
Only one process can run on a processor at any given time, while multiple processes may be ready and waiting for execution.

Process Control Block (PCB):

  • Each process in the operating system is represented by a Process Control Block (PCB), also known as a Task Control Block.
  • A PCB contains various pieces of information associated with a specific process, including:
  • Process State: Indicates the current state of the process (e.g., new, ready, running, waiting, terminated).
  • Program Counter: Address of the next instruction to be executed for the process.
  • CPU Registers: Includes various registers such as accumulators, index registers, stack pointers, and general-purpose registers, along with any condition-code information.
  • CPU-Scheduling Information: Process priority, pointers to scheduling queues, and other scheduling parameters.
  • Memory-Management Information: Values of base and limit registers, page tables, or segment tables, depending on the memory system used.
  • Accounting Information: CPU and real-time usage, time limits, account numbers, job or process numbers, etc.
  • I/O Status Information: List of I/O devices allocated to the process, list of open files, etc.
  • The PCB serves as a repository for any information that may vary from process to process.

Threads:

  • Traditionally, a process has been viewed as a program executing a single thread of execution, meaning it can perform only one task at a time.
  • For instance, when a word-processor program is running, it executes a single thread of instructions, allowing only one task to be performed at a time.
  • However, most modern operating systems have extended the process concept to support multiple threads of execution within a single process.
  • This enhancement allows a process to perform multiple tasks concurrently, such as typing characters and running a spell checker simultaneously.
  • Multithreading is particularly advantageous on multicore systems, where multiple threads can run in parallel, utilizing the available CPU cores efficiently.
  • In systems that support threads, the Process Control Block (PCB) is expanded to include information for each thread, and other system changes are made to support threading.
Design a site like this with WordPress.com
Get started