Notes 3
Notes 3
Process Management
• A process needs resources (CPU, memory, files…) to do a task
• These resources are either given to the process when it is created, or allocated to it while it is running
• A program is a passive entity
• A process is an active entity, with a program counter giving the next instruction to execute
• The execution of a process must be sequential
• Process termination requires reclaim of any reusable resources
• Single-threaded process has one program counter specifying location of next instruction to execute
• Process executes instructions sequentially, one at a time, until completion
• Multi-threaded process has one program counter per thread specifying location of next instruction to
execute in each thread
• Typically system has many processes, some user, some operating system (kernel) running concurrently on
one or more CPUs
• Concurrency by multiplexing the CPUs among the processes / threads
• Processes can execute concurrently by multiplexing the CPU
• In connection with process management, the OS is responsible for
• Scheduling processes and threads on the CPUs
• Creating and deleting both user & system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
• Providing mechanisms for deadlock handling
Process Concepts
• An operating system executes a variety of programs:
• Batch system –jobs
• Time-shared systems –user programs or tasks
• Textbook uses the terms job and process almost interchangeably
The Process
• Process = an active entity, with a program counter (to indicate the current activity), process stack (with
temporary data), and a data section (with global variables)
• Text section = the program code
• If you run many copies of a program, each is a separate process (The text sections are equivalent, but the
data sections vary)
• Process–a program in execution; process execution must progress in sequential fashion
• A process includes:
• program counter
• stack
• data section
• A process in memory
Process State
• Each process may be in one of the following states:
• New (Process is being created)
• Running (Instructions are being executed)
• Waiting (Process is waiting for an event, e.g. I/O)
• Ready (Process is waiting to be assigned to a processor)
• Terminated (Process has finished execution)
• Only one process can be running on any processor at any instant
Process Control Block
Threads
• Many OS's allow processes to perform more than one task at a time