Process management Flashcards
What is a process in an operating system?
A process is a program in execution, consisting of program code, data, and system resources.
What are the different states of a process?
New, Ready, Running, Waiting, Terminated.
What is the difference between a process and a thread?
A process is an independent execution unit with its own memory, whereas a thread is a lightweight execution unit sharing memory within a process.
What is process creation?
It is the initiation of a new process using system calls like fork(), exec(), or CreateProcess().
Which system calls are used for process creation in UNIX?
fork(), exec(), wait(), exit().
What does the fork() system call do?
It creates a new child process by duplicating the parent process.
What is the difference between fork() and exec()?
fork() creates a new process, while exec() replaces the current process image with a new one.
What happens if fork() is called multiple times?
Multiple child processes are created, leading to exponential growth in processes.
What is the return value of fork()?
0 for the child process, child’s PID for the parent process, and -1 if the fork fails.
What is the use of the wait() system call?
It makes a parent process wait until its child process terminates.
What is the difference between wait() and waitpid()?
wait() waits for any child process, while waitpid() can wait for a specific child.
What is an orphan process?
A child process whose parent has terminated.
What is an init process?
The first process in UNIX/Linux (PID 1) that adopts orphan processes.
What is a zombie process?
A process that has completed execution but still has an entry in the process table.
How do you prevent a zombie process?
By calling wait() or waitpid() in the parent process.
What is the difference between a zombie and an orphan process?
A zombie has terminated but is still in the process table; an orphan is running without a parent.
What is the exec() system call?
It replaces the current process image with a new one.
What are the variants of exec() in UNIX?
execl(), execle(), execlp(), execv(), execve(), execvp().
What happens to process ID (PID) after exec()?
It remains the same as exec() does not create a new process.
What is inter-process communication (IPC)?
It is a mechanism for processes to communicate, using pipes, message queues, shared memory, etc.
What is the difference between IPC using pipes and shared memory?
Pipes provide unidirectional or bidirectional communication, whereas shared memory allows direct access to data.
What is the parent-child relationship in processes?
A parent creates a child process using fork(), and both share some resources.
What is a daemon process?
A background process that runs without user interaction.
How do you create a daemon process?
By detaching it from the terminal using fork(), setsid(), and changing the working directory.