Week 7 Flashcards
Virtual Memory
We don’t need the whole program in all at once, code that is not in use (executing) isn’t loaded.
Pure Demand Paging
- No pages are loaded into memory at the start of memory.
- Every page must be brought in by a page fault, including first instr.
Demand Paging
- Load in each page as needed.
- Hardware needs to know which pages are in memory.
- Invalid bit - if you access an invalid page it causes a page fault
GOOD ANSWER: A memory management technique where pages are only loaded into memory as needed
Backing Store
- All frames are busy with other processes so we write our incoming process to the BACKING STORE
Memory Resident
Pages that are already in memory.
KEY IDEA: Not all pages for a process are assigned frames and are loaded into memory
Locality of Reference
If you’ve accessed one instruction in memory, the most likely to be executed next is the next spot in memory
.BSS segment
The other variation of exe. Contains uninitialized or zero initialized vars, and only specifies the size of the variables.
.Data segment
one variation of an exe. Contains initialized global variables, and constants to initialize local variables.
Fork()
Used to create a new process.
* = 0, execute code of child
* != 0, execute code of parent
Where does bash executable usually sit on a linux machine
/bin/bash
Accessed with #!/bin/bash
Copy On Write
- Only copy a page when it’s modified.
- Requires the MMU to decide which value to utilize.
- Shared memory pages - when a process is copied, the OS doesn’t immediately duplicate memory pages. Instead, it shares them and marks them as read only, and when one of them needs to be accessed, it creates it’s own clone
GOOD ANSWER:
A technique used to optimize memory usage where copying the shared memory pages are deferred until needed
What does this do?
grep pthread main.c
prints the lines in main.c that contain the string pthread
What do these commands do?
ps - cat - cut
list process status
concatenates file to output
excract column from a file
What are all the types of wild cards and what do they do
” * : any sequence of zero or more characters
? : any single character
[xyz] x or y or z
[a-z] any chars from a - z
Difference between single quotes, double quotes and back quotes?
Single quotes evaluates the statement literally, EXCEPTIONS: Tools that use the argument to evaluate such as Grep, Awk, sed
Double quotes allow us to pass variables, delimited by $
Back quotes evaluates the expression, and then passes it. EX find (BACK QUOTE) pwd -name “*.txt” (BACK QUOTE)
How do you declare and access variables in bash?
$varName=value creates var if it doesnt exist
$varName=value2 now that it exists, sets it to value2
Shell variables aren’t private to the shell T or F
F they are
How do we declare environment variables?
export FOO=”bar”, now accessible to all sub processes.
What are the special environment variables?
PATH - list of directions to find commands delimited by : EX “/usr/bin:/usr/local:.” searches /usr/bin and /usr/local
HOME - Current home dir
SHELL - current shell (/bin/bash/)
USER - username
PWD - current dir
SLLVL - number of nested shells
What are two advantages of demand paging?
Space complexity, if we need to load less pages there’s less overall load
More efficient cpu cycles, quicker overall handling
Does execv return out of itself thus rendering the rest of the code useless
Liz hella gay.
Yes
The PCB Contains a copy of the stack T or F
F