Process and Threads

Lecture 3

Process Concept

  • An operating system executes a variety of programs

    • Textbook uses the terms jobs and program used interchangeably

  • Process - a program in execution

    • Process execution proceeds in a sequential fashion

  • A process contains

    • The program code, also called text section

    • Current activity including program counter, processor registers

    • Stack containing temporary data

    • Function parameters, return addresses, local variables

    • Data section containing global variables

    • Heap containg memory dynamically allocated during run time

  • Program is passive entity stored on disk (Execuable file), process is active

    • _Progrem becomes process when executable file loaded into memory__

  • One program -> can be several processes

    Process =? Program

    • More to a process than just a program:

      • I run emacs/Notepad on lectures.txt, you run it on homework.java - Same program, Different processes

    • Less to a process than a program:

      • cc/cpp stars up processes to handle different stages of the compilation process cc1, cc2, and ld

    Process State

    • As a proces executes, it changes state

      • new: The process is being created

      • running: Instructions are being executed

      • waiting: The process is waiting for some event to occur

      • ready: The process is waiting to be assigned to a processor

      • terminated: The process has finished execution

    CleanShot 2021-04-13 at 23.18.45@2x

    Process Control Block (PCB)

    • Information associated with each process (also called task control block)

      • Process state - running, waiting, etc

      • Program counter - location of instruction to next execute

      • CPU registers - contents of all process - centric registers

      • CPU scheduling information -memory allocated to the process, page tables, value of the base, etc

      • Accounting information -CPU used, clock time elapsed since start, time limits

      • I/O status information -I/O devices allocated to process, list of open files

    Data Structures

    • Hash function can create a hash map

      CleanShot 2021-04-13 at 23.26.18@2x

      • Bitmap - string of n binary digits representing the status of n items

      • Linux data structures defined in include files:

        • Linux/list.h

        • Linux/kfifo.h

        • Linux/rbtree.h

      Process Scheduling Queues

      • Job Queue - set of all processes in the system

      • Ready Queue - set of all processes residing in main memory, ready and wating to execute

      • Device Queue - set of proceses waiting for an I/O device

      • Process migration between the various queues

      • Queue Structures - typically linked list, circular list, etc.

      CleanShot 2021-04-13 at 23.30.17@2x

Last updated

Was this helpful?