Final practice exam Flashcards
(84 cards)
What does the comma operator do?
- sequences two expressions
- value is the result of the righthand expression
- treated as a single expression by the compiler
What are enumerated types?
-syntax: enum tag { values } vars ;
-each ‘value’ is an identifier - use them in expressions
-internally, represented as integers
- by default, first ‘value’ represented as 0
- subsequent ‘values’ have previous - entry’s representation + 1
- can override: name = integer
- sequence defines an ordering relationship between the ‘values’
What are qualifiers?
- optimization hints to the compiler
What are the forms of qualifiers?
register: keep this variable in a register if possible
volatile: variable’s contents may change between compiled statements
restrict: guarantee that *ptr is the only reference to something in this scope
What is the syntax for a macro with a parameter?
define name(params) value
What is a macro with a parameter?
each occurrence of a formal parameter in value is replaced by its actual parameter during macro expansion
What are the special uses of parameters
param: replaced by a string literal containing the actual parameter
##: creates a symbol during expansion
what is #error text?
generates a compilation error whose message includes text
What is #pragma text?
- invokes a compiler-specific action
- syntax and meaning of text are implementation-dependent
- inherently non-portable!
What are some optimization tools?
- profilers (e.g., gprof): analyze program behavior, determine number of calls to each function and total time spent in each function
- code coverage (e.g., gcov): determine whether or not all code in a program can be reached
What is none as inefficient code?
- excess code inside loop bodies (“loop invariants”)
- unnecessary computation
- common subexpressions
What is the big O notation for the search of unordered list?
O(n)
What is the big O notation for the search of a ordered list?
O(n/2)
What is the big O notation for a binary search tree?
O(logn)
What is the big O notation for a hash table?
O(1)
What is inefficient memory accessing?
primarily on large data sets in memory
What are things that affect performance?
- efficiency of code produced by the compiler
- efficiency of algorithms
- redundant/unnecessary/useless code
- data layout and access
How to measure of some aspect of program behavior
- CPU time used, “user” time, i/o operations, etc.
- what matters depends on your point of view
What are the attributes in protection?
- things in the file system have these
- ownership (UID, GID)
- permission bits (read, write, execute)
- interpretation of permissions for files vs. directories
What is ownership in protection?
- user id (UID), group id (GID)
- each process has both IDs
- OS uses these IDs to determine access rights
How does altering ownership and accessing right in protection work?
- “set” bits (set uid, set gid, sticky bit)
- allow users to run programs with different UIDs/GIDs
- ID variations:
-real UID/GID: who is actually running the program
-effective UID/GID: determine access rights to files (etc.)
-saved UID/GID: “backup” of real UID/GID
What is protection?
- OS as a collection of objects
- characteristics of objects
- Principle of Least Privilege
What are the concepts of security?
- threats, attacks, intruders
- goals: confidentiality, integrity, availability
What is philosophy in security?
concept that protection is neccessary