CS6200 Flashcards

1
Q

What is an operating system?

A

A special piece of software that abstracts and arbitrates the use of a computer system.

It’s a layer of systems software that:
* directly has privileged access to the underlying hardware
* hides the hardware complexity
* manages hardware on behalf of one or more applications according to some predefined policies
* in addition, it ensures that applications are isolated and protected from one another

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

____ operates in kernel mode to access underlying hardware.

A

The operating system

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

____ operates in user level mode

A

Application software

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

T/F? kernel-level mode and user-level mode are supported by hardware

A

True

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

Attempts to directly access hardware by software running in user-level mode can activate a ____ which interrupts the program and hands control to the OS to determine if it should get access

A

trap

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

Applications can use _____ to interact with underlying hardware

A

System calls

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

T/F? User/Kernel transitions have a negligent impact on the performance of applications

A

No, it can have an impact on cache hit frequency after the transition

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

What are some benefits of a monolithic OS?

A

* Everything is included
* You can use inlining and compile-time optimizations

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

What are some drawbacks of a Monolithic OS?

A

* customization is harder
* portability is harder
* manageability is harder
* larger memory footprint
* harder to optimize performance for different use cases (e.g. using different file systems for different access patterns)

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

Is linux a monolithic, modular, or microkernel os?

A

Modular

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

What are benefits of a modular OS?

A

* Easier to maintain and upgrade
* Smaller footprint
* Less resource needs

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

What are the drawbacks of a modular OS?

A

* indirection can impact performance
* maintenance can still be an issue, because modules can introduce bugs

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

In a microkernel, system services like the filesystem and disk driver run in ____ level

A

User level (as opposed to privileged)

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

What are the benefits of a microkernel?

A

* Small size
* Easy to verify because it’s small

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

What are the downsides of a microkernel?

A

* Poor portability, typically customized for target hardware
* More complex to develop software for
* Cost of user/kernel transitions

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

What is a process?

A

An executing program

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

What is the difference between an application and a process?

A

Application is a program on disk (static entity), whereas a process is a program that has been loaded in memory and is in the state of execution (active entity).

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

What does a process store in memory?

A
  • Stack
  • Heap
  • Data
  • Text
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is “address space”?

A

The “in memory” representation of a process.

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

What are “virtual addresses”?

A

The abstracted addresses used by a process.

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

What are “physical addresses”?

A

The actual physical locations in memory.

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

Where is the mapping of virtual addresses to physical addresses stored?

A

In the Page Table

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

How does an OS keep track of the state of a process?

A

Via the Process Control Block

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

A Process Control Block contains the state of CPU registers. Since register contents can change much faster than they can be updated in memory (where the PCB is stored), how does the OS make sure those are updated for later use?

A

By setting the values in the PCB when stopping the process on the CPU.

This is called a context switch.

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

What is a “context switch”?

A

Switching the CPU from the context of one process to the context of another.

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

Is a context switch computationally expensive?

A

Yes. It takes CPU cycles to store the old context and load the new one, and caches on the CPU become invalid for the new process.

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

What states can a process be in?

A
  • New
  • Ready
  • Running
  • Waiting
    • Terminated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What state does a process start in?

A

New

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

What state does a process end in?

A

Terminated

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

How does a process transition from New to Ready state?

A

Admitted

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

How does a process transition from Ready to Running state?

A

A scheduler dispatch

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

How does a process transition from Running to Ready state?

A

An interrupt

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

How does a process transition from Running to Waiting state?

A

I/O or event wait

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

How does a process transition from Waiting to Ready state?

A

I/O or event completion

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

How does a process transition from Running to Terminated state?

A

It Exits

36
Q

The CPU is able to execute a process when it is in which states?

A

Running or Ready

37
Q

How are new processes created?

A

They are spawned by a parent process (via fork or exec)

38
Q

What is the “fork” mechanism for process creation?

A

Copying the parent Process Control Block into the new child PCB, where the child continues execution at the instruction after the fork.

39
Q

What is the “exec” mechanism for process creation?

A

Creates a new process control block, loads a new program, and starts from the first instruction.

40
Q

On unix-based OS, which process is “the parent of all processes”?

A

init

41
Q

On Android, which process is “the parent of all app processes”?

A

ZYGOTE

42
Q

What is the role of the CPU scheduler?

A

It determines which one of the currently running processes will be dispatched to the CPU to start running, and how long it should run for.

43
Q

In the context of process scheduling, an OS can “preempt”. What does that mean?

A

It can interrupt and save current context

44
Q

In the context of process scheduling, an OS can “schedule”. What does that mean?

A

It can run the scheduler to choose the next process

45
Q

In the context of process scheduling, an OS can “dispatch”. What does that mean?

A

It can dispatch the process and switch into its context

46
Q

If a process scheduler is run more frequently, ___ goes down.

A

Useful CPU work

Useful CPU work = non-scheduler Processing Time / Total Time

47
Q

In the context of process scheduling, what is “timeslice”?

A

Time allocated to a process on the CPU

48
Q

What are some ways a process can end up on the ready queue?

A
  • I/O request
  • Time slice expired
  • Fork a child
    • Wait for an interrupt
49
Q

What do Inter-Process Communication (IPC) mechanisms do?

A
  • Transfer data/info between address spaces
  • Maintain protection and isolation
    • Provide flexibility and performance
50
Q

What is message-passing IPC (interprocess communication)?

A

OS manages a messaging channel, which process can write to and read from.

51
Q

What is the shared memory IPC (interprocess communcation) mechanism?

A
  • OS sets up a shared memory channel, and maps it into each process address space
52
Q

What advantage does shared memory IPC have over message passing IPC?

A

Less overhead, OS is out of the way

53
Q

What is the advantage of message-processing IPC over shared memory IPC?

A

How to use the shared memory isn’t defined by the OS, so it becomes easier to write a bug in code that uses it, and that code might have to be duplicated between different applications.

54
Q

If we want a process to be able to execute on multiple CPUs, we must use ____

A

Threads

55
Q

Do threads have the same virtual→physical memory mapping? (shared page tables)

A

Yes

56
Q

What benefits do threads provide?

A
  • Parallelization
    • Specialization - can dedicate threads to specific tasks, CPU cache can maintain more valid entries in each core, and prioritization can be used
57
Q

Why use threads rather than just having different processes?

A

Less overhead. We don’t have to allocate memory for each thread. Communication between processes is more complicated.

58
Q

Are threads useful on a single CPU?

A

Yes. It can work on another thread during long I/O operations.

59
Q

When two threads try to access the same memory value at once, it is a ____ ____ problem

A

data race

60
Q

____ ____ ensures that only one thread has access to a memory value at a time

A

mutual exclusion

61
Q

When one thread is waiting on a specific condition to proceed, and will be notified by another thread, it is using a ____ ____

A

condition variable

62
Q

Condition Variables and Mutex are both ____ mechanisms

A

synchronization

63
Q

In Birrell’s paper, what call is used to create a new thread?

A

fork(proc, args)

64
Q

In Birrell’s paper, what do the params to fork(proc, args) mean?

A

proc = program counter

args = input parameters

65
Q

In Birrell’s paper, what call is used to terminate a thread?

A

join(thread)

66
Q

In Birrell’s paper, what does join(c_thread) do?

A

It blocks the calling thread until child thread “c_thread” finishes

67
Q

If a thread cannot acquire a mutex, it is ____

A

blocked

68
Q

In Birrell’s paper, a lock uses a mutex to prevent a ____ ____ from being executed by more than one thread at once.

A

Critical Section

69
Q

In the context of threads, what is a “spurious wakeup”?

A

When a thread is woken up, but it still cannot proceed.

70
Q

In the context of threads, what is a deadlock?

A

Two or more competing threads are waiting on each other to complete, but none of them ever do.

71
Q

In the context of threads, it prevents ____ ____ to maintain the same order in which mutexes are locked.

A

Dead lock

72
Q

What are the possible ways of dealing with deadlocks?

A
  • Prevention - maintain a lock order - expensive, can limit performance
  • Rollback - Return to an execution state before the deadlock - not always possible, also can be expensive
    • Do nothing - just reboot the software if one occurs
73
Q

What are the benefits of the one-to-one model of kernel and user threads?

A

OS sees/understands threads, synchronization, blocking…

74
Q

What are the drawbacks of the one-to-one model of kernel and user threads?

A

Must go to kernel space for all operations (which has a cost)

OS may have limits on policies and thread count

Since thread management happens at the kernel level, it can affect portability of apps between different OS

75
Q

In the many-to-one model of user/kernel threads, which user-level thread is mapped to the kernel level thread is managed at the ____ level

A

user

76
Q

What are the benefits of the many-to-one model of user/kernel threads?

A

Easy to port apps – they don’t depend on OS specific limits or policies

77
Q

What are the drawbacks of the many-to-one model of user/kernel threads?

A

OS has no insights into application needs

OS may block entire process if one user-level thread blocks on I/O

78
Q

What are bound/unbound threads in the context of the many-to-many model of user/kernel threads?

A

Bound user threads are associated to just one kernel thread

79
Q

What are the benefits of the many-to-many model of user/kernel threads?

A

Can avoid problems of one-to-one or many-to-one

80
Q

What are the drawbacks of the many-to-many model of user/kernel threads?

A

Requires coordination between user and kernel level thread managers

81
Q

What is the boss-workers thread pattern?

A

Boss assigns work, workers perform the tasks

82
Q

In the boss-worker thread pattern, how does the boss assign tasks to the workers?

A

Generally with a queue. Although it requires synchronization among the workers to avoid picking up the same task, it has less of a performance impact than using the boss process to keep track of which workers are busy.

83
Q

What are some benefits of specialized workers in the boss-worker thread pattern?

A

Better locality – more cache hits

QoS management is possible

84
Q

What is the pipeline thread pattern?

A

Threads assigned one subtask

Entire tasks are pipelines of subtask threads

Multiple tasks can go through the pipeline at different stages

85
Q

What is the layered thread pattern?

A

Layers are groups of related subtasks

end-to-end task must pass through all the layers

Like pipeline, but not linear – some threadpools can handle multiple subtasks