Processes Flashcards

1
Q

What is a process?

A

A process is a program in execution. Requires CPU resources, memory, I/O, etc.

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

What is a program?

A

A program is a set of instructions for performing a specific task. Stored on disk

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

What is the difference between a process and a program?

A

A process is simply a program in execution.

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

A process will always be in any of these 5 states…

A

Born, Ready, Waiting, Running, Dead

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

What is a process control block?

A

A process control block, or PCB, is a block used to store information about a process.

A PCB contains information such as:
The process ID
The process state (its registers, including volatile data such as temporary calculations and its next instruction)
The process address space (space to store data about the process)
The process I/O (a point of access)

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

What is a process/context switch?

A

A context switch is the act of changing which process is active. A context switch is almost purely overhead.

In order to do this, the processor must first change the state of process A to waiting, save the context of process B, then change the state of process B to running.

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

What is the process address space?

A

The process address space is a method of encapsulation, used to isolate different processes from each other, so that each process has its own private memory that cannot be accessed by other processes.

The process address space consists of the stack, the heap, a data section for static data and a text section for code.

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

What is the stack?

A

The stack is a data structure known for its “Last In First Out” property. This means that the most recently added piece of data will be the first to be “popped” out.

The stack is used to manage the execution of a program and to provide a way for functions to communicate with each other and access local variables.

It does this by, for all intensive purposes, “stacking” each function call on top of eachother, to both isolate block-scope variables and to provide a means of returning to the previous function call when finished.

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

What is the heap?

A

The heap is a data structure typically located below the stack in the process address space and grows upward as more data is added to it.

The heap is used to store data that is not known beforehand or that may change during the execution of a program.

It is typically used to store data that is allocated dynamically, meaning that the memory is allocated at runtime as needed and is not part of the process’s static memory allocation.

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

What are the four system calls for a process? (Linux)

A

Fork
Creates a child process with a unique process ID, and a copy of the ‘parent’s’ address space and all data along with it.
(In modern operating systems, the parent and child share the process space instead)

Exec
Runs an executable file that overwrites the process’s address space with a new program.

Wait
The parent process is put in the “waiting” state until the child process has finished.

Exit
When done, the child process issues the “exit” system call, and the parent process resumes.

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

What is shared memory?
(Interprocess Communication)

A

Each process writes into a shared address space. Both processes must make system calls to make the shared memory address space available to both processes.

The processes themselves are now responsible for ensuring they are not writing to the same space in memory simultaneously.

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

What is message passing?
(Interprocess Communication)

A

Both processes send data into an agreed “mailbox” that is not part of either of their address spaces.

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

Shared memory vs Message passing

A

Shared memory is faster than message passing as only one system call is needed to share the memory.

However, message passing is better for small amounts of data as it avoids the complex issue of needing to set up shared memory.

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

What is a scheduling algorithm?

A

A scheduling algorithm is a method used to optimise the amount of time spent on each process.

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

What is the difference between a first-come-first-served and round-robin scheduling algorithm?

A

First come first served is an algorithm that prioritises the first processes to be added to the queue, based on their creation time.

Round robin does the exact same. However, round robin employs a time quantum, a fixed amount of time that each process has to complete, before it will be paused and replaced by another process. This ensures that each process gets an equal amount of CPU time.

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

What is a shortest process next scheduling algorithm?

A

Allocates priority to a process based on a predicted execution time. This may be preemptive (processes may be interrupted) or non-preemptive (processes may NOT be interrupted).

17
Q

What is multi-level queueing?

A

Multi-level queueing is a method that splits each process queue into multiple process queues for certain purposes (for example, interactive vs batch process queues).

Each queue will have its own type, priority and scheduling algorithm. Its scheduling algorithm will be chosen based on best suit for the job. For example, FCFS may be chosen for a batch process queue as batch processes contain no I/O (so no system calls).

18
Q

How may priority be given to certain queues in multi-level queueing?

A

Either by fixed-priority scheduling or time-slicing.

In fixed-priority scheduling, one queue is given constant priority over the other processes. However, in time-slicing, queues are simply given differing levels of CPU time.

19
Q

What are the two criteria for process scheduling, and what may each group prefer?

A

One set of criteria may be for scheduling processes for the sake of the user - user-oriented criteria. They may want to see a greater turnaround and response time, so that they do not have to wait for their process to be completed. We may, then, want to place their processes in a higher fixed-priority queue.

The other set of criteria may be for scheduling processes for the sake of the system - system-oriented criteria. This could be for reducing the amount of time the processor is busy, or for optimising the number of processes completed over time (throughput).