Processes and threads Flashcards
What is a process?
A process is a running program
States of the process
created, waiting, running, blocked, dispatched, interrupted, terminated
Created state
Process has been retrieved from the memory is move to queue (waiting)
Waiting
Wait in the queue
Context switch
Running
Wait for resource (such as input or a file to open), then move to waiting again
Dispatched
Loaded into the CPU, ready to be run
Interrupted
When interrupt occurs, save and go back to the waiting
Terminated
delete the process once its done
Context Switch
Switch the process that’s currently in the running process with the one in the waiting
Multitasking
Threads
Simple functions
Couple lines of code
there can be one or more threads in the computer
Created by the process
Subset of the process
Share the data of the process (variables, functions, files, code)
All of the process threads must cooperate
concurrent execution - computations done so quickly it seems like they are executed at the same time
Multitasking
Cooperative and Pre-emptive multitasking
efficient , concurrent
Cooperative multitasking
Do tasks so quickly it seems like they are executed at the same time
Pre-emptive
assign a priority to threads and use a scheduler as well as a time slice (halt the execution of a thread and move it to waiting for another one to be calculated)
Interrupts
direct message -> electrical signal
IRQ - a line (wire?) reserved for interrupts
Get the CPU’s attention, move the current process form running to waiting, handle the interrupt, continue the process
*timer interrupt : time-based scheduling, occurs every x milisecond
PIPELINING
it’s purpose is to be able to run multiple cycles and therefore instructions at the same time
If the entire time of fetch, r/d, alu, mem and wrtie is x seconds:
Latency stays the same (x )
Throughput : 1 instruction/(x/number of cycles)
May run intro trouble when encounters a conditional statement