ANSWERS GRADED A+
✔✔Initial State - ✔✔Sometimes a system will have an initial state that the process is in
when it is being created.
✔✔Final State - ✔✔A process could be placed in a final state where it has exited but
has not yet been cleaned up (in UNIX-based systems, this is called the zombie state).
This final state can be useful as it allows other processes (usually the parent that
created the process) to examine the return code of the process and see if the just-
finished process executed successfully (usually, programs return zero in UNIX-based
systems when they have accomplished a task successfully, and non-zero otherwise).
When finished, the parent will make one final call (e.g., wait()) to wait for the completion
of the child, and to also indicate to the OS that it can clean up any relevant data
structures that referred to the now-extinct process.
✔✔Chapter 5 - ✔✔Interlude: Process API /
Process API
✔✔fork() System Call - ✔✔Used to create a new process.
The fork() system call is used in UNIX systems to create a new process. The creator is
called the parent; the newly created process is called the child. As sometimes occurs in
real life, the child process is a nearly identical copy of the parent.
✔✔Process Identifier (PID) - ✔✔In UNIX systems, the PID is used to name the process
if one wants to do something with the process, such as (for example) stop it from
running.
Each process has a name; in most systems, that name is a number known as a process
ID (PID).
✔✔Child Process /
Parent Process - ✔✔The newly-created process from the creating parent process.
As sometimes occurs in real life, the child process is a nearly identical copy of the
parent.
✔✔Deterministic Output - ✔✔When an input will always produce the same output with
no variation; not every program or process is deterministic.
,An indeterminate program consists of one or more race conditions; the output of the
program varies from run to run, depending on which threads ran when. The outcome is
thus not deterministic, something we usually expect from computer systems.
✔✔CPU Scheduler - ✔✔Determines which process runs at a given moment in time;
because the scheduler is complex, we cannot usually make strong assumptions about
what it will choose to do, and hence which process will run first.
✔✔Non-Deterministic Output - ✔✔When an input will not always produce the same
output each time.
We cannot usually make strong assumptions about what it will choose to do, and hence
which process will run first.
✔✔wait() System Call - ✔✔Sometimes, it is quite useful for a parent to wait for a child
process to finish what it has been doing. This task is accomplished with the wait()
system call (or its more complete sibling waitpid()).
The wait() system call allows a parent to wait for its child to complete execution
✔✔exec() System Call - ✔✔This system call is useful when you want to run a program
that is different from the calling program.
The exec() family of system calls allows a child to break free from its similarity to its
parent and execute an entirely new program.
✔✔Shell - ✔✔A UNIX shell commonly uses fork(), wait(), and exec() to launch user
commands; the separation of fork and exec enables features like input/output
redirection, pipes, and other cool features, all without changing anything about the
programs being run.
✔✔Prompt - ✔✔A user program; waits for you to type something into it (a command in
most cases).
✔✔Standard Output (Redirected / Redirecting) - ✔✔The default/expected output of a
program. It can be redirected into an output file rather than being displayed onto the
screen.
✔✔Signal - ✔✔What system calls use to call a process's directives.
Process control is available in the form of signals, which can cause jobs to stop,
continue, or even terminate.
✔✔Administer /
, Administrator - ✔✔A system generally needs a user who can administer the system,
and is not limited in the way most users are.
Such a user should be able to kill an arbitrary process (e.g., if it is abusing the system in
some way), even though that process was not started by this user.
Such a user should also be able to run powerful commands such as shutdown (which,
unsurprisingly, shuts down the system).
✔✔Superuser /
Root - ✔✔The UNIX equivalent of an administrator. While most users can't kill other
users processes, the superuser can.
A superuser can control all processes (and indeed do many other things); this role
should be assumed infrequently and with caution for security reasons.
✔✔User - ✔✔Which processes can be controlled by a particular person is encapsulated
in the notion of a user; the operating system allows multiple users onto the system, and
ensures users can only control their own processes.
✔✔Chapter 6 - ✔✔Mechanism: Limited Direct Execution /
Direct Execution
✔✔Limited Direct Execution - ✔✔The trap tables must be set up by the OS at boot time,
and make sure that they cannot be readily modified by user programs. All of this is part
of the limited direct execution protocol which runs programs efficiently but without loss
of OS control.
✔✔User Mode - ✔✔Code that runs in user mode is restricted in what it can do. For
example, when running in user mode, a process can't issue I/O requests; doing so
would result in the processor raising an exception; the OS would then likely kill the
process.
✔✔Kernel Mode - ✔✔What the operating system (or kernel) runs in. In this mode, code
that runs can do what it likes, including privileged operations such as issuing I/O
requests and executing all types of restricted instructions.
✔✔System Call - ✔✔When a user program or user process wishes to perform some
kind of privileged operation, such as reading from a disk, it perform a system call.
System calls allow the kernel to carefully expose certain key pieces of functionality to
user programs, such as accessing the file system, creating and destroying processes,
communicating with other processes, and allocating more memory.
✔✔Trap Instruction - ✔✔Used to execute a system call.