Study Questions #2 - Topic 6 + Topic 7, Qn #1-50 Flashcards
- What is the Unix process?
A process (a program that is executing)
- What are the three main states that any living process may have?
Running For a short slice of time only Ready to run A ready process means it could use the CPU immediately (if it is allowed to do so) The scheduler decides which of the ready processes to run next Blocked or sleeping Waiting for an event to occur, e.g., I/O or signal
- Under which condition does a Unix process enter a blocked state?
Waiting for an event to occur,
e.g., I/O or signal
- In Unix, what is the difference between a process ready state and blocked state?
Blocked = waiting for event to finish. Ready = Waiting on the scheduler to decide which process runs next.
- What is the Unix PID?
Process ID = Keep track of all processes in the system.
Similar to the idea of inodes in case of files, or S.I.N. in our daily life
- What is the Unix PPID?
Parent Process ID
- In a Unix operating system, scheduling services are performed by a program called scheduler. What are the main tasks that a schedule perform?
- Maintains a list of all the processes waiting to execute
- Chooses one process at a time, and gives it a chance to run
for a short time called time slice (typically 10 milliseconds) - Saves data related to the interrupted processes so that they can
be resumed later
- List five of the Unix system calls that coordinate processes. Describe the main function of each of them.
fork: creates a copy (child) of the current process (parent)
exec: changes the program that a process is running
wait: forces a process to pause until another process finishing its execution
exit: terminates a process
chomd: change permissions
- What are the main differences between internal and external Unix commands?
Internal commands: Interpreted directly by the shell (no need to create a new process)
External commands: Required the shell to run a separate program (need to create a new
process)
- Explain what will happen when executing a Unix external command.
The shell will use fork system call to create
a duplicate of the currently running program
The duplicate (child process) and the original (parent process)
proceed from the point of the fork with exactly the same data.
The only difference is the return value from the fork call.
- In Unix, what is the relation between child and parent processes?
The duplicate (child process) and the original (parent process)
proceed from the point of the fork with exactly the same data.
The only difference is the return value from the fork call.
fork returns
the child PID to the parent process and
0 to the child process
- Explain in details what will happen when a process executes the fork system call.
Fork is an operation whereby a process creates a copy of itself. It is usually a system call, implemented in the kernel.
- Process is duplicated.
- Child inherits the properties (descriptors) from the Parent.
- The parent and the child share data content (like a pointer).
- If a parent process unexpectedly died,
The child will keep executing,
The child process is considered to be an orphan
- Explain in details what will happen when a process executes the exec system call.
exec: changes the program that a process is running *
- What is the Unix Zombie state?
A zombie process is a process that completed execution but still in process table.
- When does a Unix process enter a Zombie state?
When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process’s entry in the process table remains. The parent can read the child’s exit status by executing the wait system call, at which stage the zombie is removed
After the zombie is removed, its process ID and entry in the process table can then be reused. However, if a parent fails to call wait, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.
- What is the Unix job?
A job refers to all the processes that are necessary to execute an
entire command line
- In Unix systems, what is the only living ancestor of all other processes in the system? Explain why.
In Unix, toward the end of the boot procedure, the kernel
creates a special process by hand without forking
This process is given a PID of 0 (process#0)
Process#0 initializes many data structures needed by the kernel
At the end, it forks process#1 and
then somehow disappeared (terminated itself)
- In Unix, what is an orphan process?
Orphan processes is kind of the opposite situation of zombie processes, since it refers to the case where a parent process terminates before its child processes, in which case these children are said to become “orphaned”.
The child will keep executing
- In Unix, when does a process become an orphan?
If a parent process unexpectedly died (before the child)
- In Unix, who does adopt orphan processes?
Process#1 automatically adopts all orphan processes, hence it
receives the control from the child process when finishing execution
Informs the kernel to de-allocates the child used resources and kill it
- In Unix, why orphan processes need to be adopted?
In UNIX all processes must be in a single tree, so orphans must be adopted
- In Unix systems, what will happen if a parent process unexpectedly died before its child finishing its process?
Child processes are not notified immediately when their parent finishes. Instead, the system simply redefines the “parent-pid” field in the child process’s data to be the process that is the “ancestor” of every other process in the system, whose pid generally has the value 1 (one), and whose name is traditionally “init”.
- In Unix systems, what are the main differences between a foreground and a background executions of a program?
In the foreground
The shell waits for the command to finish before giving another prompt to
allow you to continue
When running a command in the background
you do not have to wait for the command to finish before starting another command
Useful when running a command that needs a long time
The window will be free so you can use it for other work
- List five of the Unix signals that are used with the kill command. Describe the main function of each of them.
Name Des Used for
0 SIGNULL Null Check access to pid
1 SIGHUP Hangup Terminate; can be trapped
2 SIGINT Interrupt Terminate; can be trapped
3 SIGQUIT Quit Terminate with core dump; can be
9 SIGKILL Kill Forced termination; cannot be trapped
15 SIGTERM Terminate Terminate; can be traped
24 SIGSTOP Stop Pause the process; cannot be trapped
25 SIGTSTP Terminal stop Pause the process; can be
26 SIGCONT Continue Run a stopped process
- How similar the Unix stop and kill commands?
Kill: Immediate termination (Can not be
trapped or ignored by a process)
Stop (suspend): sent when you press ^Z
- How similar the Unix ^z and stop command?
Stop (suspend): sent when you press ^Z = same cmd
- How similar the Unix ^z and kill command?
Kill: Immediate termination (Can not be
trapped or ignored by a process)
Stop (suspend): sent when you press ^Z
- How similar the Unix ^c and kill command?
Interrupt: sent when you press ^C
Kill: Immediate termination (Can not be
trapped or ignored by a process)
- How do you run a Unix job in the background?
-bg
JobName -bg
Use Jobs to find active jobs.