COP 4610 Exam 2 Wang

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

1/202

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.

203 Terms

1
New cards

Monitor

A lock + condition variables

2
New cards

Lock

provides mutual exclusion to shared data.

3
New cards
4
New cards

a lock provides two operations

5
New cards

-Acquire()

6
New cards

-Release()

7
New cards

Condition Variable

provides a queue for waiting threads inside a critical section

8
New cards
9
New cards

each conditional variable

10
New cards

-consists of a queue of threads

11
New cards

-Provides three operations

12
New cards

**wait()

13
New cards

**Signal()

14
New cards

**Broadcast()

15
New cards

Hoare vs. Mesa Monitors

Hoare Monitors (used in most textbooks)

16
New cards

-Signal() transfers the CPU directly to a waiting thread.

17
New cards
18
New cards

Mesa Monitors (used in most real operating systems)

19
New cards

-Signal() only puts a waiting thread on the scheduler's ready queue

20
New cards

-By the time the waken thread gets the CPU, the waiting condition may no longer be true and needs to be retested.

21
New cards

Semaphores VS Monitors

We can't quite implement monitors with semaphores.

22
New cards
23
New cards

Condition variables only work inside a lock

24
New cards

-using semaphores inside a lock may deadlock

25
New cards
26
New cards

Condition variables have no history, but semaphores have

27
New cards

-Signal() with an empty queue does nothing

28
New cards

**A subsequent Wait() will wait

29
New cards

-V() increments semaphore

30
New cards

**A subsequent P() will not wait

31
New cards

-Wait() will always wait

32
New cards

-P() might not wait

33
New cards

Deadlock

Occur when threads are waiting for resources with circular dependencies.

34
New cards
35
New cards

Deadlock implies starvation

36
New cards

Preemptable Resource

EX- CPU

37
New cards

can be resolved by reallocation of resources

38
New cards

Nonpreemptable Resource

A resource that cannot be taken away from its current owner without causing computation to fail

39
New cards

Starvation

a thread waits indefinitely

40
New cards

Checkpointing

taking snapshots of system states from time to time

41
New cards

Four Conditions for Deadlocks

limited access (lock-protected resources)

42
New cards
43
New cards

no preemption (if someone has the resource, it cannot be taken away)

44
New cards
45
New cards

wait while holding (holding a resource while requesting and waiting for the next resource)

46
New cards
47
New cards

circular chain of requests

48
New cards

Banker's Algorithm

-A thread states its maximum resource needs in advance.

49
New cards
50
New cards

-The OS allocates resource dynamically as needed. A thread waits if granting its request would lead to deadlocks.

51
New cards
52
New cards

-A request can be granted if some sequential ordering of threads is deadlock free.

53
New cards

Deadlock Recovery Techniques

  • Scan the resource allocation graph
54
New cards
55
New cards
  • Detect circular chains of requests
56
New cards
57
New cards
  • Recover from the deadlock
58
New cards

Interprocess Communication

Processes communicate among address spaces.

59
New cards

-Bug stream ex. pipe

60
New cards

-Message passing (send/receive)

61
New cards

-File system (read and write)

62
New cards

-Shared memory

63
New cards
64
New cards

Direct

65
New cards

-send(P1, message);

66
New cards

-receive(P2, message);

67
New cards

-One-to-one communication

68
New cards
69
New cards

Indirect

70
New cards

-Mailboxes or ports

71
New cards

-send(mailbox_A, message);

72
New cards

-receive(mailbox_A, message);

73
New cards

-Many-to-many communication

74
New cards

System Call

A user process asks the OS to do something on the process's behalf.

75
New cards

Hardware-Supported Mechanisms

Address translation

76
New cards

Dual-mode operation

77
New cards

Software-Supported Mechanisms

Strong Typing

78
New cards

Software Fault Isolation

79
New cards

Steps to switch between kernel and user spaces

-Creates a process and initialize the address space

80
New cards

-Loads the program into the memory

81
New cards

-Initializes translation tables

82
New cards

-Sets the HW pointer to the translation table

83
New cards

-Sets the CPU to user mode

84
New cards

-Jumps to the entry point of the program

85
New cards

Context switching between processes vs. threads

Unlike context switching among threads, to switch among processes

86
New cards

-Need to save and restore pointers to translation tables

87
New cards
88
New cards

To resume process execution

89
New cards

-Kernel reloads old register values

90
New cards

-Sets CPU to user mode

91
New cards

-Jumps to the old program counter

92
New cards

Segment

A logically contiguous memory region

93
New cards

External Fragmentation

memory wasted because the available memory is not contiguous for allocation

94
New cards

Internal Fragmentation

allocated pages are not fully used

95
New cards

Translation Lookaside Buffers

Store recently translated memory addresses for short-term reuses

96
New cards

base and bound translation

  • Each process is loaded into a contiguous region of physical memory
97
New cards
  • Processes are protected from one another
98
New cards
  • Each process "thinks* that it owns a dedicated machine, with memory addresses from 0 to bound.
99
New cards
  • An OS can move a process around
100
New cards

--By copying bits