Process management and interprocess communication Flashcards

(38 cards)

1
Q

What is a process in Linux?

A

An instance of a running program with its own memory, registers, and system resources.

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

What data does a Process Control Block (PCB) contain?

A

PID, PPID, process state, CPU registers, memory info, open files, signals, and scheduling data.

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

What are the main process states in Linux?

A

R (Running), S (Sleeping), D (Uninterruptible Sleep), T (Stopped), Z (Zombie).

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

Which process states contribute to CPU load average?

A

R (Running) and D (Uninterruptible Sleep).

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

What system call creates a new process?

A

fork()

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

What does fork() return to parent and child?

A

Parent: PID of child. Child: 0. Returns -1 on failure.

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

What optimization does Copy-on-Write provide?

A

Parent and child share memory pages until one writes, minimizing copy overhead.

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

What system call replaces the current process image with a new program?

A

exec() family (e.g., execve()).

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

What is the difference between fork() and vfork()?

A

vfork() shares the parent’s address space and suspends the parent until child calls exec() or exit().

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

What system call underlies fork() and thread creation?

A

clone()

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

What is the difference between clone() flags CLONE_VM and CLONE_FILES?

A

CLONE_VM shares memory; CLONE_FILES shares open file descriptors.

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

What system call allows a parent to wait for its child process to exit?

A

wait(), waitpid(), or wait4().

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

What is a zombie process?

A

A terminated process not yet reaped by its parent; remains in the process table but holds no resources.

Can’t be killed, parent must call wait() or be killed and PID reaps zombie.

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

What is an orphan process?

A

A child process whose parent terminated; adopted by init (PID 1).

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

What is the role of init (PID 1)?

A

First userspace process, starts services, adopts orphan processes.

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

What are the main IPC (Inter-Process Communication) mechanisms?

A

Pipes, Named Pipes (FIFOs), Shared Memory, Message Queues, Sockets, Signals.

17
Q

How are anonymous pipes typically used?

A

For unidirectional communication between parent and child created with fork().

18
Q

What is a named pipe (FIFO)?

A

A filesystem object for bidirectional communication between unrelated processes.

19
Q

What is shared memory used for?

A

Fast IPC via memory regions accessible by multiple processes; requires synchronization.

20
Q

What is a message queue used for?

A

Structured message-based communication between processes.

21
Q

What is the difference between Unix Domain Sockets and TCP Sockets?

A

Unix sockets communicate locally via filesystem; TCP sockets communicate over networks.

22
Q

What are signals in Linux?

A

Asynchronous notifications sent to processes to indicate events or control actions.

23
Q

Which signals cannot be caught, blocked, or ignored?

A

SIGKILL and SIGSTOP.

24
Q

What signal is sent by Ctrl+C?

A

SIGINT (signal 2).

25
What signal is used to restart a process cleanly?
SIGHUP.
26
What command sends a signal to a process?
kill - (e.g., kill -HUP 1234).
27
What is the nice value range and meaning?
-20 (highest priority) to +19 (lowest priority).
28
What command runs a process with a custom nice value?
nice -n ./command
29
What command changes the nice value of a running process?
renice -n -p
30
What scheduling algorithm does Linux use for normal processes?
Completely Fair Scheduler (CFS), based on virtual runtime (vruntime).
31
What's the difference between a process and a thread?
Process is independent unit of execution within a process, with own memory space and system resources. Thread is lightweight unit of execution within process, shares resources with other threads.
32
Explain the differences between fork() and exec() in process creation
fork() creates new process by duplicating current process with copy of parents memory space exec() replaces current process image with new program
33
What is role of proc filesystem and how does it interact with the kernel?
VFS that provides interface to kernel data structures. Contains information about processes, hardware and system config as files Userspace tool and programs read files to view kernel state and write to tunables to modify kernel state
34
How do you kill processes in Linux?
Killed with signals, kill tool SIGTERM - graceful shutdown by programs (used by kill) SIGINT - graceful shutdown by user (ctrl-c) SIGKILL - force kill
35
What's a signal and how is it handled by the kernel?
A signal is an asynchronous software interrupt that can be sent to processes. Kernel sets pending bit in process's signal bitmap, and process picks it up next time it runs
36
List the ways to catch a signal for a program that you don't have the source code for.
strace, gdb, /proc//status
37
What signal is sent to a parent process when the child process terminates?
SIGCHLD, tells parent to reap it
38
How does the kill command work at the kernel level?
Runs kill() syscall looks up target PID checks permissions enqueues signal to process task struct