Processes and Threads Flashcards
what is a process in relation to a program?
a program is a bunch of instructions on a strorage medium, a process is a unit of work being executed on a computer. a program is run as one or more processes
what functions of processes does an OS facilitate? (5)
- creation
- deletion
- scheduling
- communication
- syncronisation
what are 5 states a process can be in?
- new
- ready
- running
- waiting
- terminated
what is a PCB?
a process control block is an OSs representation of a process, held in a table or list
allows OS to suspend a running process and later restore its state
what is a context switch?
switching the CPU between execution of processes. the context is the process state, stored in the PCB list or table. there is no useful work done while switching
what do parents and children share?
when forking, the child gets a copy of the address space and they share file handlers. they are identical apart from their pid
what do threads share?
Share file desc and process space, have their own stacks and registers, can write to each other’s variables. Can communicate easily via variables.
have their own registers and stack
what is overwritten when exec is called?
everything, except the process id and file descriptors
how can processes share memory?
shm_open and mmap(). creates shared memory in heap
why are threads useful?
a process has its own private address space and its inconvient for IPC and expensive to switch contexts
useful in a server handling incoming connections, or a word processer waiting for input