CSE 130 Part 3

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/42

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

43 Terms

1
New cards

How can local procedure call misbehave?

Can read/write to out-of-scope local variables

2
New cards

Define soft modularity

Pass messages/data from one function to a second one by calling it

3
New cards

What is one error caused by soft modularity?

Propagation of errors

4
New cards

Define hard modularity

Pass messages/data over a network connection

5
New cards

Why is hard modularity safer from propagation of effects?

No shared memory or interpreter → failure in one system does not affect the other

6
New cards

What does LAMP stand for in a web server model?

Linux, Apache, MySQL, PHP

7
New cards

How would you alter LAMP to deal with static load/infrequent DB access?

Increase AP + load balancer, while keeping M minimal

8
New cards

How would you alter LAMP if you needed high reliability?

Use multiple M (redundancy)

9
New cards

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.

10
New cards

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

11
New cards

Why can we not guarantee 100% accurate implementation of exactly once RPC?

Set of unique ids/results cannot grow indefinitely

12
New cards

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.

13
New cards

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)

14
New cards

Is virtualization soft modularity or hard modualrity?

Neither, it’s in between

15
New cards

Three basic virtualization techniques and their definitions

  1. Multiplexing: one physical object → multiple virtual objects

  2. Aggregation: many physical objects → one virtual object

  3. Emulation: physical object(s) → a new type of virtual object

16
New cards

Which of the three virtualization technique is “Sockets across a network”?

Multiplexing— one physical network interface → many sockets

17
New cards

Which of the three virtualization technique is “RAM disk”?

Emulation— OS uses RAM as if it’s a disk to store things

18
New cards

Which of the three virtualization technique is “RAID”?

Aggregation— combining multiple physical disks into one logical volume

19
New cards

Which of the three virtualization technique is “Content distribution network”?

Aggregation— many servers disguised as one server

20
New cards

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

21
New cards

Define virtual memory

Memory that processes can use as if they each have their private own memory

22
New cards

_______ allows two processes to read/write to same physical address

Inter-process communication

23
New cards

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

24
New cards

4 OS-provided functions for bounded buffers

  1. allocate

  2. deallocate

  3. send

  4. receive

25
New cards

Why should a bounded buffer be bounded?

Back pressure— sender should not send too much data at start

26
New cards

What is a problem with this code? (Find 2)

  1. Busy wait (line 2)

  2. Race condition (line 5)

27
New cards

Define race condition

Behavior of a system depends on timing or order of uncontrollable events

28
New cards

Define data race

Two unordered memory operations (one of which is write) act on the same variable

29
New cards

Is multiple reads on the same memory OK? (Does it have a race condition?)

Yes, it is OK

30
New cards

4 steps to fix race conditions

  1. Critical regions

  2. Mutual exclusion

  3. Condition variables

  4. Semaphores

31
New cards

Define critical region

Region that must be executed by only one thread at a time

32
New cards

What is mutual exclusion?

Ensuring only one thread is in its critical region at a time

33
New cards

4 conditions of mutual exclusion

  1. No two threads may be simultaneously inside their critical regions

  2. Any number of threads

  3. No thread running outside its critical region may block another thread

  4. No thread can wait forever to enter its critical region

34
New cards

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

35
New cards

How do you prove possible outcomes?

  1. Choose a “vocabulary” (e.g. Load, Add, Store)

  2. Find an order of operations that shows the outcome

36
New cards

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

37
New cards

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)

38
New cards

Explain pthread_create(1,2,3,4)

  1. Pointer to pthread_t

  2. NULL (we don’t use in class)

  1. Pointer to a thread function

  2. Arguments to be passed to 3 as (void *)

39
New cards

Explain pthread_join(1,2)

pthread_join() waits/blocks until the thread function returns

  1. pthread_t (not a pointer!)

  2. Pointer to return val

40
New cards

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);

41
New cards

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

42
New cards

Three functions used to wake thread(s) and release lock using condition variable

  1. wait(): release lock and reacquires it once released by another

  2. signal(): wakes one thread waiting on a condition variable

  3. broadcast(): wakes all threads waiting on a condition variable

43
New cards

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);