processes Flashcards
what is a process
a running instance of a program
what is the role of the linker
puts object files together to create an executable
what is the role of the loader
takes an executable file from the file system
reads the file to make sure that the different libraries needed are loaded into memory so they’re available for use
then it makes an execution
what is a thread
a flow of execution within the process; sequencing instructions as part of a program
why are threads more efficient than processes
dont need to have file permissions and other recourses
what is the process context
information that describes what the process is doing
what could a process context contain
registers
memory layout
open files
where programs are within a file; r/w position
access permissions to a file
any communication happening
timers and alarms
recourses used by child processes
what is a process control block
a table containing the process context
what is the stack typically used for
implements function calls; a new stack frame is added at the top
it stores parameters and return values and any declared variables
what is the role of the heap
dynamically allocated memory; holds things that you wont know the length of
e.g. strings, queue, by overestimating the size
requests at runtime
how do we expand the heap
using sbrk()
what is the problem with the heap overestimating the size of the data
creates wasted space
meta data
describes the layout of the program and is used by the loader to build the memory layout
also includes libraries we want to use whilst a program is running
how do we run multiple processes
we switch between and store the context of the process being suspended in the process control block
we then determine which process will run next and recover the context and load it into registers then continue
what is the point of the process hierarchy
allows processes to spawn child processes
why do we limit the amount of children that a process can have
so it doesnt get an advantage in the system as more children could mean more resources
why do we have a limit on the number of processes allowed in the system
so it doesnt get overwhelmed
how do we ensure proper resource control within the process hierarchy
each process is responsible for its own resources as well as its children
what call so we use to create a process
fork()
how does fork() work
when called it creates a duplicate process which are identical except for the values returned to them
what does fork() return if youre a child
0
what does fork() return if youre a parent
the process id of the child
what is the point of the parent receiving the process id of the child after calling fork()
allows you to call want() for any children to get their information
what happens when a child calls exit()
it enters a zombie state; the child has finished execution however all resources are still held in the os
when the parent calls wait() then all resources are transferred to the parent which is added to the resource total that the parent has to account for
what is an uninterruptable io mode/operation
once you start the operation you must complete it
what is an interruptible io mode/operation
can be stopped to complete other processes
what is the life cycle of a process
starts at ready; it has been initialised and is ready to run
it is moved to the running state once selected for execution
can either carry out an io operation, we can choose when we want it to stop, or it will run for a defined amount of time in the system
the process exits then enters the zombie state and recourses are ready to be collected by its parent