Process management Flashcards

1
Q

Define the term “process” in the context of operating systems

A

A process is a program in execution. It’s not just the code itself but includes the program’s current state and resources.

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

Distinguish between a “program” and a “process.”

A


A program consists of executable code and is typically stored as a file on disk.

A process is that program actively running in memory. It includes the code, data, and system resources the program is using.

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

What are the fundamental Linux primitives (system calls) used in process creation and management?

A

○ fork(): Creates a new process that is an identical copy of the parent process. Returns the child’s process ID (PID) to the parent and 0 to the child.
○ exec(filename): Replaces the current process’s code with the code from the specified file (the program to be executed).
○ wait(): Causes the parent process to pause execution until a child process terminates.
○ exit(): Terminates the calling process.

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

What constitutes a process’s state? In other words, what are the essential elements that define a process?

A

○ Registers: Hold temporary data and the program counter.
○ Address Space: Contains the code, data (heap, stack), and libraries the process can access.
○ Open Files: A list of files the process has open.

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

Describe the components and organization of a process’s address space.

A


Code: The program instructions.

Static Data: Global variables with fixed sizes.

Heap: Dynamically allocated memory during program execution.

Stack: Used for function calls, local variables, and function parameters.

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

Compare and contrast stack-based and heap-based dynamic memory allocation.

A

○ Stack:
■ Memory allocation and deallocation are fast.
■ Follows a Last-In, First-Out (LIFO) order, simplifying memory management.
■ Used for function call frames (local variables, parameters).
■ Managed automatically.

○ Heap:
■ Allocation can be slower due to searching for free space.
■ Flexible allocation and deallocation order.
■ Can lead to fragmentation (unused memory between allocated blocks).
■ Programmers are responsible for allocating (using malloc()) and deallocating (using free()) memory.

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

How does an operating system uniquely identify each process?

A

Every process is assigned a unique Process Identifier (PID), a unique numerical ID.

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

What is the purpose of a Process Control Block (PCB)?

A

○ The PCB is a data structure the operating system uses to store information about a process.

○ This information includes the PID, process state, register values (save area for context switching), and other relevant details.

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

Explain the concept of a “process tree” in Linux.

A

○ The process tree is a hierarchical representation of processes on a Linux system.

○ The init process is the root of the tree, created during system boot.

○ When a process (parent) creates a new process (child) using fork(), the child becomes a node below the parent in the tree.

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

Why use the combination of fork() and exec() instead of a single system call to create and run a new program?

A

○ Environment Inheritance: fork() allows the child process to inherit a copy of the parent’s environment (open files, environment variables).

○ Flexibility: The parent can modify the child’s environment after fork() and before exec(), giving fine-grained control over the new program’s execution context.

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

What are the primary drawbacks of a single-process computing system?

A

○ Long Wait Times: Users experience significant delays because only one program can run at a time, and they must wait for it to finish.
○ Low Utilization: CPU resources are wasted during I/O operations. When a process is waiting for I/O, the CPU sits idle instead of doing useful work.

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

What are the key advantages of a multiprocess system compared to a single-process system?

A

○ Improved CPU Utilization: While one process waits for I/O, another process can use the CPU. This leads to more efficient hardware resource usage.

○ Reduced Wait Times: Multiple processes running concurrently give the illusion of simultaneous execution, reducing user wait times for task completion.

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

List and briefly describe the typical states a process can be in within an operating system.

A

○ Running: The process is currently executing instructions on the CPU.

○ Ready: The process is runnable (ready to use the CPU) but is waiting for its turn to be scheduled.

○ Waiting (Blocked): The process is waiting for an event (like I/O completion) before it can proceed.

○ New: The process is being created.

○ Terminated: The process has finished executing or has been terminated.

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

What is a process switch, and why is it necessary in a multiprocess system?

A

○ A process switch is the procedure of suspending the execution of one process on the CPU and resuming (or starting) the execution of another process.

○ It’s how the OS gives the illusion of concurrency, allowing multiple processes to share the CPU.

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

Describe the steps involved in a context switch.

A

1.Save the Context of the Running Process: Store the values of the CPU registers, program counter, and other relevant information of the process that is currently running into its PCB.

2.Load the Context of the Next Process: Retrieve the saved context of the process that is going to run next from its PCB and load it into the CPU registers.

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

What is the role of the process scheduler in an operating system?

A

○ The scheduler is the OS component responsible for deciding which process from the ready queue gets to use the CPU next.

○ It uses scheduling algorithms to make this decision, aiming to meet performance goals like fairness, response time, and throughput.

17
Q

Differentiate between preemptive and non-preemptive scheduling.

A

○ Non-Preemptive: Once a process is assigned the CPU, it runs to completion or until it voluntarily relinquishes the CPU (e.g., for I/O).

○ Preemptive: The OS can interrupt a running process (using a timer interrupt) and switch to another process, even if the first process is not finished.

18
Q

Name and briefly describe three common process scheduling algorithms.

A

○ First-Come, First-Served (FCFS): Processes are scheduled in the order they arrive in the ready queue. Simple but can lead to poor response times if long jobs arrive first.

○ Shortest Job First (SJF): The process with the shortest estimated execution time is selected to run next. Can minimize average waiting time but requires knowledge of job lengths, which is often difficult to predict accurately.

○ Round Robin (RR): Processes take turns using the CPU in a cyclic fashion. Each process is assigned a time quantum (a slice of CPU time). After its quantum expires, the process is moved to the back of the ready queue, ensuring fairness.

19
Q

What are some of the trade-offs to consider when selecting a process scheduling algorithm?

A

○ Response Time: How long does it take for a process to start executing after becoming ready?

○ Throughput: How many processes can the system complete in a given amount of time?

○ Overhead: How much time does the scheduler itself consume? Excessive context switching can reduce overall system performance.

○ Fairness: Are processes given a reasonable share of CPU time?

20
Q

How do interactive jobs and batch jobs differ in their scheduling requirements?

A

○ Interactive Jobs: (e.g., text editors, web browsers) - Prioritize short response times to feel responsive to the user.

○ Batch Jobs: (e.g., scientific simulations, data analysis) - Prioritize high throughput, as they are typically long-running and don’t require immediate user interaction.