1/42
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
How can local procedure call misbehave?
Can read/write to out-of-scope local variables
Define soft modularity
Pass messages/data from one function to a second one by calling it
What is one error caused by soft modularity?
Propagation of errors
Define hard modularity
Pass messages/data over a network connection
Why is hard modularity safer from propagation of effects?
No shared memory or interpreter → failure in one system does not affect the other
What does LAMP stand for in a web server model?
Linux, Apache, MySQL, PHP
How would you alter LAMP to deal with static load/infrequent DB access?
Increase AP + load balancer, while keeping M minimal
How would you alter LAMP if you needed high reliability?
Use multiple M (redundancy)
What is a core issue with messages? What is one way we could address this?
They may not reach the other party, and we need a way to know what happened.
Use acknowledgements.
What are the three types of ____ once in RPC?
Which one(s) uses unique id?
Which requires a request to be idempotent?
At Least once: needs to be idempotent
At Most once: needs unique id (duplication in the network)
Exactly once: needs unique id
Why can we not guarantee 100% accurate implementation of exactly once RPC?
Set of unique ids/results cannot grow indefinitely
What is asynchronous RPC?
Client sends the request, but it doesn’t wait for the return. It continues with other works and later processes the results.
What is marshaling/serialization in RPC?
Agreeing that data on the two end systems have the same meaning (e.g. converting to ensure same endian-ness, size of int, pointers)
Is virtualization soft modularity or hard modualrity?
Neither, it’s in between
Three basic virtualization techniques and their definitions
Multiplexing: one physical object → multiple virtual objects
Aggregation: many physical objects → one virtual object
Emulation: physical object(s) → a new type of virtual object
Which of the three virtualization technique is “Sockets across a network”?
Multiplexing— one physical network interface → many sockets
Which of the three virtualization technique is “RAM disk”?
Emulation— OS uses RAM as if it’s a disk to store things
Which of the three virtualization technique is “RAID”?
Aggregation— combining multiple physical disks into one logical volume
Which of the three virtualization technique is “Content distribution network”?
Aggregation— many servers disguised as one server
Which of the three virtualization technique is “Logical volume manager“?
Multiplexing & Aggregation— Can combine multiple disks as one as well as partition one volume into many
Define virtual memory
Memory that processes can use as if they each have their private own memory
_______ allows two processes to read/write to same physical address
Inter-process communication
How can a bounded buffer act as a communication link?
Threads cannot communicate with each other directly— they communicate through the OS using bounded buffer
4 OS-provided functions for bounded buffers
allocate
deallocate
send
receive
Why should a bounded buffer be bounded?
Back pressure— sender should not send too much data at start
What is a problem with this code? (Find 2)
Busy wait (line 2)
Race condition (line 5)
Define race condition
Behavior of a system depends on timing or order of uncontrollable events
Define data race
Two unordered memory operations (one of which is write) act on the same variable
Is multiple reads on the same memory OK? (Does it have a race condition?)
Yes, it is OK
4 steps to fix race conditions
Critical regions
Mutual exclusion
Condition variables
Semaphores
Define critical region
Region that must be executed by only one thread at a time
What is mutual exclusion?
Ensuring only one thread is in its critical region at a time
4 conditions of mutual exclusion
No two threads may be simultaneously inside their critical regions
Any number of threads
No thread running outside its critical region may block another thread
No thread can wait forever to enter its critical region
Why should a while loop be included in a critical region?
If you lock after checking the loop condition, an OS may allow multiple threads to enter the loop
How do you prove possible outcomes?
Choose a “vocabulary” (e.g. Load, Add, Store)
Find an order of operations that shows the outcome
What is deadlock?
One thread acquires the lock and waits for a condition (e.g. push waits for the buffer to be pop()-ed) but another thread cannot fulfill that condition because of the lock
What is one inefficient way to resolve deadlock? What is another issue caused by this method?
Strategic release()/acquire() pairs, causing spinlock (wasting CPU resources)
Explain pthread_create(1,2,3,4)
Pointer to pthread_t
NULL (we don’t use in class)
Pointer to a thread function
Arguments to be passed to 3 as (void *)
Explain pthread_join(1,2)
pthread_join() waits/blocks until the thread function returns
pthread_t (not a pointer!)
Pointer to return val
Say we want to pass in a thread_id to the thread function. How do we do it?
Use intptr_t to cast int to void *
int thread_id = i; (using for loop)
intptr_t intptr = thread_id;
pthread_create(…, (void *) intptr);
What functions do we use to lock and unlock mutex?
pthread_mutex_lock(1) and pthread_mutex_unlock(1)
1: pointer to pthread_mutex_t
Three functions used to wake thread(s) and release lock using condition variable
wait(): release lock and reacquires it once released by another
signal(): wakes one thread waiting on a condition variable
broadcast(): wakes all threads waiting on a condition variable
Functions for creating and destroying a mutex lock
// static initialization
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
// dynamic initialization
pthread_mutex_t mutex;
int rc = pthread_mutex_init(&mutex, NULL);
assert(rc == 0);
int rc = pthread_mutex_destroy(&mutex, NULL);
assert(rc == 0);