Chapter 3: processes Flashcards
What is a process
a program in execution; process execution must progress in sequential fashion
the 5 sections of process:
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 containing memory dynamically allocated during run time
Program vs Process
Program is passive entity stored on disk (executable file), process is active
Program becomes process when executable file loaded into memory
5 states of a process
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
What is a process control block?
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- priorities, scheduling queue pointers
Memory-management information – memory allocated to the process
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
What is the process scheduler?
Maintains scheduling queues of processes
Job queue – set of all processes in the system
Ready queue – set of all processes residing in main memory, ready and waiting to execute
Device queues – set of processes waiting for an I/O device
Processes migrate among the various queues
What is a context switch
When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch
Context of a process represented in the PCB
process termination (zombie vs orphjan)
The parent process may wait for termination of a child process by using the wait()system call. The call returns status information and the pid of the terminated process
pid = wait(&status);
If no parent waiting (did not invoke wait()) process is a zombie
If parent terminated without invoking wait , process is an orphan
What are the two models of interprocess communication
Share memory
Message passing
What are the advantages of process cooperation
Advantages of process cooperation
Information sharing
Computation speed-up
Modularity
Convenience
Producer consumer problem, and buffer
Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process
unbounded-buffer places no practical limit on the size of the buffer
bounded-buffer assumes that there is a fixed buffer size
Types of communication links between processes
Physical:
Shared memory
Hardware bus
Network
Logical:
Direct or indirect
Synchronous or asynchronous
Automatic or explicit buffering
Direct vs indrect communication:
Send a message to process P vs send to a mailbox.`