OS Part 2 (Processes) Flashcards

1
Q

What is a process?

A

A program that is currently being executed.

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

What meta information does the process store about itself?

A

Processes store their own:
1. Unique Program Counter
2. Registers
3. Variables
4. Flow of Control

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

What is the general abstraction of a running program?

A
  1. A process is a program in execution.
  2. Many processes can run the same program text.
  3. Each process has its own address space (isolation).
  4. A (parent) process can create/fork (child) processes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens when a process is ran, and what happens when the processor switches to a different process?

A

The processes’ logical internal program counter gets copied into the physical program counter of the physical CPU.

When the process being ran switches, the current physical program counter gets stored in the memory of the process being suspended, whilst the process getting activated’s program counter gets moved from its own memory into the physical program counter.

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

How does the OS use the processor?

A

The OS decides how to correctly allocate processing time to each process currently being executed.

For example, long computations are are divided up into sections, and after each section the overall program’s execution is temporarily suspended to allow other processes to access the processor.

“Processing time” is how long a processor spends executing instructions needed by a process.

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

What does the OS do when a process is suspended?

A

Suspended processes must restart in exactly the same state they had before suspension.

The OS makes note of all the address spaces relevant to the process, referred to as the processes “Core Image”.

It also maintains a “process table entry” for each process which records the information about the resources being used such as memory locations and open files.

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

What resources does the OS maintain for each process?

A
  1. Registers including program counter and stack pointer.
  2. Open files being used by the process.
  3. Outstanding alarms, and a list of related processes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does OSs keep processes separate?

A

The OS allocates each process a private address space which is isolated from other processes.

Each process can typically read and write from the following memory locations:

  1. Executable Program Text
  2. Program Data
  3. The Stack (one frame per active procedure or function)
  4. Dynamically Allocated Memory
  5. The Runtime Environment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the “Stack”?

A

Memory location that is automatically managed by the OS.

OS only keeps objects in memory for the scope they are needed, and removes them once they are no longer needed.

The maximum size of the stack is known at compile time, however its usage is likely to depend on runtime from its execution trace.

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

What is the “Heap”?

A

Memory location that is “dynamically allocated”.

Memory calls are made by the programmer as memory is allocated in-line with what their code defines.

Is more error-prone and costly as programmers are typically less efficient at managing memory than the OS is.

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

What is a process’ “lifecycle”?

A

A selection of states a process can be in throughout its lifespan, managed by the OS.

In embedded systems such as a microwave, all processes are created on startup.

On more complicated systems, processes must be created and terminated when they are needed to use resources efficiently.

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

What are the main process creation events?

A
  1. System Initialisation
    Many processes are needed directly on start-up. These can be foreground processes such as a user interface, or background processes such as driver managers and daemons.
  2. Task Creation Processes
    Larger processes might require the help of several smaller processes to complete one task. A process might be created as a result of being needed in such a scenario.
  3. User Creation
    Process is created due to user clicking on an icon or entering a command.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why might a process be terminated?

A

A process can be terminated voluntarily, or involuntarily.

Examples of voluntary termination would be:
1. Normal exit (process reached end of instructions)
2. Error exit (process encountered handled error, and exited)

Examples of involuntary termination would be:
1. Fatal error (process encountered an error it could not mitigate and crashed)
2. Killed by another process (shut down by task manger)

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

What states can a process be in?

A
  1. Ready (From ready, can go to Running)
  2. Running (From running, can go back to Ready, or become Blocked)
  3. Blocked (From blocked can go to ready)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly