lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

Multithreading.md (1271B)


      1 +++
      2 title = 'Multithreading'
      3 +++
      4 # Multithreading
      5 each process in the operating system has a thread
      6 
      7 thread — thread of control whose state consists of contents of program counter and other processor registers (a specific process)
      8 
      9 two or more threads can run on different processors, executing either same part of program on different data, or different parts of a program, or different programs
     10 
     11 multitasking two or more programs on same processor
     12 
     13 time slicing — OS selects process that’s not blocked and lets it run for a short period of time
     14 
     15 context switching — OS selects a different process at the end of the time slice
     16 
     17 timer interrupt — interrupt-service routine to switch from one process to another
     18 
     19 hardware multithreading:
     20 
     21 - processor has several identical sets of registers, each for a different thread
     22 - this includes multiple program counters
     23 - makes context switching simple & fast, just change a hardware pointer to use a different set of registers, in one clock cycle
     24 
     25 coarse-grained multithreading: on a cache miss during Load/Store, switch to a different thread and continue fetching/executing other instructions
     26 
     27 fine-grained/interleaved multithreading: switch threads after every instruction is fetched, increasing processor throughput