Quiz 2 Flashcards
What is the difference between a program and a process?
A process is simply a program that is currently in execution.
What are the different components of a process?
The program code, or the 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.
What are the process states?
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 process scheduling/scheduler?
Maximizes CPU use, quickly switches processes onto CPU core. Process scheduler selects among available processes for next execution on CPU core. Maintains scheduling queues of processes.
What are ready and wait queues?
Ready queue - Set of all processes residing in main memory, ready and waiting to execute
Wait queues - Set of processes waiting for an event (i.e. I/O)
What is a context switch?
When a 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.
What is the PCB?
A context of a process is represented in the Program Control Block or PCB.
How is time related to context switching?
Context-switch time is overhead, the system does no useful work while switching. The more complex the OS and the PCB the longer the context switch. Some hardware provides multiple sets of registers per CPU meaning multiple contexts loaded at once.
What does process creation mean?
A parent process creates child processes, which in turn create other processes, forming a tree of processes.
Generally process identified and managed via a process identifier (pid)
When a parent creates a new child process what are the possibilities in terms of execution and address space for the new process.
Resource Sharing:
- Parent and child share all resources
- Children share subset of parent’s resources
- Parent and child share no resources.
Execution options
- Parent and child execute concurrently
- Parent waits until children terminate.
What are some unix commands associated with process creation?
fork() - Creates a new process
exec() - System call used after fork() to replace the process’ memory space with a new program.
exit() - Terminates a child process
wait() - Parent processes will wait for the child to terminate.
What does process termination mean?
Process executes last statement and then asks the operating system to delete it using the exit() system cal.
- Returns status data from child to parent (via wait())
- Process’ resources are deallocated by operating system.
How does a parent terminate a child process? Why would this be done?
A parent may terminate the execution of children processes using the abort() system call. Some reasons for doing so:
- The child has exceeded allocated resources
- Task assigned to child is no longer required
- The parent is exiting and the operating system does not allow a child to continue if its parent terminates.
What is cascading termination?
Some operating systems do not let a child exist if its parent has terminated. Therefore when a process terminates all its children must also be terminated. Cascading termination refers to the process of all children, grandchildren etc. processes of a process being terminated.
What are the two types of processes within a system?
Independent - Process cannot affect or be affected by the execution of another process
Cooperating - Process can affect or be affected by the execution of another process
What are some reasons for using cooperating processes?
- Information sharing
- Computation speedup
- Modularity
- Convenience