CSCE 313 Exam 3 Review

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:57 PM on 4/23/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

21 Terms

1
New cards

What does each thread have its own version of?

Stack
Registers
Sigmasks

2
New cards

What do all threads in a process share?

Address space

Data

Code

Open files
Signal disposition (handlers)

3
New cards

How is thread similar to fork()?

They’re both non-blocking functions. The program continues after they’ve been executed.

4
New cards

What is a race condition?

When the output of concurrent threads depends on the order of operations between them. It can create non-deterministic outputs.

5
New cards

In the context of threads, what is instruction reordering?

Some compilers will move around items in threads to achieve peak performance. They may move simpler functions to the start and more complex ones to the end, possibly breaking threads in the process.

6
New cards

What is a Mutex?

A lock that we require before using a shared resource. It prevents any other thread from accessing the locked region of code. It’s released after use.

7
New cards

Describe the producer-consumer problem that comes with using a mutex.

If one thread is dependent on data from another and they both lock each other, something like a while loop can cause a dead lock by preventing either thread from accessing their data due to one of the locks being active. The consumer can’t consume if the producer is locked.

8
New cards

How do we fix the producer-consumer problem?

By using a condition variable.

9
New cards

What is a condition variable? What does it do?

A queue of all the waiting threads with a lock for access to the critical section of code. It essentially sends a notification to a thread alerting it that it can access that section now and likely safely lock itself.

10
New cards

What does declaring a condition variable look like (In C and C++)? Assume there is some unique_lock named ul and some pthread mutex named m.

pthread_mutex_lock lock;
pthread_cond_wait(&cond, &lock)

std::condition_variable cond;
cond.wait(ul, []{ return (condition); });

11
New cards

What is a Semaphore?

A non-negative integer variable shared among multiple processes. It acts in a similar function to wait() and lock() with more simplicity.

12
New cards

What is the difference between wait() and post()?

wait() waits until the value is positive and then decrements it by 1. post() increments the value by 1, possibly waking up a thread.

13
New cards

What happens if a wait and a post happen at functionally the same time?

No different from what would happen otherwise. The post() is picked up regardless.

14
New cards

What is a Binary Semaphore?

A Semaphore that starts at 1. This allows the first wait to decrement the value to effectively “lock” the code that is critical.

15
New cards

Do the order that the posts and waits happen in matter?

Only the order of waits matters, because it can cause deadlocks. The order of posts only affects the scheduling efficiency.

16
New cards

When dealing with scheduling constraints between threads, why do we have an initial value of 0 for our Semaphore?

Because it allows for another thread to wait for a “signal” (post) from the other. The post() would increment that value, allowing the wait to finally decrement since the Semaphore is no longer 0.

17
New cards

What does the Application layer do, and what are the key terms?

Meaning of data for the program. HTTP, DNS.

18
New cards

What does the Transport layer do, and what are the key terms?

End-to-end process communication. TCP, UDP, ports.

19
New cards

What does the Network layer do, and what are the key terms?

Host-to-host addressing and routing. IP, routers, packets.

20
New cards

What does the Data Link layer do, and what are the key terms?

Local delivery on current link segment. Ethernet, Wifi, MAC, frames.

21
New cards

What does the Physical layer do, and what are the key terms?

Raw bits onto wire/fiber/radio. Electrical signals, bits.