chapter 4: the abstraction: the Process Flashcards
what is a process?
a running program
what is Time Sharing and Space Sharing?
sharing time and space between programs (only one or a few CPU and only one big address space
what are the steps an OS has to do to run a program?
- load its code and static data into memory, the address space of the process
- programs initially reside on disk, SSDs in some kind of executable format.
- OS reads those bytes from disk and place them in memory somewhere
- memory allocated for the programs runtime stack. (local variables, function parameters, return addresses.
- the OS fill in the parameters to main() and initialze the stack.
- the OS allocate memory for program’s heap. (malloc() , free()). heap will be small at first, OS may get involved and add more memory if needed.
- OS sets up I/O
- start the program main() by jumping to the main() routine. Transfers control of CPU to process
how was loading process done in OS before?
it was loaded EAGERLY, all at once before running the program. now its done LAZILY, only loading it when needed.
Process states
running, ready, blocked
how do the states change from one another
running to ready: descheduled
ready to running: scheduled
Blocked to ready: I/O done
running to blocked: I/O initiate
data structures of a process
the OS keeps a process list: to track states of all processes
each process has a PCB: contains information of a process (stack pointer, PID, process state, parent process etc)