LATEST UPDATE (ALREADY GRADED A+)
What is a process?
The active implementation of an otherwise passive program.
Within the process context (also known as user context), there are four components:
Text, data, stack, heap.
Within the register context, the components are:
General purpose registers, stack pointer, program counter, etc..
PID 0
Swapper/sched, used for memory management.
PID 1
Init, continually running in the background and used to startup/shutdown the system.
Process state created
Also known as "new".
Process state waiting
Also known as "ready", when process is scheduled for execution. Can transition to running via scheduler
dispatch.
Process state running
Actively executing instructions on the CPU.
Process state blocked
Unable to continue without even occurring, eg./ I/O.
Process state terminated
Has been killed off by "exit".
CPU scheduler
Invoked every couple of milliseconds, this is short term.
Job scheduler
Invoked every couple of seconds or minutes, decides which processes to be brought into the ready
queue.
, Three queues:
Job (all PCBs in the system).
Ready (All processes in the main memory and waiting to execute).
Device (All processes waiting for an I/O device).
Thrashing
When the CPU spends more time swapping context than getting actual work done.
Context switches
Yield and overhead of 1 us and are swapping an old PCB for a new one.
Exec family
execl (full name of command, variable length of arguments terminated by NULL)
execlp(same as execl but with partial name)
execle(same as execlp but third argument listing environment variables)
execv(execl where args are null terminated array)
execvp(execlp w/ null term)
execve (execle with null)
Two uses for fork
Dispatching a child to do some work for you, and executing a command (like a shell).
Two reasons fork will fail
Too many processes in system already, or exceeds max number of processes allowed for the user ID.
When a new processed is created:
Child inherits a copy of the parent's memory space, File descriptors are also inherited. Non-deterministic
output.
A process may be terminated:
When it executes its last statement, by calling, exit, when the parent calls abort() on it.
Abort() can be called by the parent when the child:
Has exceeded its allocated resources, has a task assigned that is no longer required, or when the
parenting is exiting (on select operating systems).