deck_17769120 Flashcards

1
Q

What is parallelism? When can it take place?

A

The simultaneous execution of multiple processes or threads.

When there exist multiple processors or cores.

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

What is concurrency? How does it differ from parallelism? Can concurrency take place on a single-core processor?

A

The ability of an operating system to manage multiple processes at the same time, allowing them to make progress independently.

Processes are not executed simultaneously, but rather multiple tasks are dealt with at once. Yes, as only one process is actually being executed at any one time.

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

What are three disadvantages of processes?

A
  1. Creation overhead, e.g., in terms of memory space.
  2. Complex inter-process communication.
  3. Process-switching overhead (mode + context switch, including save/restore contexts of execution).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between processes and threads?

A

Process is an independent program in execution with its own memory space. Thread is the smallest unit of execution within a process.

Processes define ownership on resources, while threads may share access to the same variables, code, or files.

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

What additional info does a thread’s associated executed state have in addition to the PCB?

A

Program counter, stack counter, return addresses of function calls, values of processor registers.

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

Why do threads operate faster than processes?

A

Thread creation and termination is much faster as no memory address space copy is needed.

Context switching between threads of same process is much faster, as no need to switch whole address space, only swap CPU registers content.

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

What are some reasons to introduce threads? What is their primary downside?

A

Reasons:

  1. Increase concurrency level with better performance.
  2. Use natural concurrency within a program.

Downside: No protection against other threads in the same process (risk of faults, memory sharing).

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

What are user threads?

A

Threads managed by a user-level library without kernel intervention, with the OS unaware of these threads.

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

What are kernel threads?

A

Threads managed and scheduled directly by the operating system kernel.

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

What are the four multithreading mapping models?

A

Many-to-one Model, One-to-one Model, Many-to-many Model, Two-level Model.

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

What is the many-to-one multithreading mapping model?

A

Multiple user threads are created and managed by a user-level thread library.

All these threads are mapped to a single kernel thread.

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

Advantages of many-to-one multithreading mapping model? Disadvantages?

A

Adv: No need for kernel involvement, fast and easy to deploy.

Disadv: Only one user accesses kernel at a given time; thus, multiple threads cannot run in parallel on multiple processors.

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

What is the one-to-one multithreading model?

A

Each user-level thread maps to a kernel thread.

Kernel fully aware of all threads in process.

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

Advantages of one-to-one multithreading model? Disadvantages?

A

Adv: Allows for concurrency between all threads.

Disadv: All threads managed by kernel, with negative impacts on performance in case of many user threads.

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

What is the many-to-many model?

A

Limited number of kernel threads.

Multiple user threads mapped to a pool of kernel threads.

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

Advantages of many-to-many multithreading model? Disadvantages? What is the concurrency level limited by in this model?

A

Advantages: Concurrency, bounded performance cost for kernel.

Disadvantage: More complex to implement. Number of kernel threads.

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

What is the two-level multithreading model?

A

Maps multiple user threads to a smaller number of kernel threads (like in many-to-many model).

Certain user threads can also be bound directly to kernel threads (like in one-to-one model).

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

How does thread switching as a kernel activity? How about as handled by user-level thread libraries?

A
  1. Kernel maintains execution state of thread, works similar to process switching.

  1. Library maintains execution state of threads, must obtain control in order to switch threads; responsibility of programmer to call library to yield execution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are thread pools? What are their advantages?

A

A collection of pre-initialised threads that can be reused to execute tasks, avoiding the overhead of creating and destroying threads repeatedly.

Adv: Slightly faster to service a request with an existing thread than creating a new one.

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

What are some common processor scheduling algorithms?

A

First-Come First-Served (FCFS), Shortest-Job-First (SJF), Round Robin (RR), Priority Scheduling - Rate Monotonic (RM), Deadline Monotonic (DM), Earliest Deadline First (EDF), Multilevel Queue, Multilevel Feedback Queue.

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

What does the decision mode define?

A

When scheduling decisions are taken.

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

Preemptive vs Non-Preemptive Scheduling:

A

In preemptive scheduling, the OS can interrupt a running process to allocate CPU time to another process.

In non-preemptive scheduling, once a process starts executing, it runs until it completes or voluntarily relinquishes control of the CPU.

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

Time-Based vs Event-Based Scheduling:

A

In time-based scheduling, scheduling decisions are made based on a regular time slice or a clock interrupt.

In event-based scheduling, decisions are made in response to specific events rather than fixed time intervals.

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

What is the priority function?

A

The function defining which ready tasks are chosen for execution next.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the arbitration rule?
Breaks ties between tasks.
26
How is the waiting time defined?
Total amount of time a process spends in the ready queue, waiting for CPU time to be allocated, excluding the time the process is actively executing.
27
How is the response time defined?
The amount of time that elapses between when a user initiates a request and when the system first produces a response.
28
How is the turnaround time defined?
The total time taken to execute a particular process, from the time it is submitted to the time it completes execution.
29
What is throughput?
The number of jobs or processes that are completed per unit of time.
30
What is the priority function of FCFS? Is it preemptive or non-preemptive? What is its arbitration rule?
Tasks are scheduled in order of their arrival. ## Footnote Non-preemptive. Random choice among processes that arrive at the same time.
31
What is the priority function of SJF scheduling? What is its decision mode? What is its arbitrary rule? What is it optimal with relation to? What is its preemptive version called?
Tasks are scheduled in terms of shortest execution time. ## Footnote Non-preemptive. Chronological or random ordering. Average waiting time. Shortest-Remaining-Time-First.
32
How does Round Robin Scheduling work? Arbitration Rule?
Each process in the ready queue is allocated a fixed time slice, i.e., a 'quantum'. ## Footnote If a process completes within its quantum, it releases the CPU voluntarily.
33
What is priority scheduling? What is an issue with it?
A priority number is associated with each task that is either assigned by the programmer or computed through a function. ## Footnote Starvation, i.e., low priority processes never executing.
34
What is Rate Monotonic (RM) Priority Scheduling? Is it preemptive or non-preemptive? Arbitration function?
Processes are often periodic, i.e., activated every period T. RM priorities the processes with the shortest period T. ## Footnote Preemptive. Chronological/Random.
35
What is Deadline Monotonic (DM) scheduling? Preemptive? Arbitration function?
Prioritises the processes with the shortest relative deadline D. ## Footnote Preemptive. Chronological/Random ordering.
36
What is Earliest Deadline First (EDF)? Decision mode? Arbitration rule?
Highest priority assigned to process with shortest remaining time until its deadline. ## Footnote Preemptive. Chronological/Random.
37
What is multilevel queue scheduling? How is scheduling between the queues done?
Partitions the ready queue into various sub-queues. ## Footnote Each queue has its own scheduling algorithm.
38
What is a multilevel feedback queue? What is a multilevel feedback queue scheduler defined in terms of?
Instead of processes being assigned to one, fixed sub-queue, tasks can be moved across sub-queues. ## Footnote 1. Number of queues. 2. Scheduling algos for each queue.
39
What is a sequential task? What takes the place between the states?
A discrete sequence of tasks, e.g., observable in program code. ## Footnote Indivisible, atomic steps/actions.
40
What is the single reference rule?
A statement in a programming language may be regarded as atomic if at most one reference to a shared variable occurs.
41
How to regard a non-atomic statement as atomic, e.g., S?
You write it as , e.g., .
42
What is a trace? Does it maintain the internal execution of the individual tasks? What do the actions refer to?
A sequence of atomic actions, obtained by interleaving the execution of concurrent tasks. ## Footnote Yes. Assignments or tests.
43
What is a 'possible trace'?
A trace in which all tests yield true.
44
What are shared variables?
Variables accessible to several tasks (processes/threads).
45
What is a private variable?
Variable accessible only to a single task.
46
What is interference?
Disturbing others' assumptions about the state.
47
What is meant by race condition?
A situation in which correctness depends on the execution order of concurrent activities.
48
What is synchronisation?
Ordering the execution, i.e., forbidding certain traces.
49
What are the five requirements on synchronisation solutions? Explain each shortly.
1. Functional correctness - satisfying the given specification. ## Footnote 2. Minimal waiting - waiting only when correctness is in danger.
50
How does Peterson's Algorithm work? Write out the structure of the algorithm.
Uses a shared variable t to denote the turn. Uses two booleans bY and bX to ensure minimal waiting. ## Footnote void Px { while (true) { bX = true; t = Y; while(bY=true AND t!=X) { skip;} x = x+1; bX = false; }}
51
What are the limitations of Peterson's Algorithm?
Can synchronise only two tasks, with extensions for more tasks existing but being more complex. ## Footnote Busy-wait, which wastes CPU Cycles.
52
What is a mutex?
A synchronisation primitive used to ensure that only one thread or process can access a shared resource at a time.
53
What is a mutex initialised to? What are its two operations?
1. ## Footnote lock(m): await(m>0) + m=m-1; unlock(m): m=m+1.
54
What are some challenges with priority scheduling when protecting shared resource access?
1. Blocking: a low priority task obtaining a resource, and a high priority task then waiting on it. ## Footnote 2. Priority Inversion: occurs when a lower-priority task holds a resource that is needed by a higher-priority task.
55
What is a solution to priority inversion that prevents a middle-priority task to preempt the lowest priority task that has the resource? What is the name of this protocol?
Adjusting the priority of the task T holding the resource to the maximum of the priority of any other task that is blocked on the allocated resources of P and its own priority. ## Footnote Priority Inheritance Protocol.
56
Which of the following components of program state are shared across threads in a multithreaded process: register values, heap memory, global variables, stack memory?
Share heap memory and global variables. ## Footnote Do NOT share register values and stack memory.
57
Can a multithreaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single processor system?
No, since the multithreaded system cannot make use of the different processors simultaneously, as it sees only a single process.
58
Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Discuss the performance implications of the following scenarios.
When the number of kernel threads is less than the number of processors, then some of the processors would remain idle. ## Footnote When the number of kernel threads is exactly equal to the number of processors, then it is possible that all of the processors might be utilized simultaneously.
59
Do processes share global variables?
No, they do not.
60
Which is the most general scheduling algorithm?
Multilevel Feedback-Queue Algorithm.