Week 5 - Operating System Fundamentals (Part 3) Flashcards

Process Management (78 cards)

1
Q

What is the difference between a program and a process?

A
  • A program is a passive entity, stored on disk (executable file).
  • A process is an active entity that is created when the program is loaded into memory and executed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can one program have multiple processes?

A

Yes, a single program can have multiple processes, especially if multiple users are running the same program.

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

What triggers the execution of a program as a process?

A

Execution can be triggered via:

  • GUI mouse clicks
  • Command line entry of the program’s name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does the process concept work in terms of program execution?

A
  • A process represents a program in execution.
  • Each process has its own address space, memory, and resources.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the three basic components of Process Representation?

A
  1. Executable Program Code
  2. Data related to the Program
  3. Execution Context (includes Process ID, Group ID, User ID, etc.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is included in the execution context of a process?

A
  • Process ID, Group ID, User ID
  • Stack Pointer, Program Counter, CPU Registers
  • File Descriptors, Locks, Network Sockets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is the execution context essential for process switching?

A

The execution context contains crucial data that allows the OS to save and restore the state of a process during a context switch.

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

What does a process consist of besides the program code (text section)?

A
  • Current activity (program counter, processor’s registers)
  • Process stack (temporary data like function parameters, return addresses, local variables)
  • Data section (global variables)
  • Heap (dynamically allocated memory during runtime)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is stored in the process stack?

A
  • Temporary data such as function parameters, return addresses, and local variables.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is stored in the data section of a process?

A

Global variables.

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

What is the purpose of the heap in process structure?

A

The heap is used for memory dynamically allocated during the process’s runtime.

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

What is the “process image”?

A

The layout of a process in memory.

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

What is stored in the Stack Segment of a process?

A

Function calls and related data (such as local variables and return addresses).

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

What is stored in the Data Segment of a process?

A

Static variables, constants, and dynamic memory allocation from the heap.

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

What is contained in the Text Segment of a process

A

The program code, which is shared between processes.

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

What happens when a program is invoked in terms of process creation?

A

It results in the creation of a separate process, each with its own process image.

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

How does each process image appear to the system?

A

Each process image appears to “own” the complete address space.

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

How does each process image start at address 0?

A

Virtual to physical address mapping is required to achieve this.

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

What is a Process Control Block (PCB) also known as?

A

It is also called a Task Control Block (TCB).

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

What information is stored in a PCB?

A
  • Process state (running, waiting, etc.)
  • Program counter
  • CPU registers
  • CPU scheduling information
  • Memory-management information
  • Accounting information
  • I/O status information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is included under CPU scheduling information in a PCB?

A
  • Priorities
  • Scheduling queue pointers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does the accounting information in a PCB include?

A
  • CPU used
  • Clock time elapsed since start
  • Time limits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are the different Process States during execution?

A

The Process States during execution are:

  1. New: The process is being created.
  2. Ready: The process is waiting to be assigned to a processor.
  3. Running: Instructions are being executed.
  4. Waiting (Blocked): The process is waiting for some event to occur.
  5. Terminated (Exited): The process has finished execution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the main goal of process scheduling?

A

Maximize CPU use by quickly switching processes onto the CPU for time-sharing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Maximize CPU use by quickly switching processes onto the CPU for time-sharing.
- I/O request - After N units of time have elapsed (requires a timer)
25
What happens when a process gives up the CPU?
The process is added to the "ready queue."
26
How does the process scheduler work?
It selects among the available processes in the ready queue for the next execution on the CPU.
27
What is the job queue in process scheduling?
The job queue contains all processes in the system.
28
What does the ready queue contain in process scheduling?
The ready queue contains all processes residing in main memory, ready and waiting to execute.
29
What is the purpose of the device queues in process scheduling?
The device queues contain processes waiting for an I/O device.
30
How do processes move among scheduling queues?
Processes migrate among the various queues (job queue, ready queue, device queues) depending on their state.
31
What does a queuing diagram represent in process scheduling?
A queuing diagram represents queues, resources, and the flows between them.
32
What is the role of the short-term scheduler (CPU scheduler)?
- The short-term scheduler selects which process should be executed next and allocates the CPU. - It is invoked frequently (every few milliseconds) and must be fast.
33
What does the long-term scheduler (Job scheduler) do?
- The long-term scheduler selects which processes should be brought into the ready queue. - It is invoked infrequently (every few seconds or minutes) and controls the degree of multiprogramming.
34
What is an I/O-bound process?
- An I/O-bound process spends more time doing I/O operations than performing computations. - It has many short CPU bursts.
35
What is a CPU-bound process?
- A CPU-bound process spends more time performing computations than doing I/O operations. - It has few but very long CPU bursts.
36
What does the long-term scheduler strive for in terms of processes?
The long-term scheduler strives for a good mix of I/O-bound and CPU-bound processes to optimise system performance.
37
What is a context switch?
- A context switch occurs when the CPU switches to another process. - The system saves the state of the current process and loads the saved state of the new process. - The context of a process is stored in the Process Control Block (PCB).
38
What is the impact of context switch time on system performance?
- Context-switch time is considered overhead because the system does no useful work during the switch. - The more complex the OS and the PCB, the longer the context switch takes
39
How does hardware support affect context switching?
- Some hardware provides multiple sets of registers per CPU, allowing multiple contexts to be loaded simultaneously. - This can speed up the context-switch process.
40
What triggers a context switch in the case of a clock interrupt?
- A clock interrupt occurs after a specified time interval (usually 3-10ms). - The execution of the current process is interrupted, and control goes back to the OS. - The current process is added to the ready queue for later execution
41
Why is the frequency of clock interrupts important?
- The frequency of clock interrupts is a critical system parameter. - It balances the overhead of context switching with the responsiveness of the system. - A higher frequency can improve responsiveness but also increase overhead.
42
What triggers a context switch in the case of a clock interrupt?
- A clock interrupt occurs after a specified time interval (usually 3-10ms). - The execution of the current process is interrupted, and control goes back to the OS. - The current process is added to the ready queue for later execution.
43
Why is the frequency of clock interrupts important?
- The frequency of clock interrupts is a critical system parameter. - It balances the overhead of context switching with the responsiveness of the system. - A higher frequency can improve responsiveness but also increase overhead.
44
What happens during an I/O interrupt?
- I/O interrupt occurs when an I/O action is completed, and data is loaded into memory. - The currently executing process is interrupted. All blocked processes waiting for the I/O action to complete are moved into the ready queue. - The dispatcher must decide whether to continue executing the process that was interrupted or select another process from the ready queue.
45
What happens during a Memory fault / Page fault?
- The executing process refers to a virtual memory address that isn't mapped to a physical memory location (data is on disk). - The currently executing process (in the Running state) is interrupted. - An I/O request is issued to bring the required data from disk into memory. - The executing process is switched to the blocked state. - A different process is selected from the ready queue to continue execution. - Once the data is loaded into memory, the blocked process moves back to the ready queue.
46
What does a Dispatcher in an OS do?
A dispatcher allocates the CPU to processes and switches the CPU from one process to another.
47
What is the main weakness of the Dispatcher in an OS?
The weakness is when an event occurs, and all processes waiting for that event must be moved from the "Blocked" queue to the "Ready" queue. This requires scanning the entire "Blocked" queue, which can be inefficient if there are many processes waiting for different events.
48
What is swapping in an operating system?
Swapping is the process of moving a process from main memory to secondary memory when not all processes can fit into physical memory.
49
Why is swapping useful in an operating system?
Swapping helps reduce the degree of multiprogramming and allows the system to manage more processes than the physical memory can accommodate.
50
What two extra process states are needed for swapping?
The two extra process states for swapping are: 1. ready-suspended 2. blocked-suspended
51
What operations must the system provide for processes?
The system must provide mechanisms for: Process creation Process termination
52
When is a process created?
A process may be created in the following scenarios: - System boot - An existing process spawns a child process - User request to create a process - A batch system takes on the next job in line
53
How are processes related when created?
Parent processes create children processes, which may, in turn, create other processes, forming a tree of processes.
54
How are processes identified and managed?
Processes are identified and managed via a process identifier (pid).
55
What is the first step in process creation?
The first step is to assign a unique process identifier (PID) to the new process.
56
The first step is to assign a unique process identifier (PID) to the new process.
The second step is to allocate space for the process, including memory for the process image (program, data, stack).
57
What is done in the third step of process creation?
In the third step, the Process Control Block (PCB) is initialised.
58
What happens in the final step of process creation?
In the final step, the process is added to the Ready queue.
59
What are the options for resource sharing among parent and child processes?
The options are: 1. Parent and children share all resources 2. Children share a subset of parent's resources 3. Parent and child share no resources
60
What are the execution options when a parent creates a child process?
The options are: 1. Parent and children execute concurrently 2. Parent waits until children terminate
61
What are the address space options for child processes?
The options are: 1. Child is a duplicate of the parent address space 2. Child loads a new program into its address space
62
How does a process create new processes under UNIX?
A process creates new processes using the kernel system calls fork() and exec().
63
What happens when a process creates a new process under UNIX?
1. A new slot in the process table is allocated. 2. A unique process ID is assigned to the child process. 3. The process image of the parent is copied, except for shared memory areas. 4. The child process owns the same open files as the parent. 5. The child process is added to the Ready queue and starts execution.
64
What happens when fork() is called by the parent process in UNIX?
When fork() is called, there is initially one process (the parent).
65
What happens after fork() finishes and returns a value in UNIX?
After fork() finishes, there are now two processes: - The parent process continues execution at the return from fork(). - The child process begins executing at the same point in the code as the parent, at the return from fork().
66
What is the return value of fork() in the parent process in UNIX?
In the parent process, fork() returns the process ID (PID) of the child process.
67
What is the return value of fork() in the child process in UNIX?
In the child process, fork() returns 0.
68
What does the "e" in exec() system call variants (like execle(), execve()) stand for?
The "e" in exec() system call variants indicates that an array of pointers to environment variables is explicitly passed to the new process image.
69
What does the "l" in exec() system call variants (like execl(), execle()) stand for?
The "l" in exec() system call variants indicates that command-line arguments are passed individually.
70
What does the "p" in exec() system call variants (like execvp(), execve()) stand for?
The "p" in exec() system call variants means the PATH environment variable is used to find the file name of the program to be executed.
71
What does the "v" in exec() system call variants (like execv(), execvp()) stand for?
The "v" in exec() system call variants indicates that command-line arguments are passed as an array of pointers.
72
What does the waitpid() system call do in a parent-child process relationship?
The waitpid() system call is used by the parent process to wait for the exit of a child process.
73
What are the two types of process termination?
1. Normal termination: The program ends itself. 2. Abnormal termination: The OS intervenes, often due to errors like forbidden memory access, I/O errors, timeouts, or the parent process being terminated.
74
What are the different ways a process can terminate in UNIX?
1. Normal exit (voluntary): - Process completes regularly, with or without an error code. - The process calls exit(errNo) to indicate completion. 2. Fatal error (involuntary): - Uncatchable errors like out-of-memory, I/O errors, stack overflow, or arithmetic errors. 3. Killed by another process (involuntary): - The process receives a SIGKILL signal from another process. - In some systems, the parent process terminates all child processes as well.
75
What is cascading termination in operating systems?
Cascading termination occurs when a parent process terminates, causing all its child processes (and their descendants) to also terminate. This is done by the operating system to ensure that no orphaned processes remain.
76
What is a zombie process?
A zombie process is a process that has completed execution but still has an entry in the process table. This occurs because the parent process has not yet called wait() to collect the exit status of the child process.
77