Concurrency - ayaohsu/Personal-Resources GitHub Wiki

Thread: execution sequence of instructions
Can think of every thread like a mini CPU
It is executed independently, just like a literal thread, and they never cross.

For event scheduling:
When the event comes, it executes the sequence (event scheduler thread)
After finishing that, it waits.

For different processes, there is hardware level limit between memory for accessing. A process will never use the other memory of other processes.
But inside the process for threads, there is no such protection.
Every thread can access all the memory of the process. It is all shared, which is why there will be issues: deadlock, race conditions, livelock.

Our trick to solve this problem
"Processing memory is only accessed by the processing thread"
It's how our software is good in terms of performance and robustness
Robustness comes in when you don't have a thousand conditions to check (that is the problem for a lot of multi thread programs)
We only use one thread to process events. And we have simple code, not complicated at all