Chapter 2 Process Model Flashcards
The process model
Conceptually, each process has its own virtual CPU. In reality, of course, each real CPU switches back and forth from process to process,
Uses multi-programming to switch very quickly between processes.
There is only one physical program counter, so virtual ones are loaded in memory.
Blueprint for a process
A program
A process is an activity that is actively being run.
It has:
- Program
- Input
- Output
- State
only 1 parent, but n children
Which 4 events cause a process to be created?
- System initialization
- A running process makes a system call
- A user requests a new process
- Initiation of a batch job
In UNIX, there is only one system call to create a new process: ____. This call creates an exact clone of the calling process. After the ____, the two processes, the parent and the child, have the same memory image, the same environment strings, and the same open files. That is all there is. Usually, the child process then executes execve or a similar system call to change its memory image and run a new program.
fork
How can a process terminate? (2 voluntary, 2 involuntary)
- Normal exit (voluntary)
- Error exit (voluntary)
- Fatal error (involuntary)
- Killed by another process (involuntary)
What are the 3 process states?
Blocked - because the process can’t continue because it’s waiting on something else
Running - Using CPU now
Ready - run-able but temporarily stopped to let another process run
The lowest layer of a process-structure OS. It handles interrupts and scheduling. Above that layer are sequential processes.
OS Scheduler
____ _____ has one entry per process (array)
Entries are called Process Control Blocks
- Process state
- program counter
- stack pointer
- memory allocation
- status of open files
- accounting and scheduling info
This saves the state of the process whenever the state is changed so it can be restarted later if it is stopped
Process Table
This is an example of a ____ ___ ___
Process management
- registers
- program counter
- stack pointer
- process id
- CPU time used
Memory management
- pointer to text segment info
- pointer to data segment info
- pointer to stack segment info
File management
- root directory
- working directory
- file descriptors
- user/group ID
Processes table entry
____ _____ (fixed location at bottom of memory). It contains the address of the ISR (interrupt service routine).
An ______ _____ isthe memory location of an interrupt handler, which prioritizes interrupts and saves them in a queue if more than one interrupt is waiting to be handled.
Interrupt vector
What happens when a program is interrupted?
its registers are pushed onto the current stack
What happens to processes during an interrupt?
- save registers in the process table entry
- after the interrupt, the process returns to the exact state it was before
very similar to processes, but they share an address space (and global variables). It’s a mini-process that shares data. Thread creation is 10-100 times faster than process creation.
Threads
They give almost no performance gain when all of them are CPU bound. They’re helpful when there is I/O that will block so other activities can continue. They are ALSO useful with multiple CPUs because real parallelism is possible.
What does a web server use to manage a pool of worker threads?
dispatcher thread
Note that threads can access the shared cache. These types of threads run in the user space because they are part of the application not the OS.