Proccess Management Flashcards

1
Q

Define a program

A

A program is a set of instructions for performing a specific task (passive), and is stored on disk.

when you run it, it is a program associated with a process

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

What is a process

A

A process is a program in execution (active), and requires CPU resources, primary memory, and I/O.

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

By organising a computer system into processes we achieve what

A

both modularity (we can switch between them) and improved performance (allowing us to improve performance).

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

What happens in the NEW state of a process lifecycle?

A

The process is created and enters the system. It awaits admission to the READY state.

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

What happens in the READY state?

A

The process is prepared to run and waits to be dispatched to the CPU.

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

What happens in the RUNNING state?

A

The process is actively executing on the CPU.

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

When does a process move to the WAITING state?

A

A process moves to the WAITING state when it begins I/O operations and waits for I/O to complete.

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

When does a process enter the TERMINATED state?

A

The process enters the TERMINATED state when it finishes execution and exits.

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

What is the transition from READY to RUNNING called?

A

The transition is called dispatch, where the CPU scheduler selects a process to run.

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

What happens when a process is paused during execution?

A

The process transitions from RUNNING back to READY if it’s preempted (e.g., by a higher-priority process).

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

What happens when a process starts an I/O operation?

A

The process moves from RUNNING to WAITING.

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

What happens when a process completes its I/O operation?

A

The process transitions from WAITING to READY.

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

What determines the transfer between READY and RUNNING states?

A

The transfer depends on processor scheduling, which prioritises processes based on their assigned priority.

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

What is a process control block

A

A Process Control Block (PCB) is a data structure maintained by the operating system to store information about a process. It is used to manage processes during execution.

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

What are the components of the process control block

A
  • Process number
  • Process state
  • process address space
  • process I/O
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where is the process control block stored

A

in the memory or on the disk

17
Q

How to stop running process A and start process B:

A
  1. change the process scheduling state of process A
  2. save the context of process A
  3. load the context of process B
  4. change the process scheduling state of process B
18
Q

What is a context switch

A

when the CPU switches from running one process to another.

19
Q

What is the tradeoff of context switches

A

Too few switches lead to poor responsiveness (as it is never actually running the task rather just moving data), while too many switches increase overhead, reducing efficiency.

20
Q

What 4 sections does a process address space have

A
  • a stack for temporary data
  • a heap for dynamically-allocated data
  • a data for static data
  • a text for program code
21
Q

How does a stack work

A

When a function is called, temporary variables are added to the top of the stack. When exiting a function, these variables are removed from the top of the stack.

22
Q

How does a heap work

A

In the heap, blocks of memory are allocated and removed in an arbitrary order. The heap is used for variables that need to persist beyond the scope of a single function or need a flexible amount of memory.

23
Q

What is the issue with stack and heap in address space

A

The stack grows downwards while the heap grows upwards thus they could collide so its up to the OS to stop this by providing more address space

24
Q

What is process calling

A

A process is created at the request of a different process. In Linux there are four system calls for process spawning.

25
Q

In process spawning, what is the relationship between a parent and child process?

A

The parent process creates a child process. The child process can execute the same code as the parent or replace its code with a new program using exec.

26
Q

What system call is commonly used to create a new process in Linux?

A

The fork system call is commonly used to create a new process.

27
Q

What happens when fork is called?

A

fork creates a child process that is a copy of the parent process, with its own process ID and address space.

28
Q

What are the return values of fork?

A

The parent process receives the child’s process ID as the return value of fork.

The child process receives 0 as the return value.

29
Q

How can a child process run a different program after fork?

A

The child process can replace its code with a new program using the exec system call.

30
Q

What does the exec system call allow for

A

The exec system call allows a process to replace its current program with a new executable file.

31
Q

What does the wait system call do

A

The wait system call causes the parent process to pause execution until the child process completes.

32
Q

What does the exit system call do

A

The exit system call is issued by the child process when it finishes its task.

33
Q

How may Interprocess communication be implemented

A

either using:
- shared memory
- or message passing

34
Q

What is interprocess communication by shared memory

A

involves processes writing data to/reading data from from an agreed area of memory.

35
Q

What is interprocess communication by message passing

A

involves processes sending messages to/receiving messages from an agreed mailbox.

36
Q

Shared Memory vs message passing

A

Message passing requires regular system calls, while shared memory only requires system calls to set up the shared memory space. As a result, shared memory is generally more efficient for large data transfers, whereas message passing is better suited for smaller data exchanges.

37
Q

When does a process move into the running state

A

When the schedueler decides to exeter the program it move to the running state.