Multitasking when a computer works on several problems at once.
Prallelism is when several problems are being worked on in a single time slice. Concurrency is when one problem is worked on per time slice, but the problem being worked on changes from slice to slice.
True parallelism requires one hardware thread (or CPU core) per task. The kernel offers preemptive mulitasking as an alternative for when CPU time is over-committed (which is literally always, and badly); it "pre-empts" tasks and switches between them in each time slice, which is effectively a kind of transparent concurrency.
Cooperative multitasking is the opposite of preemptive multitasking, and in this case each task decides for itself when to relinquish control to another task. A common way of achieving this is coroutines.
A process is a task with its own isolated memory space. A thread is a task within a process, which shares its memory space. Multithreading is using multiple threads, multiprocessing is using multiple processes.
Did I miss anything?
@sir Processors can also do parallelism on single-threaded programs. They're allowed to process instructions out of order as long as the result is the same, which is why you often see compilers reorder statements that are related to add unrelated statements in between.
@ben deep magic here, out of scope
@ben I thought about talking about pipelining and speculative execution and so on but better to leave that for a CPU-design-specific post
@sir which part is shit and/or broken ?
@sir this is an insteresting take, IMHO multithreading is not fundamentally broken but is de-facto broken.
However I think the Rust language can really help unbreak multithreading as it enforce correct sharing of resources between the threads. Which is the de-facto broken part.
@sir @amdg2 @ecs I just realized I read https://drewdevault.com/2019/03/25/Rust-is-not-a-good-C-replacement.html a year ago *face palm*. Brain is fried.
@sir I don't think your definition of concurrency is right.
@sir upon re-read, I think it is correct enough for the context in which you've stated it
@sir Failure modes? Debugging/diagnosing?
These two aspects are pretty critical for every system (not only software).
@_1751015 lol I wasn't trying to explain all of computer science in my post
thanks for the disambiguation, this actually helped me.
The last paragraph is unclear to me: what precisely is the difference between thread, process and task?
@maltimore a task is anything your computer is working on. A thread is a task which shares the same address space with other tasks; a process is a task with its own address space. More or less.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!