week2 Flashcards
concurrency
- ability to specify parts of program that can run simultaneously
- no assumption can be made about relative order of execution of concurrent portions of a program
- does not necessarily mean parallel
- even on multicore, no guarantee concurrent portion will be on different cores
ada concurrency
task specifications
task body
abstraction (func and types)
functions - procedural abstractions, hidden, i.e. printf for displaying output
types - data abstractions (bits)
type
set of values w set of operations over those values
adt
- type
- has complicated representation that is not visible to users of the type
- has user defined operations over values of the type
higher order functions
functions that operate over functions
- pass func as parameter, insert into data struct and return func as parmeters
static scoping
look where function is DEFINED
dynamic chain
- represents the way back to the stack frame
stacks in concurrency
cactus stack
each thread has its own stack
stack pointer
- points to top of stack
- adjusted everytime something pushed on
frame pointer
- points into same plc w/in current activation record
- locals and parameters are offset from FP in current AR
- when stack is decremented to go to next stack item, must have pter (DL) to show where to go in next frame
block structure
- function can access its own declared varaibles as well as outside variables
dynamic link
- pts to previous AR
static link
- for each procedure from AR of current procedure to procedure outside of it
- allows arbitrary nested programs in ADA
- main procedure does not have static link
- if multiple a’s static link pts to most recent a
- address in memory
symbol table
compiler uses it so names /searching does not occur
why is static chain efficient
all variables forced on appropriate plc on stack
closure
- code pter
- static link
= environment; i.e. path to retrieve nonlocal variables that the function needs
-self-contained
heap
- when stack is not enough; i.e. in scheme for returning functions as parameters means procedures can outlive procedure where it is declared
- languages that support returning functions that access nonlocal variables
garbage collection
reclaims space in heap where variables are no longer needed
formal parameter
the parameter in the function construction
actual parameter
the parameter when the function is called
pass by value
the value of actual param is copied into formal param (c, c++, java)
pass by ref
any use of formal params in body to function is ref to actual param
pass by val-result
copy in copy out
pass by name
algol copy rule
- expression that is in the actual parameter is passed
- replace formal params by actual params
- expand func call into body of funct w formals replaced by actual params