Featured image of post Os

Os

Chapter 3 | Processes

Process Concept

  • Defination: a program in execution

  • Program code = text section(the code was treat as text before compilation)

  • Program counter: indicates the next instruction to execute

  • Stack: contains temporary data (e.g. function parameters, return addresses, local variables)

  • Data section: contains global variables

  • Heap: dynamically allocated memory during runtime

The heap concept in data structures is different from the heap in memory management. The former is a specific data structure, while the latter refers to a region of memory used for dynamic allocation.

  • Program is passive, process is active

Memory Layout of a Process

  graph TD
    subgraph Memory_Layout [Process Memory Layout]
        direction TB
        High["High Address"]
        Stack["Stack (Function calls, local variables)"]
        Gap[" "]
        Heap["Heap (Dynamic memory allocation)"]
        Data["Data Section (Global & Static variables)"]
        Text["Text Section (Program code)"]
        Low["Low Address"]

        High --- Stack
        Stack -- "grows down" --> Gap
        Gap -- "grows up" --- Heap
        Heap --- Data
        Data --- Text
        Text --- Low
    end

Process State

As a process executes, it changes state. The lifecycle of a process can be visualized through the following state diagram:

  stateDiagram-v2
    [*] --> New
    New --> Ready: Admitted
    Ready --> Running: Scheduler dispatch
    Running --> Ready: Interrupt
    Running --> Waiting: I/O or event wait
    Waiting --> Ready: I/O or event completion
    Running --> Terminated: Exit
    Terminated --> [*]

The Five States

  • New: The process is being created.
  • Running: Instructions are being executed.
  • Waiting: The process is waiting for some event to occur (such as I/O completion or reception of a signal).
  • Ready: The process is waiting to be assigned to a processor.
  • Terminated: The process has finished execution.

Process Control Block (PCB)

Threads

Process Scheduling

Context Switch

Process operations

Multitasking in Mobile Systems

Multiprocess Architecture – Chrome Browser

A winner is just a loser who tried one more time.
Robust AI
使用 Hugo 构建
主题 StackJimmy 设计