Concept of Process

Cards (28)

  • Process
    A program in execution. The unit of work in most systems.
  • Process
    • Needs resources like CPU time, memory, files and I/O devices to accomplish its task
    • Resources are typically allocated to the process while it is executing
  • Modern operating systems
    • Support processes having multiple threads of control
    • On systems with multiple hardware processing cores, these threads can run in parallel
  • Program counter
    Specifies the next instruction to execute
  • Memory layout of a process
    • Text section: executable code
    • Data section: global variables
    • Heap section: dynamically allocated during program run time
    • Stack section: temporary data storage when invoking functions
  • Program
    A passive entity, such as a file containing a list of instructions stored on disk
  • Process
    An active entity, with a program counter specifying the next instruction to execute and a set of associated resources
  • A program becomes a process when an executable file is loaded into memory
  • Process states
    • New
    • Running
    • Waiting
    • Ready
    • Terminated
  • Process Control Block (PCB)
    Represents a process in the operating system and serves as the repository for all the data needed to start, or restart, a process, along with some accounting
  • Contents of the PCB
    • Process state
    • Program counter
    • CPU registers
    • CPU-scheduling information
    • Memory-management information
    • Accounting information
    • I/O status information
  • Thread
    Allows a process to have multiple threads of execution and thus to perform more than one task at a time
  • Multiprogramming
    Objective is to have some process running at all times so as to maximize CPU utilization
  • Time sharing
    Objective is to switch CPU core among processes so frequently that users can interact with each program while it is running
  • Process scheduler
    Selects an available process for program to execute on a core
  • A system with a single CPU core can only run one process at a time whereas a multicore system can run multiple processes at one time
  • Degree of multiprogramming
    The number of processes currently in memory
  • Types of processes
    • I/O-bound process
    • CPU-bound process
  • I/O-bound process
    Spends more of its time doing I/O than it spends doing computations
  • CPU-bound process

    Generates I/O requests infrequently, using more of its time doing computations
  • Scheduling queue
    1. When processes enter the system, they are put into a ready queue
    2. When a process is allocated a CPU core, it executes for a while and eventually terminates, is interrupted, or waits for the occurrence of a particular event, such as the completion of an I/O request
    3. Waiting processes are placed in the waiting queue
  • CPU scheduler
    Responsible to select from among the processes that are in the ready queue and allocate a CPU core to one of them
  • Swapping
    An intermediate form of scheduling where a process is removed from memory for active contention of the CPU and later reintroduced into memory, and its execution can be continued where it left off
  • Context switch
    The task of Switching the CPU core to another process by performing a state save of the current process and a state restore of a different process
  • Process creation
    1. During the course of execution, a process may create several new processes
    2. The creating process is called a parent process, and the new processes are called the children of that process
    3. A child process may be able to obtain its resources directly from the operating system, or it may be constrained to a subset of the resources of the parent process
  • Process termination
    1. A process terminates when it finishes executing its final statement and asks the operating system to delete it by using the exit() system call
    2. A parent process may terminate the execution of one of its children
    3. When a process terminates, its resources are deallocated by the operating system
    4. A terminating child process must have its entry in the process table until the parent calls wait()
    5. A process that has terminated, but whose parent has not yet called wait(), is known as a zombie process
    6. A situation where a parent did not invoke wait() but instead terminate, leaves its child processes as orphans process
  • The new process consists of a copy of the address space of the original process when a new process is created by the fork() system call
  • After a fork() system call, one of the two processes typically uses the exec() system call to replace the process's memory space with a new program