cinera_handmade.network/cmuratori/hero/code/code123.hmml

47 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

[video output=day123 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Interlocked Operations" vod_platform=youtube id=_olNhuuRYxo annotator=dspecht annotator=Miblo]
[2:33][Blackboard: Thread Synchronization / Communication]
[3:31][Blackboard: Processes]
[4:08][Blackboard: Threads]
[5:22][Blackboard: Problem #1 - Knowing what work to do]
[7:05][Blackboard: Problem #2 - Sync / When work is done / visible]
[11:15][Blackboard: Conceptualising how threads work]
[12:34][Blackboard: Doing a busy-wait loop]
[16:19][Blackboard: Preventing multiple threads from doing the same work]
[18:57][Blackboard: x64 provides special instructions]
[19:46][Blackboard: "locked exchange"]
[24:00][Blackboard: "interlocked compare exchange"]
[26:51][Put on the Pig Hat]
[28:43][Blackboard: Being slyfox with the other primitives][quote 96]
[30:02][Blackboard: "reads and writes" in a multithreaded context]
[31:56][Blackboard: cache lines]
[39:34][Take off the Pig Hat and open the code]
[40:17][win32_handmade.cpp: Make four threads that do different work]
[42:41][Run Handmade Hero]
[42:57][Make the threads look for work to do]
[48:51][Run and inspect the debug output]
[50:17][Moment of realisation: You need to let ThreadInfo values persist]
[51:38][Inspect the output]
[52:32][Explain what's happening]
[54:50][The writes to EntryCount are not in order]
[57:04][The reads are not in order]
[58:14][Q&A][:speech]
[58:40][@tenbroya][Is your use of "for (;;)" instead of "while(1)" a stylistic choice or is there a benefit / drawback I'm missing?]
[1:00:17][@gasto5][What's the problem with not being interlocked and seeing the same value, as your "TODO" suggests?]
[1:02:39][Blackboard: Why two threads did the same work]
[1:05:29][@quikligames][Do mutexes that I've seen used for multithreaded code in other places rely on those interlocking instructions, or are they something completely different?]
[1:06:23][@emanresuon][What is your opinion on lockless queues?]
[1:08:18][@sedihglow][What's the point of an infinite loop to begin with? It ends at some point, doesn't it?]
[1:08:46][@my_twitch_sn][What threading libraries do you recommend and why (e.g. boost or pthreads)?]
[1:09:37][@lavisan][What's better: a job scheduler from where each thread can get a job, or separate queues for each thread?]
[1:10:45][Blackboard: "Single producer / Single consumer" vs "Single producer / Multiple consumer"]
[1:14:39][@pseudonym73][I think that the point of "lockless" is that it doesn't use an operating system-level lock]
[1:14:55][Blackboard: "lock free"]
[1:16:46][@rygorous][Hey Casey, an InterlockedIncrement is a lock-free operation! (The terminology is shitty. The original term is "non-blocking" which is more useful)]
[1:17:40][@gasto5][Is it reasonable to synchronize the receiving of network packets on one synchronized thread?]
[1:19:16][@cubercaleb][Later in the development cycle, will you go over threading for other operating systems like Mac and Linux?]
[1:19:45][@rc1290][What are the advantages of having a queue of jobs, instead of creating a thread every time you add a job?]
[1:20:04][Blackboard: Overlap vs Performance]
[1:24:50][Recap and glimpse into the future][:speech]
[1:28:08][Close things down][:speech]
[/video]