• process (תהליך) - an executing instance of a program, with its own memory space.
  • child process (CP): processes created by another (parent) process.
  • thread (תהליכון): the smallest unit of execution within a process.
    • kernel threads
    • user thread
      • done by a user-space library
      • the kernel knows nothing about the threads
  • multithreading (ריבוי תהליכונים): A CPU feature that enables the processor to maintain the state of multiple threads and rapidly alternate between them on a nanosecond scale.
    • This mechanism improves the utilization of execution units during stalls (such as memory latency), but it does not provide genuine parallelism, as only one thread is actively executing at any given moment.
  • process vs. thread: (by (Tanenbaum, 2022))

    • shared data:
      • per-process items
        • address space
        • global variables
        • open files
        • child processes
        • pending alarms
        • signals and signal handlers
        • accounting information
      • per-thread items
        • program counter
        • registers
        • stack
        • state
    • pros of thread over process:
      • lightweight
      • faster context switching
      • faster creation and termination
  • process termination: (by (Tanenbaum, 2022))

    • normal exit (voluntary)
    • error exit (voluntary)
    • fatal error (involuntary)
    • killed by another process (involuntary)
  • process creation: (by (Tanenbaum, 2022))

    • system initialization
    • execution of a process-creation system call by a running process
    • a user request to create a new process
    • initiation of a batch job
  • process state: 180

    • created (or new)
    • running (or waiting)
    • ready
    • blocked
    • terminated
    • swapped out and waiting (or suspended and waiting)
    • swapped out and blocked (or suspended and blocked)
  • context switch

    • ”The switching of the CPU from one process or thread to another; requires performing a state save of the current process or thread and a state restore of the other.” (Galvin, 2018)
  • the process table

    • data structure used by the OS to manage processes.
    • an array of structures
    • one entry per process
  • process control block (PCB) (also task control block, process descriptor, and task descriptor)

    • “Data needed by the OS to control the process” (Stallings, 2018)
    • “A per-process kernel data structure containing many pieces of information associated with the process.” (Galvin, 2018)
    • Each process is represented in the OS by a PCB
    • typically includes:
      • process state
      • process ID
      • program counter
      • stack pointer
      • CPU registers
      • memory-management information
        • value of the base and limit registers
        • page tables (or segment tables)
      • memory allocation
      • accounting information
        • amount of CPU and real time used
        • time limits
        • account numbers
        • job or process numbers
      • the status of its open files
      • scheduling information
        • process priority
        • pointers to scheduling queues
      • I/O status information
        • list of I/O devices allocated to the process
        • list of open files
  • timesharing (חלוקת זמן): CPU time is divided among multiple users or processes.

  • batch system (מערכת אצווה): executes jobs in batches with minimal user interaction.

  • multiprogramming (ריבוי תוכניות): multiple programs reside in memory to improve CPU utilization.

  • kernel (גרעין): the core part of the OS managing resources and hardware.

  • kernel mode (מצב ראשוני): CPU mode with full access to hardware and memory.

  • user mode (מצב משתמש): restricted CPU mode for running user applications.

  • system call

    • ”the programmatic way in which a computer program requests a service from the operating system on which it is executed” (Wikipedia)
    • “Software-triggered interrupt allowing a process to request a kernel service” (Galvin, 2018)
    • “The primary interface between processes and the operating system, providing a means to invoke services made available by the operating system” (Galvin, 2018)
  • UID (user identification): numeric ID assigned to a user for permission control.

  • GID (group identification): numeric ID assigned to a group of users.

  • address space: the memory range a process can access.

  • command interpreter: program that reads and executes user commands (e.g., shell).

  • core image: memory snapshot of a process, including code and data.

  • file descriptor: integer handle used to access open files in a process.

  • virtual memory

Interrupts

  • interrupt (פסיקה)
  • An interrupt request (or IRQ) is a signal to the CPU to stop and handle an event.
    • are the interrupt numbers
    • hardware interrupts generated by hardware devices external to the CPU
    • software interrupt is a software-generated interrupt.
      • It can be caused by: error, system call instruction,
      • (“Most Unix systems and derivatives do not use software interrupts, with the exception of interrupt 0x80, used to make system calls back in pre mid-2000s days” (Wikipedia))
    • (e.g. in x86, 0–31 are CPU exceptions, 32-47 hardware interrupts and 48–255 software interrupts)
  • interrupt vector table (IVT) is a list of interrupt vectors, where the th interrupt vector is an address points to the th ISR.
  • interrupt handler, aka interrupt service routine (ISR),
  • The term trap may refer to:
    • any interrupt
    • any software interrupt
    • an instruction (e.g. int 0x80 or SYSCALL in x86) that causes to switch from user mode to kernel mode to handle a system call or exception.

Linux

  • The kernel and user use the term PID differently:

    • (kernel view) Each thread has its own ID called PID (sometime called thread ID (TID)).
    • (user view) PID of process refers to the TGID
  • A thread group is a collecation of threads sharing the same thread group ID (TGID)

    • The first thread in a procces is called the thread group leader, and it has TGID the same as its (kernel) PID. The other thread will have TGID the same as the TGID of the thread group leader.
    • the TGID is the same as the PID of the procces of the theards.
    • each thread has its own struct task_struct *task.
    • each thread has its own (kernel) PID (=TID).
      • (kernel) pid_t task->pid.
      • (user) syscall(SYS_gettid).
    • all threads have the same TGID.
      • (kernel) pid_t task->tgid
      • (user) getpid().
    • all threads have the same PPID. (using pid_t getppid())
  • A process group is a set of one or more processes sharing the same process group ID (PGID, pgid), (which is a number of type pid_t).

    • a process group groups processes (not threads)
    • a process group has a process group leader, which is the process that creates the group and whose PID becomes the PGID of the group.
      • A new process inherits its parent’s process group ID.

job control

  • A session is a collection of process groups (jobs)
    • All of the processes in a session have the same session identifier.
    • A session leader is the process that created the session, and its process ID becomes the session ID.

References

  • Tanenbaum, Andrew S. (2022). Modern Operating Systems. Pearson.
  • Galvin, Abraham Silberschatz; Greg Gagne; Peter B. (2018). Operating System Concepts. Wiley Global Education US.
  • Stallings, William (2018). Operating Systems: Internals and Design Principles, Global Edition. Pearson Education Limited.