-
Goroutines are the most basic unit of concurrent execution
-
Amdahl’s law explains that the effect of parallelisation depends on how much of the process is sequential
- Gustafson’s law argues that the size of a problem changes when you have access to more resources
- As the problem size increases, generally, the non-parallel portion of the problem remains constant allowing the problem to scale linearly with more parallel resources
Interrupts
- An interrupt is used to stop the current execution and notify the system of a particular event
- Interrupts are handled by the interrupt controller
- The interrupt controller handles interrupts coming from multiple devices and notifies the CPU to stop the current job (and save the job’s context)
- A hardware clock can also interrupt the current execution to ensure all jobs in the run queue are given a chance to execute
- The OS scheduler decides which job to do execute from the run queue
- Interrupts can be expensive as it involves context switching (saving the current job state and then loading the new job from the run queue)
- The job state is called the process context block, which stores the CPU register, program counter (also the instruction pointer) and information about the memory
Processes
-
A process represents a program running on the OS
-
A thread is a construct within the process that’s lightweight and aids concurrency
-
fork()
is a UNIX system call used to create a copy of an existing process -
After
fork()
is run, the child process can determine to keep or clear the copied resources -
Each process (parent and child) can determine what instructions to run after
fork()
is called (based on the return value offork()
) -
Creating processes can be expensive as it consumes more memory and uses more CPU cycles
-
- WHAT IS TIME SHARING?
- WHAT IS A HEAP?