Low Level Programming Sessions Summary 17
29th February
This week we talked a lot more about threading and how to
properly run tasks in parallel and the methods used to do this effectively.
Pipelining is the first method we discussed and I feel this
would be the main way to go about threading different aspects of the system.
Essentially we take a different part of our system, and run it in parallel to
the main game engine loop. This means we can run an input poll function at the
same time as our main game loop, rather than having that as part of the update
loop. We take out bits of functionality, and give them their own processing
loop. This is great as we can now run multiple processes at the same time.
We should sleep our network threads when they are not in
use. An event processing thread is ideal for this since it is dependent on what
the program is doing at certain times.
Another technique is to use worker threads which are a
dedicated subsystem which can take smaller tasks and work on them when they are
available. Otherwise, the thread is sleeping and functionality shifts to the other
threads.
The other game threads can offload work to the worker thread
by packing subtasks up and then signalling to the worker thread with a
semaphore that there is work available. Once there is, the worker thread is
called and works through what it needs to.
We also discussed mutexes and thread locking. If we don't use these, then threads may run out of sync and perform necessary operations before or after we need them to. Thus, we need to lock and unlock threads so that they can be run in sequence or skipped if we need them too. This grants us greater control over threading.
Overall I understand how threading works and how to implement it in my code, and I am eager to start using it in our assignments.
No comments:
Post a Comment