Exam 2 Review - Chapters 4 to 6, Tutorials for Mutex Lock and Semaphore Flashcards

1
Q

What is a thread?

A

A basic unit of computation, AKA a lightweight process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do multi-threaded applications consist of?

A

They have multiple threads within a single process, each having their own program counter, stack, and set of registers; all share common code and data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the benefits of using multi-threaded processes?

A

Improves responsiveness, resource sharing, economy, and scalability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do multithreading models work?

A

User threads are supported above the kernel, and kernel threads are supported by the OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the different kinds of multithreading models?

A

Many-to-one, one-to-one, and many-to-many

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is many-to-many the most popular multithreading model?

A

A blocking system call wouldn’t block the entire process, as well as allowing the OS to create a sufficient number of kernel threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is assigned to a thread when it’s created?

A

A thread ID, stack, and starting address for execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What parameters does pthread_create() have?

A

In order, ChildID, Thread_attributes, function_name, arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of pthread_join()?

A

Wait for the target thread to terminate before further processing in main thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you compile and create and executable file with pthread?

A

cc -o programName programName.c -pthread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why do we care for process synchronization?

A

So processes can execute concurrently with minimal problems (OS must provide mechanisms to ensure the orderly execution of cooperating processes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What problem arises with concurrent data access?

A

May result in data inconsistency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Producer-Consumer (Bounded Buffer) problem?

A

A data buffer shared by two processes; each can update counter, risks a race condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a race condition?

A

Several processes access and manipulate the same data concurrently and the outcome depends on the particular order of execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the critical section?

A

It’s a segment of code in each process where the process may be changing common variables, updating table, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Peterson’s solution for fixing the race condition?

A

Uses the idea of locking to protect critical regions via locks; meets the three requirements: mutual exclusion, progress, bounded waiting. Uses flags as locks

17
Q

What are mutex locks?

A

Based on the idea of locking, protects a critical section by first acquire() a lock and then release() the lock (boolean variable indicating lock availability, and methods must be atomic); considered the simplest synchronization tools

18
Q

What are semaphores?

A

Similar to mutex locks, binary but uses an integer value to indicate lock availability

19
Q

How can you use semaphores with no busy waiting?

A

Instead of keeping a process busy waiting, have it block itself (suspend itself), then wake it up when a semaphore is ready

20
Q

What is a deadlock?

A

Multiple processes are blocked, each waiting for a resource that can only be freed by one of the other blocked processes

21
Q

What methods can you use to resolve deadlocks?

A

FIFO (every process will eventually get its turn to be removed) or LIFO (early processes may never be removed, starved)

22
Q

What solutions can be used for the Dining-Philosophers Problem?

A

Allow at most 4 philosophers to sit at the table; pick up chopsticks only if both are available (picking up done in critical section); use asymmetric solution, odd-numbered picks up first the left then right chopstick, even-numbered picks up first right then left chopstick

23
Q

What is a CPU-I/O burst cycle?

A

A process execution consisting of a cycle of CPU execution (performing calculations) and I/O wait (waiting for data transfer in or out the system)

24
Q

What does the CPU (short-term) scheduler do?

A

Handle removal of running process from CPU and the selection of another process, as well as selecting from among the processes in ready
queue, and allocates the CPU to one of them

25
Q

What is preemptive scheduling?

A

A process given the CPU may have it taken away

26
Q

What is nonpreemptive scheduling?

A

A process given the CPU may not have it taken away

27
Q

What does a dispatcher do?

A

Switches context, switches to user mode, and jumps to the proper location in the newly loaded program

28
Q

What is the criteria for selecting a scheduling algorithm?

A

Maximize CPU utilization and throughput, minimize turnaround time, waiting time, and response time

29
Q

What’s the average wait time for first-come first-serve?

A

(P1 wait time + P2 wait time + … + Pn wait time)/n; Average time can be long

30
Q

What is the convoy effect?

A

A short process comes behind a long process

31
Q

What is the average wait time for shortest job first?

A

Same as FCFS but organize processes by shortest to largest; one of the fastest algorithms

32
Q

How do you calculate shortest remaining time first?

A

AWT = Delta((Completion Time - Arrival Time) - Burst Time)/n

33
Q

What is priority scheduling?

A

A priority number is associated with each process, and the CPU is allocated to the CPU with the highest priority

34
Q

What is round robin?

A

Each process gets a small amount of CPU time (time quantum q). After this has elapsed, the process is preempted and added to the end of the ready queue (no process waits more than (n-1)q time units

35
Q

How does multilevel queue work?

A

Processes in the ready queue is partitioned into multiple sub-lists, based on some criteria (RR for foreground queue and FCFS for background queue), each one independent

36
Q

How does multilevel feedback queue work?

A

Like multilevel queue but processes flow from one to another, can be organized with different scheduling algorithms like RR leading to FCFS

37
Q

How do symmetric and asymmetric processing differ?

A

For asymmetric, only one processor controls all activities and for symmetric, each processor is self-scheduling

38
Q

What is load balancing?

A

Attempts to keep workload evenly distributed