Week 2 Flashcards

1
Q

Process creation

A

A parent will create a child process and will then have control over child. E.g. Unix kernel finds init process, starts system boot, daemon processes, and terminal login processes.

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

Process Termination

A

Process asks OS to system exit or parent terminates child process. The processes resources are then removed.

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

Cooperating processes

A

Dependent upon other processes and have to communicate accordingly

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

Producer - Consumer

A

Producer generates information that will be consumed by the consumer. Process can have a bounded or unbounded buffer.

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

Interprocess Communication

A

Mechanism for processes to communicate and synchronize (direct and indirect)

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

Direct Communication

A

Processes explicitly identifies who is sending and where it is being sent. Addressing can be asymmetric, meaning they can receive from anyone by must specify who they send to

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

Mailboxes

A

Processes share a mailbox (port), which is where messages will be sent. Disadvantages: Sharing mailbox isn’t efficient.

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

Blocking synchronization

A

Synchronous message sender. Both processes must wait until the exchange is made.

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

Rendez-vous

A

Both sender and receiver are blocking. Blocker is zero capacity.

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

Non-Blocking synchronization

A

Sender can drop into buffer until receiver is ready and vice versa.

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

Bounded vs unbounded buffer

A

Bounded buffer may need to wait or abandon messages. Unbounded is very resource heavy.

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

Thread

A

Lightweight process, essentially one part of an existing process. Contains a unique stack, thread ID, and registers but shares code, memory, files, and other resources with other threads.

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

Benefits of threads

A

Less overhead on context switching. Can run on multiple CPUs. Helps responsiveness, resource sharing, faster thread creation.

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

What happen when a thread terminates

A

Rejoins main thread

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

Examples of threads

A

Games (NPCs), Web browser (tabs)

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

User Threads

A

Threads are implemented by a library. OS is not thread aware. Cooperative multitasking means there’s no interrupt when switching threads. Earliest version of threads. Process schedules threads on CPU.

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

User Thread advantages

A

Fast, don’t require system calls to switch, simple scheduling

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

User thread Disadvantages

A

No multi-processor support. When a thread is blocked, all threads are blocked.

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

Setup of user kernel

A

File and devices are manage by OS. Thread control blocks are put in data segment because OS isn’t aware of them. Stack pointers are allocated in heap or in unallocated space.

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

Kernel thread

A

Os aware thread. Os does scheduling for this thread. System calls are required to create new threads.

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

Kernel thread advantages

A

Can run a process on multiple cores. OS will block only singular threads.

18
Q

Kernel thread disadvantages

A

Not as fast, more resource intensive

19
Q

Kernel thread implementation

A

OS assigns stack to unallocated space automatically. Thread control blocks stored in memory.

20
Q

Many-to-one implementation

A

User level thread. OS sees one process but programmer sees multiple threads.

21
Q

One-to-One

A

Kernel threads. OS sees every thread that exists.

22
Q

Thread pool

A

Pool of threads OS is aware of. At the user level, there are more threads than supported. Library will manage which threads are mapped.

23
Q

Thread Pool Pattern

A

Taking blocks like loops and putting each independent iteration into a thread.

24
Q

Creating kernel threads

A

Fork and Clone

25
Q

Fork

A

System call to start another process. Returns the Child PID to the parent and 0 to the child. Makes a deep copy of the PCB and returns a separate copy. Two independent shells are now running.

26
Q

Clone

A

System to start another process. Makes a shallow copy of the current running thread. New PCB but both point to same data, file information, etc.

27
Q

Java threads

A

Part of the language. Extends the thread class and implements the runnable interface.

28
Q

Race condition

A

Final value of a shared resource depending on the order in which code executes.

29
Q

Critical section

A

Block of code where a shared resource is changed or manipulated.

30
Q

Breakdown of critical section

A

Entry: Acquire access to the shared resource. Critical Section: Modify shared variable. Exit: exit the critical section. Remainder: Code post critical section.

31
Q

Criteria for critical section

A

Mutual exclusion, progress, bounded wait

32
Q

Mutual exclusion

A

One process in a critical section at a time

33
Q

Progress

A
  • If there is no process in cs, a waiting process is let in. Essential that you can’t just lock out and have no one in the critical section
34
Q

Bounded wait

A

Equitable sharing between processes

35
Q

Peterson’s model

A

Model only works for two processes and contains a shared variable initialized at zero. While loop until turn becomes the appropriate number, enters the cs, then makes turn the second number and exits.

36
Q

CS criteria and Peterson’s model

A

Satisfies mutual exclusion and bounded wait. Doesn’t satisfy progress as P0 hitting an infinite loop in the remainder will halt progress.

37
Q

Peterson’s model 2

A

Model still works for 2 processes and contains a shared variable Boolean array called flag. Set your flag to true when entering code. Infinite while loop while the other program’s flag is true. Enter cs once its false. Set appropriate flag to false and enter remainder section.

38
Q

Issue with Peterson’s model 2

A

If an interrupt occurs during entry section both sections can be set to true and no one can enter cs, failing progress.

39
Q

Petersons complete algorithm

A

Model works with 2 processes and contains a shared integer set to zero and a Boolean array set to false. Infinite wait while other processes flag is true and turn is set to other process. Turn will break the tie if both flags are true.

40
Q

Test and Set

A

Guaranteed by hardware to be atomic. Lock set to false. Processes will swap their true value with the lock value until they receive false in their register. At this time they have the key and can be let into the critical section. Once done, they will set the lock back to false.

41
Q

Atomic instruction

A

Cannot be interrupted

42
Q

Test and set cs constraints

A

Satisfies progress and mutual exclusion. Doesn’t satisfy bounded wait because the same process can get the lock over and over.

43
Q

Test and set with bounded wait

A

Same concept as test and set. When exiting critical section, we look to the next process in the queues and give them the key. If there’s no one in line, set lock back to false.

44
Q

Problems with test and set bounded wait

A

If an interrupt occurs when checking wait queue and process that was already checked goes to wait queue. Sol: Keep going until a waiting process is found or get to yourself and release the lock.

45
Q

Busy waiting

A

Cycles of processes on wait

46
Q

Semaphore solution

A

Integer value and two atomic operations: wait and signal. If semaphore is greater than 1, you can enter the critical section. Once semaphore hits zero, the process gets put to sleep. When the process leaves the critical section, it increments the semaphore.

47
Q

Semaphore with bounded wait

A

semaphore is contained within struct that has a queue. During wait and signal, the program will put or remove processes from the wait queue in the order they were added.