FINAL STUDY Flashcards
Four issues of complexity?
- Emergent Properties
- Propagation of Effects
- Incommensurate Scaling
- Tradeoffs
Emergent Properties
(issue of complexity)
Properties that show when combining components
Propagation of Effects
(issue of complexity)
Problems in one component affect other components
Incommensurate Scaling
(issue of complexity)
Not all parts of a system scale at the same rate
Tradeoffs
(issue of complexity)
Sacrifice one thing for more of something else
What is a system?
A set of interconnected components that has an expected
behavior observed at the interface with its environment.
Signs of Complexity?
- Large number of components
- Large number of interconnections
- Lots of irregularities (little differences)
- Long description (high information content)
- Large team of designers, implementers, or maintainers
What are the sources of system complexity?
- Interactions of requirements
- Increasing efficiency, utilization, or other measure of “goodness”
Interactions of Requirements in terms of complexity?
(source of system complexity)
A general-purpose tool that can do X and other things is more complex than
a special-purpose tool that can only do X
Increasing efficiency, utilization, or “goodness” in terms of complexity?
(source of system complexity)
Additional gains in efficiency will lead to a more complex system
What increases complexity?
- Principle of escalating complexity
- Principle of excessive generality
- Law of Diminishing Returns
Principle of escalating complexity?
(increases system complexity)
Adding a requirement increases complexity out of proportion
Principle of excessive generality?
(increases system complexity)
If it’s good for everything, it’s good for nothing (flying car)
Law of Diminishing Returns?
(increases system complexity)
The more one measure of goodness is improved, the harder it gets to make
the next improvement
Ways we can manage complexity?
- Modularity
- Abstraction
- Layering
- Hierarchy
Modularity
Break big things into smaller pieces (aka divide and conquer)
Abstraction
Break into components at logical points, Treat an individual component as a black box, Benefit from the Robustness principle
Layering
Build new layer from (already existing) lower layer, Layer may consist of multiple modules (components), Modules in a layer may only interact within the layer or up or down one layer
Hierarchy
Combine small groups of modules into small subsystems, Combine small subsystems into large subsystems, Combine large subsystems into systems, Limit the visibility of each level of abstraction hierarchy to limit
complexity
Robustness Principle
Be TOLERANT on inputs, be STRICT on outputs
Three main things a system does?
Store -> Memory
Compute -> Interpreter
Communicate -> Communication Channels
Volatile Memory/ Non-Volatile Memory
Volatile Memory is memory that only keeps data while it’s powered
Bandwidth (Memory Performance)
Units of memory/Units of time
Latency (Memory Performance)
How long does it take to get a single value from memory
What is more important? Low read latency? Low write latency? Why?
Read Latency, because we can make it asynchronous, writes are synchronous
Programs bound by synchronous writes operate at the speed of write ________.
a. latency
b. bandwidth
c. throughput
Write latency
Programs bound by asynchronous writes operate at the speed of write
_________.
a. latency
b. bandwidth
c. throughput
Write bandwidth
Read/Write Coherency
The result of a read is the same as the most recent write
Read/Write Atomicity
The result of a read is as
if the read occurred completely before or completely after every other write
What two functions does a communication link use?
SEND(link, message_buf)
RECEIVE(link, message_buf)
char *s = “abc”;
s = NULL;
what happens?
s becomes a null pointer
char s[10] = “abc”;
s = NULL;
what happens?
ERROR s is not an address
int main(void) {
char *s;
…
}
What is s initialized to?
It’s not initialized! Local variables aren’t initialized.
char *s;
int main(void) {
…
}
What is s initialized to?
It is initialized to NULL
int main(void) {
static char* s;
…
}
What is s initialized to?
It is initialized to NULL.
It has a GLOBAL storage, but LOCAL scope
open()
- header for function?
- header for flags?
- what arguments?
- success return value(s)?
- error return value(s)?
- Flag to read/write
- Flag to read
- Flag to write
- Flag to create file
- Flag to truncate file
- <unistd.h>
</unistd.h> - <fcntl.h>
</fcntl.h> - open(char* pathname, int flags, mode_t mode)
- Success: non-negative int
- Error: -1
- O_RDWR
- O_RDONLY
- O_WRONLY
- O_CREAT
- O_TRUNC
read()
- header for function?
- what arguments?
- success return value(s)?
- error return value(s)?
- <unistd.h>
</unistd.h> - read(int fd, void* buf, size_t n)
- Success: num bytes read, can be 0
- Error: -1
write()
- header for function?
- what arguments?
- success return value(s)?
- error return value(s)?
- <unistd.h>
</unistd.h> - (int fd, void *buf, size_t n)
- Success: num bytes written, can be zero
- Error: -1
creat()
- arguments
- success return values?
- error return values?
- creat(char* name, mode_t mode)
- Success: non-negative int
- Error: -1
close()
- arguments
- success return values?
- error return values?
- close(int fd)
- Success: 0
- Error: -1
unlink()
- arguments
- success return values?
- error return values?
- unlink(char *name)
- Success: 0
- Error: -1
lseek()
- arguments
- success return values?
- error return values?
- lseek(int fd, off_t offset, int origin)
- Success: non-negative int
- Error: -1
origin:
- SEEK_SET means relative to beginning of file (offset ≥ 0)
- SEEK_CUR means relative to current position
- SEEK_END means relative to end of file (offset ≤ 0)
regcomp()
- arguments
- success return values?
- error return values?
- regcomp(regex_t preg, char regex, int cflags)
- Success: 0
- Error: error code use regerror() to convert
CFlags:
- REG_EXTENDED - use it
- REG_NEWLINE - [”^” -> “$”]
regfree()
- arguments
- success return value?
- error return value?
- regfree(regex_t *preg)
- Success: does not return
- Error: does not return
regexec()
- arguments
- success return value?
- error return value?
- regexec(regex_t preg, char string, size_t nmatch, regmatch_t pmatch[], int eflags)
- Success: 0
- Error: error code convert use regerror()
- declare pmatch array with nmatch items
- pmatch[0] always matches whole expression
regmatch_t struct
- beginning of match
- end of match
- rm_so
- rm_eo
printf(“%.10s”, string);
how many characters will this print
it will print NO MORE than 10 characters
max_width = 5;
printf(“%.*s”, max_width, string);
how many characters will this print?
it will print NO MORE than 5 characters
LAMP Web Server, what does LAMP stand for?
Linux
Apache
MySQL
PHP
Soft Modularity
Dividing code into named modules, functions etc., what we normally do when we code
Hard Modularity
Divide code and let them communicate only through messages. “Connected by a wire”
Marshaling
Essentially serialization, Ensuring that the client and server data have the same meaning
How does the interpreter(CPU) receive the next instruction, aka what does it access?
Instruction Reference
How does the interpreter(CPU) interpret an instruction, aka what does it access?
Instruction Repertoire and Environment Reference
What does the interpreter(CPU) change when it gets an interrupt signal?
Instruction Reference and Environment Reference