Process Review (week 2) Flashcards
process
running program
remember: the program itself just sits there (data, instructions, etc). it is the OS that gets it up and running into something useful, a process
how does OS provide the illusion of many CPUs?
by virtualizing the CPU.
by running one process, then stopping and running another, and so forth, the OS can promote the illusion that many virtual CPUs exist when in fact there is only 1 (or a few). this is called time-sharing.
cost: slower performance
what is the counterpart to time sharing?
space sharing. where a resource is divided; e.g., disk space is naturally a space shared resource
what is address space?
the memory that the process can address
what are the most important registers in a process?
program counter (PC): instruction pointer or IP, tells us which instruction of the program will execute next
stack pointer & frame pointer: used to manage the stack for function parameters, local variables and return addresses
what might I/O information contain?
programs often access persistent storage devices. this i/o information might include a list of the files the process currently has open.
What are some of the common process API’s that are available on any modern OS?
- create a process
- destroy: many processes exist on their on when complete, but this is useful when you have a runaway process
- wait: it can be useful to wait for a process to stop running
- misc. control: for e.g.: suspend a process and then resume
- status: get the status of a process
Use this image to explain process vs. program
Program is useless
Becomes a process when it is loaded from disk into memory by the OS and “runs”
briefly describe process creation.
- the OS loads process code (program) and any static data (e.g. initialized variables) into memory and address space of the process
- -> programs start out on disk or sometimes on flash-based SSDs in some kind of executable format
- -> modern OSes perform the process lazily, by loading pieces of code or data only as they are needed during program execution (paging and swapping policies!) - once the OS loads the bits from disk to memory, some memory must be allocated for the program’s run-time stack. the OS allocates this memory and gives it to the process. the OS will also likely initialize the stack with arguments – fill in the parameters to the main() function, i.e., argc and the argv array
- the OS will probs allocate some memory for the program’s heap / dynamically allocated data; malloc() and free(). heap is needed for data structures. heap is small at first; as the program runs, and requests more memory via malloc() librabry API, the OS may get involved and allocate more memory to the process to help satisfy such calls
- other initialization tasks (like file descriptors for standard input, output, and error)
- now, the OS has set the stage for program execution. last, stats the program running at the entry point, main(). by jumping to the main() routine the OS transfers control of the CPU to the newly-created process. thus program begins execution
what are the three states a process can be in?
ready
running
blocked
Describe some things the OS needs to keep track of.
process list: for all processes that are ready and some additional info to track which process is currently running
note: the OS must also track blocked processes; when an I/O event completes, the OS should make sure to wake the correct process and ready it to run again
what is the zombie state?
in UNIX – when a process has finished but has not been cleaned up yet
process control block
structure that contains information about a specific process