Processes (OS2 L1&2) Flashcards
Processes
program in execution (with restricted rights)- dynamic entity executing or ready to execute
Job
unit of work in a time sharing/multi-tasking OS
how does a user create a process
double click
cmd
What happens when two copies of a program are running two separate processes
OS generally smart enough to not duplicate resources and allow these processes to share those that they can share
Relationship between process and the OS kernel
process is the abstraction for protected execution provided by the operating system kernel
process needs permission from kernel before accessing memory of any other process - amongst other things
Kernel maps user process to be executed by hardware?
True/False - programs can spawn other processes
True, they can also be an execution environment for other processes
Parent process
spawns children processes - forming a tree of processes. Processes are identified by PID
innit systemd launchd
examples of parent processes that are the parent of all other processes on the system first process executed manages all other processes started by kernel PID = 1
Program’s execution context
basically, surrounding info needed for running the process effectively
- state of processor (processor context) which is the value of its program counter and all registers
- process memory map - identifies various regions in memory that have been allocated to the process
Process lists
used to keep track of processes
each entry is a process control block - contains info that kernel needs to know about the process
process groups
groups of process that are related so that they can be signaled
every process is a member of a group
Fields in PCB
process state
program counter
CPU registers - contents of all process centric registers
CPU scheduling information - priorities etc
Mem management information - mem allocated to process
Accounting info - cpu used, clock time elapsed
I/O status information - i/o devices allocated to process
for( )
create new process
wait( )
e.g. parent can call wait( ) and wait for child to finish executing before executing itself
exec( )
overlays a process - replaces a process’s mem space with a new program
Resource sharing options between parent and children
share all resources
children share subset of parent resources
no sharing
Execution options for parent and children processes - after fork( )
execute concurrently
parents wait until children terminate
Address space option for parent and children processes
duplicated
child has other program loaded into it
how many processes per processor at a time
1
new state
process being created
running
instructions being executed
waiting
process waiting to event to occur
ready
process waiting to be assigned to a processor
terminated
process finished execution
“System is in the context of that process”
When a process is running its said that System is in the context of that program
What needs to be saved during a context switch
enough information so that the kernel can switch back to the earlier process and continue from the exact same place it left off
Short term scheduler
selects process to be executed next, invoked frequently
long term scheduler
selects processes to be brought into the ready queue. - controls the degree of multitasking
i/o bound processes
spend more time doing i/o - many short cpu bursts
cpu bound processes
spend more time doing computations - few long cpu bursts
Reasons for IPC (cooperating processes)
information sharing
Computation speedup - parallelization
Modularity
name the two IPC models
shared memory
message passing
explained shared memory as an IPC model
two or more processes agree to remove restrictions (relating to preventing one process from accessing another’s memory) and exchange information by reading and writing data to shared areas
explained message passing as an IPC model
send() receive() - parents and children can send messages via a pipe
what happens upon process termination?
executes last statement and asks OS to delete it using exit( ). On exit a process may return status value (typically an int) to waiting parent process. On exit all process resources are reclaimed by OS
why is a terminate system call only allowed to be invoked by parent process?
otherwise user or misbehaving application could kill another process
parent needs to know identities of children to terminate them
why would a parent process terminate its child process
child exceeded allocated resources
Task assigned to child is no longer required
parent is exiting and OS does not allow child with out a parent
zombie process
A zombie process or defunct process is a process that has completed execution but still has an entry in the process table as its parent process didn’t invoke an wait() system call.
Orphan process
An orphan process is a computer process whose parent process has finished or terminated, though it (child process) remains running itself.