Hardware Concepts

Hardware

Description

uniprocessor

refers to a single CPU chip with 1 execution-unit/core

multicore

refers to a single CPU chip with multiple execution-units/cores

hyper-threading

a single physical execution-unit/core with hyper-threading appears as two logical/virtual units to an operating system

multiprocessor

refers to a system that has ≥2 CPU chips

Software Concepts

Program - Process - Threads - Heavyweight/Kernel/OS/Lightweight/Virtual/User-Mode Threads / Fibers - Task (Software)

Task Type

Description

program

processes

  • is a program loaded into memory (i.e. in execution)
  • processes are independent sequences of execution
  • a process is an execution of a program
  • processes run on separate memory spaces

usually starts with a single thread i.e a primary thread but later down the line of execution it can create multiple threads

threads

  • threads are independent sequences of execution
  • a thread is an execution of a program driven by the environment of a process
  • threads run in the same memory space of its parent process

virtual thread
fiber

  • a thread is managed and scheduled by the operating system, while a virtual thread is managed and scheduled by a virtual machine

task

  • either a process or thread or virtual-thread
Link to original

Hardware & Software: Putting It Together

Hardware Diagram

Hardware & Software Diagram

Whenever there are more software threads of execution trying to execute at any given time than there are available hardware (simultaneous) threads of execution, then these software threads will be “interleaved” among the available cores. In the case of a “uniprocessor” (one CPU core with no hyper-threading), if you have more than one software thread, they will always be interleaved. If you have a 4-core CPU with hyper-threading, that’s 8 “hardware threads”, meaning the CPU can execute 8 simultaneous threads of execution at the same instant, so if you had 8 software threads trying to run, they could all run at once; but if you had 9 software threads, one of the hardware threads would have to interleave a pair of threads (the exact pair of threads chosen would depend on the operating system’s scheduler implementation).

General Concepts

  • synchronous - tasks are executed one after another, each task waits for any previous task to complete and then gets executed
  • asynchronous - when one task gets executed, you could switch to a different task without waiting for the previous to get completed
    • asynchronous with outside entity - the dispatching of task(s) to an outside entity, leaving the originating program free to execute other task(s) until it receives a signal from that entity (e.g. Ajax call). That signal can be either: task-finished or error
    • asynchronous without outside entity - similar to multi-tasking
  • concurrency - multiple tasks (e.g. processes or threads) in execution, either: simultaneously or not
    • parallel and distributed - multiple tasks in execution simultaneously. It achieves this by distributing tasks to multiple resources (e.g. processors, execution-units)
      • parallel - communicate over a shared memory
      • distributed - communicate over a network
    • multi-tasking - multiple tasks in execution but NOT simultaneously. There is only 1 resource that executes these tasks, therefore at any given moment only 1 task is actually executing code. However, multi-tasking emulates “parallelism” via context switching (i.e. execution time of tasks are interleaved with each other on a single resource)

More Terminology

Term

Description

Diagram

multi-programming

the execution of multiple programs within a computer

multi-tasking

a type of concurrency where multiple tasks (e.g. threads or processes) are executed on a single resource (e.g. uniprocessor, core)

for example:

  • multi-threaded or same-threaded application in a single core environment

single-threading

the execution of a single (thread/sequence-of-instructions)

multi-threading

the execution of multiple (threads/sequence-of-instructions) concurrently

threads share common data, which can cause problems (e.g. deadlocks, livelocks, race-conditions, etc)

multi-threading in a environment of:

  • multiple cores - similar parallelism
  • single cores - similar to multi-tasking

same-threading

a type of multi-threaded system where threads do not share state with each other

however, threads can pass messages between each other via sockets

since threads don’t share state, they don’t inherit multi-threaded problems (e.g. deadlocks, livelocks, race-conditions, etc)

multi-processing

the availability of multiple processors/cores which can execute multiple (processes or threads) in parallel

Synchronous/Asynchronous vs Single/Multi Resource

Resource = Processor or Execution-Unit or Virtual-Unit

Synchronous

Asynchronous

Single-Resource

r1: -|<==A==>||<===B===>||<==C==>|---
r1: -|<=A=|<=B=|<=C=|=A=|=B=|=C=>|=A=>|=B=>|-
      ʌ    ʌ    ʌ               ʌ    ʌ    ʌ
      |    |    |               |    |    |
      |    | C-Start -------- C-End  |    |
      |    |                         |    | 
      | B-Start ---------------------|- B-End
      |                              |
     A-Start ---------------------- A-End

Multi-Resource

r1: -|<==A==>|-----------------------
              \  
r2: -----------|<===B===>|-----------
                          \   
r3: -----------------------|<==C==>|-
r1: -|<==A==>|------------------

r2: -----|<===B===>|------------

r3: -------|<==C====>|----------

Subpages