Exam 2 OS Concepts CH5-CH8

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

1/165

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:32 PM on 10/30/23
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

166 Terms

1
New cards

What is concurrency?

When things run at the same time, specifically processes and threads

2
New cards

In what systems does concurrency arise?

Multiprogramming - multiple processes on a uniprocessor (multitasking)

Multiprocessing - multiple processes on a multiprocessor

Distributed processing - multiple processes on multiple distributed systems

3
New cards

In what contexts does concurrency occur?

Multiple applications running at once

Structured applications (apps made up of multiple pieces running at once)

OS Structure (OS made of multiple pieces running at once)

4
New cards

What problems arise when running more than one processor at a time?

  • Sharing of resources among processes (order of execution becomes critical)

  • Allocation of resources (deadlocks)

  • Debugging (bugs might be unique to one order of process execution)

5
New cards

What is a race condition?

Multiple processors/threads read and write data so the final results depend on the order of execution

6
New cards

What design/management issues are raised due to concurrency in the OS?

  • Keeping track of active processes

  • Allocation of resources to each process

  • Protecting data/resources from interference of other process

  • Results must be independent of speed at which execution occurs relative to other processes

7
New cards

What are three cases in which processes interact with eachother?

  • Unaware: independent (competition)

  • Indirectly aware: shared resource (cooperation)

  • Directly aware: communicate (cooperation)

8
New cards

What problems does competition between processes pose?

Mutual exclusion, deadlock, starvation

9
New cards

What problems does cooperation by sharing pose?

Mutual exclusion, deadlock, starvation, and data coherence

10
New cards

What problems does cooperation by communication pose?

Deadlock, starvation

11
New cards

What are some requirements for mutual exclusion support?

Enforcement (one process at a time in crit section)

Non-Interference (process that halts in non-crit doesn’t affect other processes)

Crit section open → any process wanting entry permitted without delay

Finite time (within crit section)

12
New cards

What three approaches are used to achieve mutual exlcusion?

Software - apps enforcing it through coding

Hardware - disable interrupts/have special machine instructions to support it

OS or Language - OS or language offer support for it

13
New cards

What are software solutions to achieve mutual exclusion?

Dekker’s and Peterson’s Algorithm

14
New cards

What are hardware solutions to achieve mutual exclusion?

Interrupt disabling, special machine instructions

15
New cards

What is interrupt disabling for mutual exclusion?

Allow a process to complete the critical section without being switched to another process

16
New cards

What issues arise from interrupt disabling for mutual exclusion?

Degrades multitasking performance

Doesn’t work on multiprocessor systems where processes execute at once regardless of interrupts

17
New cards

What are special machine instructions for mutual exclusion?

An instruction could be designed that carries out 2 operations against a memory location atomically (without interruption)

18
New cards

What issues arise from special machine instructions for mutual exclusion?

Busy-waiting

Starvation

Deadlock

19
New cards

What are OS or language approaches to achieve mutual exclusion?

Semaphores - uses waits (decrement) and signals (increment), made atomic by provider

Queue used to hold processes waiting on semaphore

20
New cards

What is a strong semaphore?

Queue uses FIFO order

No starvation

21
New cards

What is a weak semaphore?

No queue ordering

Could have starvation

22
New cards

What is a binary semaphore?

Only two values, equally powerful as a general semaphore

Like a flag

23
New cards

What is a counting semaphore?

A general semaphore with n values

24
New cards

How does a semaphore behave?

No way of knowing before a process calls wait if it’ll block or not

When both processes continue running concurrently after a signal, no way to know which will actually run next on a uniprocessor system

Signal might not actually awaken another process/processes

25
New cards

To allow s processes into a critical section

Initialize the semaphore value to that number

26
New cards

Value of a semaphore s: s > 0

s processes may wait WITHOUT delay

27
New cards

Value of a semaphore s: s = 0

no processes waiting

28
New cards

Value of a semaphore s: s < 0

s processes are suspended waiting on s

29
New cards

What is the finite buffer solution?

Can be constructed by adding a semaphore to keep track of the buffer size

30
New cards

How do monitors compare to semaphores?

Equivalent to semaphores but easier to control

31
New cards

What are the chief characteristics of a monitor?

Local data variables accessible on by monitor

Process enters monitor invoking one of its procedures

Only one process may be executing in monitor, others suspended waiting for monitor to be available

32
New cards

What are condition variables?

Monitors use them for synchronization:

  • cwait(c) - suspend execution of process calling condition c, monitor available for others

    • csignal(c) - resume exec of some process blocked after a cwait on c. if many, choose one, if none, do nothing

33
New cards

How does a csignal differ from a semaphore signal?

The signal is lost if no one is waiting

34
New cards

What are two requirements for processes that have interact?

Synchronization (for mutual exclusion)

Communication (to exchange information)

35
New cards

What environment does message passing work well in?

Distributed

36
New cards

What are basic message passing commands?

send (destination, message)

receive (source, message)

37
New cards

What are the three combinations of sender and receiver?

Blocking send, blocking receive

Nonblocking send, blocking receive

Nonblocking send, nonblocking receive

38
New cards

Blocking send, blocking receive

Both sender and receiver are blocked until message is delivered

Called a “rendezvous”

39
New cards

Nonblocking send, blocking receive

Sender continues processing such as sending messages as quickly as possible

Receiver is blocked until the requested message arrives

40
New cards

Nonblocking send, nonblocking receive

Neither party is required to wait

41
New cards

Message addressing, direct

specify destination process

42
New cards

Message addressing, indirect

send to mailbox and let receiving process/es pick up whenever ready (flexibility)

43
New cards

What is a deadlock?

Permanent blocking of a set of processes either competing or communicating

Conflicting need for resources

No efficient solution

44
New cards

What are the categories for resources?

Reusable, consumable

45
New cards

Reusable resources

used by one process at a time and is not consumer, ex: a process

46
New cards

Consumable resources

can be created and destroyed, ex: a message

47
New cards

What is a resource allocation graph?

Directed graph that depicts state of the system resources and processes

48
New cards

What are the required conditions for a deadlock?

Mutual exclusion

Hold and wait

No preemption

Circular wait

49
New cards

Mutual exclusion

only one process may use resource at a time

50
New cards

Hold and wait

a process may hold allocated resources while awaiting assignment of other resources

51
New cards

No preemption

no resource can be forcibly removed from a process holding it

52
New cards

Circular wait

a closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain

53
New cards

What are the general approaches to dealing with a deadlock?

Prevention

Avoidance

Detection

54
New cards

Deadlock prevention approaches

Indirect: prevent one of the three preconditions

Direct: prevent the fourth conditions

55
New cards

Deadlock prevention: Mutual exclusion

Difficult since required sometimes

56
New cards

Deadlock prevention: hold and wait

Make processes request all resources at once and blocking until resources can be granted simultaneously

57
New cards

Drawbacks to hold and wait prevention

  • process may have to wait a long time for all resources to be free

  • process may keep resources for a long time and deny it to other processes

  • process may not know in advance what resources it needs

58
New cards

Deadlock prevention: no preemption

Two possibilities:
- if process holding resources can’t get one it needs, release the ones it has an request all again

- if a process needs resource held by another, preempt the process to make it release resources. this requires resources whose state can be saved and restored, such as the processor

59
New cards

Deadlock prevention: circular wait

Require ordering of resource requests, prevents a circle by having requests in forward order, so a process can’t acquire a resource then request one prior to it which another process may hold

May not be efficient

60
New cards

What is deadlock avoidance?

Similar to prevention

Allows the three preconditions but tries to prevent deadlock dynamically as resource requests are made

Allows more concurrency than prevention

Requieres knowledge of future resource request

61
New cards

What are the approaches to deadlock avoidance?

Process initiation denial - constrains whether new process allowed to run

Resource allocation denial - lets a process run but constrains whether its resource requests are granted

62
New cards

Deadlock avoidance: process initiation denial

Process declares max need for each resource

Process only allowed to start if max claim of all current processes + max claim of new process can be met

Doesn’t work well, assumes that all processes will make max resource req at same time, which keeps processes from starting that would have run successfully

63
New cards

Deadlock avoidance: resource allocation denial

An algorithm for this is the “Banker’s Algorithm” a term used by Dijkstra to compare processes + resources to bank reserves + loans

64
New cards

Banker’s Algorithm

Defines state of system as either safe or unsafe

Works by determining if the system would be safe if the resource is granted. Yes, grant. No, block until safe

65
New cards

What is a safe state in the Banker’s Algorithm?

in which a sequence of allocations exists NOT leading to deadlock

66
New cards

What is a unsafe state in the Banker’s Algorithm?

in which there is NO sequence of allocations that will avoid deadlock

67
New cards

What is the claim matrix in the Banker’s Algorithm?

requirement of each process for each resource

68
New cards

What is the allocation matrix in the Banker’s Algorithm?

current allocation to each process of each resource

69
New cards

What is the resource vector in the Banker’s Algorithm?

total amount of each resource in the system

70
New cards

What is the available vector in the Banker’s Algorithm?

total amount of each resource not allocated to any process

71
New cards

Advantages of deadlock avoidance

Less restrictive than deadlock prevention

Not necessary to preempt and rollback processes as in deadlock detection

72
New cards

Disadvantages of deadlock avoidance

Max resources must be known in advance

Process ordering must be independent (not constrained by process synch)

Must be fixed number of resources

Processes can’t exit while holding resources

73
New cards

What is deadlock detection?

Detects deadlocks and takes action if they occur

Performs algorithm periodically to detect deadlock

Uses allocation matrix and available vector as in Banker’s Algorithm

Request matrix states amount of resources being requested by each process

74
New cards

What is the deadlock detection algorithm?

1. Mark each process that has a row in the allocation of all zeroes (holds no resources)

2. For each remaining process, see it is resource requests can be met by the current available resources

3. Mark all such rows and temporarily add their current allocation to the available list

If there are unmarked processes at the end of these steps, then these processes are deadlocked

75
New cards

In deadlock detection, how can recovery work?

Abort all deadlocked processes: most common

Back up each deadlocked process to previous checkpoint and restart all processes: could result in same deadlock

Continue aborting deadlocked processes one by one until deadlock resolved: abortion order should be intelligent

Successively preempt resources until deadlock is resolved: choices should be intelligent

76
New cards

Deadlock detection recovery intelligent process choice criteria

Least CPU time so far

Least output so far

Most estimated remaining runtime

Least total resources allocated so far

Least priority

77
New cards

What are the requirements for memory management?

Relocation

Protection

Sharing

Location organization

Physical organization

78
New cards

Memory management: relocation

In multiprogramming systems, program may be loaded into any free area of memory. can be swapped in and out of memory.

Difficult to load back into same memory location

Don’t know in advance where a program will load

79
New cards

Memory management: protection

Memory references each process makes must be checked to ensure they’re allowed

Memory references (like array positions) can be computed dynamically, cant be known in advance

Memory refs checked at run time by hardware

Impossible for OS since each program instruction must be checked

80
New cards

Memory management: sharing

2+ processes may be running same program, so we may want to let them SHARE program code

2+ processes may be working on the same data, so we may want to let them SHARE some memory for data

Protection must allow flexibility for sharing memory

81
New cards

Memory management: logical organization

Memory organized as linear address space

Programs consist of a number of pieces, modules, which have diff attributes like read only

Memory segmentation helps support use of modules

82
New cards

What are some advantages of logical organization of memory management if the system effectively deals with modules?

Modules can be written and compiled independently

Modules can be given diff degrees of protection (read only, exec only, etc)

Modules may be shared among processes

83
New cards

Memory management: physical organization

Memory organized as main memory and secondary storage (disk)

Difficult for programmer to manage moving the program between both environments as it runs

Best to let the memory management system manage moving processes between two types of memory

84
New cards

What is memory partitioning?

Putting memory into regions of fixed boundaries which can be equally or differently sized

85
New cards

What are the problems of equal-sized partitions?

Program may be too large, which is combatted by using overlays, where the program loads pieces of itself overlaying others.

Memory utilization is poor, since small programs occupy a large space (internal fragmentation)

86
New cards

How does unequal-sized partitions solve the problems from equal-sized partitions?

Small programs can be loaded into small regions and large programs can be loaded into large regions to avoid the need for overlays

87
New cards

How does the placement algorithm work?

A single queue is used for all partitions, and a program is assigned to the smallest open partition that holds it

88
New cards

What are the advantages and disadvantages of fixed partitions?

Number of partitions limit the number of active processes

Utilization not as good since it’s likely that part of a partition goes unused

89
New cards

What is dynamic partitioning?

Process given a region exactly as big as required

Size of region set dynamically as each program is loaded

However, this can cause “external fragmentation”

90
New cards

How can external fragmentation be dealt with?

A technique called compaction

91
New cards

What is compaction?

Shifts processes around in memory so there aren’t holes between them

However, this can be time consuming

92
New cards

What are the 3 different placement algorithms for dynamic partitioning?

Best-fit, first-fit, next-fit

93
New cards

What is the best-fit placement algorithm for dynamic partitioning?

Chooses partition closest in size to the process, often the worst because it causes smallest fragments which are unusable by other processes

94
New cards

What is the first-fit placement algorithm for dynamic partitioning?

Chooses first available partition from the beginning of memory that is large enough to hold the process, often the simplest, fastest, and best

95
New cards

What is the next-fit placement algorithm for dynamic partitioning?

Chooses next available partition beginning at previously chosen partition of memory that is large enough to hold the process, though it tends to fragment the end block of memory more than first-fit

96
New cards

What is the buddy system?

A system that divides memory blocks in half until a block that satisfies the request is found

When a divided block is freed, it can be combined to form the original block size

97
New cards

Why wont physical addressing work in equal and unequal partitions + dynamic partitioning?

When processes are swapped in and out of memory, they may be loaded back into different areas and are therefore RELOCATED

98
New cards

What are types of addresses?

Physical address

Logical addressW

99
New cards

What is physical address?

actual memory address, absolute address

100
New cards

What is logical address?

Address from pov of program, independent of current loaded position

Relative address: logical relative to a known point (ie the beginning)

Explore top flashcards

Finska
Updated 1060d ago
flashcards Flashcards (127)
unit 6: long island
Updated 770d ago
flashcards Flashcards (25)
Derm E1: Intro
Updated 432d ago
flashcards Flashcards (75)
Finska
Updated 1060d ago
flashcards Flashcards (127)
unit 6: long island
Updated 770d ago
flashcards Flashcards (25)
Derm E1: Intro
Updated 432d ago
flashcards Flashcards (75)