1/34
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
why processes were invented
for batch jobs (tasks that repeat over and over)
what is a process
a program in execution; process execution must progress in sequential fashion. It is active, where a program is passive
when program moves from secondary memory into main memory (RAM) and the CPU executes it
what is process vs program
program is passive and stored on disk, not memory (executable file)
process is active (executable and has resources)
program TURNS INTO process when an executable is loaded into memory
how does program code move
program code goes from DISK (secondary) to RAM (main memory)
then CPU can access data

how does process work in VIRTUAL memory
-hardware (RAM) allocates specific space for the process
-the image is the allocated space
-text is read only
-data is broken up into initialized and uninitialized
-stack and heap are modified by OS and compiler
-static data goes into stack (grows down), dynamic goes to heap (grows up)

who operates the stack (virtual memory)
the OS

who operates the heap (virtual memory)
the programmer/coder
where do memory leaks happen
in the heap (if programmer forgets to deallocate dynamic memory)

where do variables live in
the stack (variables in main = stack, variables outside of main = live in DATA)

where do dynamic variables live in
the heap

explain the picture
-two global variables
-two local variables (stored in stack)
-note the ERROR → the values line doesn’t verify if the space is available first and causes a memory leak
what is a stack frame
a container (temporary data structure) that organizes functions
what does a stack frame have
return address (location after function ends)
function parameters (arguments passed)
saved registers (context, previous function’s state_
local variables
stack frame pointer (start of the frame)

where are new stack frames allocated
at lower memory addresses

explain the code
basically stack gets A, B, C, then the functions execute and get popped off the stack
the program then returns to main


explain the diagram of process state
a process transitions between states and can cycle
-the scheduler dispatch has a user-determined policy (like how long for the process; the structure)
-movement between states depends on the actions done during the process

what are the process states (practice drawing this)
new
ready
running
waiting
terminated

what is the process control block
a data structure used by OS to store information about a process (useful for context switching, like goes from one process to another and back to the first)

what is in the process control block (PCB)
BASICALLY INFO ABOUT THE PROCESSES, mainly previous action and next action
process id
process state
program counter
CPU registers
CPU scheduling info
memory info
list of open files
what does program counter do
keeps track of location for next instruction
if a process is running, what does it have access to
the CPU (registers)
why are stack frames used
used for function calls mostly (like recursion or just general calls)
they keep track of execution order and prevents corruption
what are the 2 types of processes
user
kernel

what are interrupts
like a notification about errors while a process is running

what are scheduling policies/dispatch
like what will run in what order
what is an example of a process in a waiting state?
when an application waits for keyboard input
printing queues


what does a dispatcher do
moves process from ready to running (and sometimes waiting) states
keeps each process information up-to-date

explain the picture
process moves through ready queue to the CPU and can terminate, but likely it
could loop back to ready queue bc of
IO requests
time runs out
interrupts (can be from software or hardware)
forking a child (duplicating a process, could be identical or fraternal)
what does short-term scheduler do (CPU scheduler)
is quick; chooses which process the CPU should execute next
what does long-term scheduler do (job scheduler)
is slower; chooses which processes should be put into the ready queue
what is IO bound vs CPU-bound
IO - quickly uses CPU, mainly for input and outputs
CPU - uses CPU for longer times to do computations
what are examples of IO bound
downloading files, browsing the web
what are examples of CPU-bound
gaming (bc rendering pixels), machine learning training, data mining
what is context switching
when a CPU switches processes (requires saving the state of old process and loading the state of new process)
why is context switching expensive
because it takes a while to interrupt a process and switch to a new process