chapter 3 (processes)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/34

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:42 PM on 9/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

35 Terms

1
New cards

why processes were invented

for batch jobs (tasks that repeat over and over)

2
New cards

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

3
New cards

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

4
New cards

how does program code move

program code goes from DISK (secondary) to RAM (main memory)

then CPU can access data

5
New cards
<p>how does process work in VIRTUAL memory</p>

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)

6
New cards
<p>who operates the stack (<strong>virtual </strong>memory)</p>

who operates the stack (virtual memory)

the OS

7
New cards
<p>who operates the heap (<strong>virtual </strong>memory)</p>

who operates the heap (virtual memory)

the programmer/coder

8
New cards

where do memory leaks happen

in the heap (if programmer forgets to deallocate dynamic memory)

9
New cards
<p>where do variables live in</p>

where do variables live in

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

10
New cards
<p>where do dynamic variables live in</p>

where do dynamic variables live in

the heap

11
New cards
<p>explain the picture</p>

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

12
New cards

what is a stack frame

a container (temporary data structure) that organizes functions

13
New cards

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)

<p>return address (location after function ends)</p><p>function parameters (arguments passed)</p><p>saved registers (context, previous function’s state_</p><p>local variables</p><p>stack frame pointer (start of the frame)</p>
14
New cards

where are new stack frames allocated

at lower memory addresses

15
New cards
<p>explain the code</p>

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

<p>basically stack gets A, B, C, then the functions execute and get popped off the stack</p><p>the program then returns to main</p>
16
New cards
<p>explain the diagram of process state</p>

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

<p>a process transitions between states and can cycle</p><p>-the scheduler dispatch has a user-determined policy (like how long for the process; the structure)</p><p>-movement between states depends on the actions done during the process </p>
17
New cards

what are the process states (practice drawing this)

new

ready

running

waiting

terminated

<p>new</p><p>ready</p><p>running</p><p>waiting</p><p>terminated</p>
18
New cards

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)

<p>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)</p>
19
New cards

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

20
New cards

what does program counter do

keeps track of location for next instruction

21
New cards

if a process is running, what does it have access to

the CPU (registers)

22
New cards

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

23
New cards

what are the 2 types of processes

user

kernel

24
New cards
<p>what are interrupts</p>

what are interrupts

like a notification about errors while a process is running

25
New cards
<p>what are scheduling policies/dispatch</p>

what are scheduling policies/dispatch

like what will run in what order

26
New cards

what is an example of a process in a waiting state?

when an application waits for keyboard input

printing queues

<p>when an application waits for keyboard input</p><p>printing queues</p>
27
New cards
<p>what does a dispatcher do</p>

what does a dispatcher do

moves process from ready to running (and sometimes waiting) states

keeps each process information up-to-date

28
New cards
<p>explain the picture</p>

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)


29
New cards

what does short-term scheduler do (CPU scheduler)

is quick; chooses which process the CPU should execute next

30
New cards

what does long-term scheduler do (job scheduler)

is slower; chooses which processes should be put into the ready queue

31
New cards

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

32
New cards

what are examples of IO bound

downloading files, browsing the web

33
New cards

what are examples of CPU-bound

gaming (bc rendering pixels), machine learning training, data mining

34
New cards

what is context switching

when a CPU switches processes (requires saving the state of old process and loading the state of new process)

35
New cards

why is context switching expensive

because it takes a while to interrupt a process and switch to a new process