Download presentation
Presentation is loading. Please wait.
Published byDarlene Johns Modified over 9 years ago
1
Multi-Threading and Load Balancing Compiled by Paul TaylorCSE3AGR Stolen mainly from Orion Granatir http://www.gamasutra.com/php-bin/article_display.php?story=4006
2
What changed? Single Thread Computer games have been used since day 0 The person to blame is Gordon Moore* * Not really it just feels good to blame someone!
3
Moore’s Law http://en.wikipedia.org/wiki/Fil e:Transistor_Count_and_Moore %27s_Law_-_2008.svg The Complexity of IC’s will go up exponentially We mutilated this into CPU speed will increase expo. This all F*#ked up a few years ago when we started pushing the boundaries of transistor miniaturisation To keep the processing increase we went with Multi core processors
4
It all goes bad.... http://www.gamasutra.com/php-bin/article_display.php?story=4006
5
Multi-Core and Threading http://www.gamasutra.com/php-bin/article_display.php?story=4006
6
Network Assimilation http://www.gamasutra.com/php-bin/article_display.php?story=4006
7
Processes and Threads
8
The first crappy threading code you’ll see CATCTATCATTC TATCTACTATC ATCTACTATCT ACTATCTACT CTTACTCAT
9
Distributing Load (You need to manage your employees)
10
That was a better Threading Model But still not good enough for today's machines
11
Distributing Load even more!
12
Learning to Share All cats need the Shovel for their Quest
13
Learning to Share Cat has the Shovel
14
Learning to Share Cat has the Loot
15
This is what Thread Locking is for Now how do we go about locking them??
16
Critical Sections When one thread enters the critical section, the others will have to wait......
17
Critical Sections And wait....
18
And wait...
19
Critical Sections Keep them small!!! A lot of CPU time can be wasted waiting.... And waiting...
20
Mutexs and Semaphores
25
A Semaphore is like using Multiple tokens (it retains a value) Critical Sections are fastest, but limited to one process Mutexs are slower, but globally accessible Semaphores are great for things like allocating your memory buffers
26
Events
32
Atomic Operations http://www.breadonthewaters.com/add/0888_nuclear_explosion_large_clipart.jpg
33
Atomic Operations 5 + 1 + 1 + 1 = 8
34
Atomic Operations 5 + 1 + 1 + 1 = 6!!
35
Atomic Operations This is why we need atomic operations
36
Atomic Operations This is why we need atomic operations
37
Deadlocks
40
Race Conditions The ‘race’ is a term for when your code expects threads to return in order, and they don’t!!!
41
Race Conditions
44
Network Code Example
49
The Main thread would then need to wait for all Network threads to finish before it resets the NetworkUpdateEvent and continues How would you solve this?
50
References http://www.gamasutra.com/php- bin/article_display.php?story=4006
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.