LU3 Process Management Flashcards

1
Q

What is a process in the context of operating systems?

A

An instance of a program running in a computer

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

What distinguishes a program from a process?

A

A program is a static sequence of instructions stored on disk, while a process is the running instance of a program using system resources.

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

What is the ‘init’ process in UNIX systems?

A

The first visible process in UNIX with process ID 1, serving as the ancestor of all subsequent processes.

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

How can you view currently running processes in Linux?

A

Using the ‘ps’ command.

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

Which command stops a process by its PID in Linux?

A

The ‘kill {PID}’ command.

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

What does the ‘killall’ command do in Linux?

A

It stops processes by their name.

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

What command is used for real-time updates on running processes?

A

The ‘top’ command.

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

Name the six possible states of a process.

A

Idle, Runnable, Running, Sleeping, Suspended, Zombified.

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

What is a zombie process?

A

A process that has terminated but has not returned its exit code to its parent.

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

How do you create a new process in UNIX?

A

By duplicating an existing process using the ‘fork()’ system call.

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

What does the ‘fork()’ system call do?

A

It duplicates a process, creating a child process that is an almost-exact duplicate of the parent.

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

What is returned by ‘fork()’ in the parent process?

A

The process ID of the child process.

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

What is returned by ‘fork()’ in the child process?

A

0 on success.

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

How can a process obtain its own PID?

A

By using the ‘getpid()’ system call.

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

What system call retrieves a process’s parent PID?

A

The ‘getppid()’ system call.

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

What happens to a child process if its parent dies before it terminates?

A

It is adopted by the ‘init’ process (PID 1).

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

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

A

The ‘wait()’ system call.

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

What does the ‘exec()’ family of system calls do?

A

Replaces the current process’s code, data, and stack with those of another executable.

It replace the current process with another program.

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

What distinguishes ‘fork()’ from ‘exec()’?

A

‘fork()’ duplicates a process, while ‘exec()’ replaces a process with a new one.

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

What is the purpose of the ‘exit()’ system call?

A
  • Terminates a process
  • Deallocates its resources
  • Sends a SIGCHLD signal to the parent.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What command can be used to change a process’s priority in UNIX?

A

The ‘nice()’ command.

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

What is the range of priority values that can be set using ‘nice()’?

A

Between -20 (highest priority) and +19 (lowest priority).

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

Which system call sends signals to processes?

A

The ‘kill()’ system call.

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

What signal is often used to terminate a process forcefully?

A

SIGKILL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What does the 'waitpid()' system call do?
Suspends the calling process until the specified child process finishes.
26
What macro checks if a process terminated normally in 'waitpid()'?
WIFEXITED(*statusPtr).
27
What is the default parent process of all orphaned processes?
The 'init' process with PID 1.
28
Which process state indicates a process is waiting for an event?
Sleeping.
29
What command lists all running processes with their owners in Linux?
'ps aux' command.
30
What is an orphan process?
A process whose parent has terminated before it finishes, becoming adopted by 'init'.
31
How does 'execl()' differ from 'execvp()'?
'execl()' requires the full path of the executable, while 'execvp()' searches using the PATH environment variable.
32
What happens if 'exec()' fails to find the specified executable?
It returns -1.
33
What does the 'ps' command output signify for a zombie process?
The process status shows ''.
34
What is a common cause of a zombie process?
The parent process hasn't executed a 'wait()' to accept the child's return code.
35
What system call is used to terminate a process with a specific signal?
'kill(pid, sig)'.
36
What is indicated by a process status 'S' in 'ps' command output?
The process is sleeping (waiting for an event).
37
Which system call returns immediately if no child has exited?
`waitpid()` with the `WNOHANG` option.
38
What is the function of 'WEXITSTATUS()' macro?
It evaluates the exit status code returned by the terminated process.
39
How can you suspend a running process?
By sending a SIGSTOP signal, often using Control-Z in the terminal.
40
What process attribute remains unchanged after a 'fork()'?
* Session * process group membership * controlling terminal * UIDs and GIDs.
41
What is the definition of a process in an operating system?
An instance of a program running in a computer
42
What resources does a process require to run?
Memory, user and system stacks, file handles, CPU, and access to physical devices.
43
How does a process differ from a program?
A program is a static sequence of instructions stored on disk, while a process is the active execution of those instructions.
44
What is the role of the microprocessor in process management?
It executes the instructions of the process.
45
What attributes are associated with every UNIX process?
Code (text), data, a stack, and a unique process ID number (PID).
46
What is the 'init' process in UNIX systems?
The first visible process with PID 1, ancestor of all subsequent processes.
47
How are new processes created in UNIX?
By duplicating an existing process using the fork() system call.
48
Which Linux command lists currently running processes?
ps
49
How do you kill a process by its PID in Linux?
Using the command kill {PID}.
50
Which command stops processes by name in Linux?
killall {process-name}
51
What command provides real-time updates of running processes?
top
52
What are the six possible states of a process?
Running, Runnable, Sleeping, Suspended, Idle, Zombified.
53
What does it mean if a process is in the 'Running' state?
The process is currently using the CPU.
54
Define a 'Runnable' process.
A process that can use the CPU as soon as it becomes available.
55
What is a 'Sleeping' process?
A process waiting for an event, such as I/O completion.
56
What signal suspends a process?
SIGSTOP.
57
How is a suspended process resumed?
By sending it a SIGCONT signal.
58
What is an 'Idle' process?
A process being created by a fork() system call but not yet runnable.
59
What is a 'Zombified' process?
A terminated process that hasn't returned its exit code to its parent.
60
What system call is used to create a process in UNIX?
fork()
61
What is returned by fork() in the parent process?
The process ID of the child process.
62
What is returned by fork() in the child process?
0 on success.
63
How can a process obtain its own process ID?
By using the getpid() system call.
64
How can a process obtain its parent's process ID?
By using the getppid() system call.
65
What happens to a child process if its parent dies?
It becomes an orphan process and is adopted by the init process.
66
What is an orphan process?
A process whose parent terminated before it did.
67
How does a parent process wait for its child to terminate?
By using the wait() system call.
68
What does the exec() family of system calls do?
Replaces the current process's code, data, and stack with a new executable.
69
What is the difference between fork() and exec()?
fork() duplicates a process; exec() replaces it with a new process.
70
What happens if exec() fails to find the executable?
It returns -1.
71
What is the purpose of the exit() system call?
Terminates a process, deallocates resources, and sends a SIGCHLD signal to the parent.
72
How do you send a signal to a process in UNIX?
Using the kill(pid, sig) system call.
73
What does the nice() command do?
Changes a process's priority.
74
What is the range of priorities set by nice()?
-20 (highest priority) to +19 (lowest priority).
75
How does a process become a zombie?
When it terminates but its parent hasn't accepted its return code.
76
What is the role of the waitpid() system call?
Suspends the calling process until a specified child process terminates.
77
What does the macro WIFEXITED(*statusPtr) indicate?
The process terminated normally.
78
What command lists all processes along with their owners?
ps aux
79
What does the process status 'Z' indicate in the ps command output?
The process is a zombie (defunct).
80
How can you check if a specific process is running?
Using ps ax | grep process-name.
81
What does the kill 0 command do?
Stops all processes except your shell.
82
What does the execvp() system call do?
Searches for the executable in the PATH environment variable and executes it.
83
How does the execlp() function differ from execl()?
execlp() searches for the executable using the PATH variable, wheras, execl() need absolute executable path.
84
What is the purpose of the wait() system call?
Waits for a child process to terminate.
85
What happens if wait() is called but there are no child processes?
It returns immediately with a value of -1.
86
How does waitpid() differ from wait()?
waitpid() can target **specific** child processes and has **non-blocking** options.
87
What does the WEXITSTATUS(*statusPtr) macro evaluate?
The exit status code of the terminated process.
88
How can you suspend a running process from the terminal?
By pressing Control-Z, which sends a SIGSTOP signal.
89
What does the WIFSIGNALED(*statusPtr) macro indicate?
The process terminated due to an **unhandled** signal.
90
How does fork() affect file descriptors?
The child process inherits copies of the parent's open file descriptors.
91
What is the parent process ID of the init process?
It is 1.
92
What does the WTERMSIG(*statusPtr) macro evaluate?
The **signal number** that caused the process to terminate.
93
How do you create a background process in Linux?
Append & to the command (e.g., ls &).
94
What is the function of the execle() system call?
Executes a new process with a specified environment.
95
What is a 'process table' in UNIX?
A kernel structure containing entries for every process, including: * PIDs * state * resource information.
96
What is a 'signal' in UNIX process management?
It is how processes communicate with each other. A form of **inter-process communication** (IPC) used to notify a process of events. A simple message sent to a process to tell it that something important has happened
97
What is the default action of the SIGKILL signal?
Immediately terminates the process.
98
What does the nice(10) command do?
Lowers the process's priority, making it run slower.
99
How can a process voluntarily terminate itself?
By calling exit().
100
What is the purpose of the `WIFSTOPPED(*statusPtr) `macro?
Indicates if the process is currently **stopped** but **not terminated**.
101
What is the WSTOPSIG(*statusPtr) macro used for?
Identifies the signal that caused the process to stop.
102
What does the execv() system call do?
Executes a program specified by a path, with arguments provided in an **array**.
103
What happens if a process receives a SIGCHLD signal?
It indicates that a child process has terminated.
104
How does the kill() system call ensure process security?
Based on UID. Only processes with the **same** *UID* or *superuser privileges* can send signals to others.
105
What does nice(-5) do, and who can execute it?
Raises the process priority; only superusers can use negative values.
106
What is the significance of the 'user area' in a process?
It holds **housekeeping information** about the process.
107
What does a 'stack area' in a process contain?
**Temporary data** used during process execution.
108
What does `execl("/bin/ls", "ls", "-l", NULL)` do?
Executes the ls -l command, **replacing** the current process. `NULL == (char *)0`
109
What is the function of execve()?
Executes a program with a specified environment and array of arguments.
110
What is a 'page table' in process management?
A structure used by memory management to map virtual to physical addresses.
111
What happens when waitpid(-1, &status, 0) is called?
Waits for any child process to terminate.
112
What does the ps -ag command do?
Lists all running processes **by process group ID**
113
What causes a process to enter the 'Idle' state?
Being created by fork() but not yet runnable.
114
What happens to an orphan process in UNIX?
It is adopted by the init process.
115
What does waitpid(0, &status, WNOHANG) do?
* Checks if any child process has exited. * If so, it stores the exit status in `status` and returns the **child's PID**. * Otherwise, it **returns 0** immediately (***no blocking***). * This allows non-blocking checks on child processes.
116
What is the default priority of a user process in UNIX?
0.
117
What is the highest possible priority value for a process?
-20 (requires superuser privileges).
118
119
How do you terminate a process using its name?
Using killall {process-name}.
120
What is the result of exit(2) in a process?
Terminates the process with an exit status of 2.
121
How do you analyze a terminated process's status?
Using macros like: * `WIFEXITED` * `WEXITSTATUS` * `WIFSIGNALED`
122
What does `SIGSTOP` do to a process?
**Suspends** it until a `SIGCONT` is received.
123
What is the effect of a 'fatal error' on a process?
Causes **in**voluntary termination.
124
How do you resume a suspended process?
By sending it a SIGCONT signal.
125
What does the ps ax command display?
Lists all running processes with detailed status.
126
127
What is the **role** of WUNTRACED in waitpid()?
Return children that are **temporarily paused** or **not reporting back**.
128
How does the kernel manage multiple processes?
Through: * process scheduling * prioritization
129
What happens if a parent process never calls wait()?
Its child processes become zombies.
130
How do you terminate all processes except your shell?
Using the command kill 0.
131
What is a 'process group' in UNIX?
A collection of related processes that can be managed together.
132
How does `execvp("ls", argv)` work?
Searches for `ls` in the `PATH` and executes it with arguments in `argv`.
133
What does `ps aux | grep "process-name"` do?
Find a specific running process.
134
What is a 'controlling terminal' in process management?
The terminal associated with a process's input and output.
135
What is the significance of the **umask** in process creation?
The **default** file permission for new files created by the process.
136
What happens if you call wait() without any child processes?
It returns immediately with an error.
137
How can a process change its working directory?
By using the chdir() system call.
138
What does `execle("/bin/ls", "ls", "-l", NULL, env)` do?
Executes `ls -l` with a specified environment `env`.
139
What is a 'real user ID' in UNIX?
The ID of the user who **owns the process**.
140
What is an 'effective user ID' in UNIX?
The ID used **for permission checks** during process execution.