top of page

Studying Complex Game Systems Part 1: Multi-threaded Programming

  • Jun 7, 2020
  • 2 min read

The first topic for our Complex Game Systems subject, is threading and multi-threaded programming. A thread is essentially a function that runs asynchronously to other threads. Something that processes asynchronously doesn’t have a dependency relationship between requests or replies and their timing. An example of one of these functions in the C++ language is the main() function.


During this topic we learnt how to prevent the corruption of our data when threads are accessing it in memory. This is done by controlling the amount of threads that can access it during its write operation. In our threading exercise we got to practice doing this using the Mutex and Atomic methods. Mutex stands for ‘Mutual Exclusion’ and is an object that can only be locked and unlocked by one thread at a time. A thread locks the data before its reading, incrementing and writing operations, and then unlocks it when the operations are complete, allowing another thread to access the data. Data and instructions can be made ‘thread safe’ using Atomic types. Atomics are template structures that preserve the order of instructions being processed when following a specific memory order. Atomic types possess functions that will assist in locking and unlocking data based on memory order. Memory order refers to the C++ standard library’s memory_order functions. These functions give instructions to the compiler on what order atomic types are read or altered when being processed. Atomic types are used to modify instructions to be non-uninterruptible. Here are some examples of both of these methods being used in our threading exercises:



In this topic we also learnt more about Graphics Processing Units (GPU’s) and General-purpose Programming GPU’s (GPGPU’s). The origin of the GPGPU is rooted in GPU’s becoming capable of transmitting and receiving data to and from the CPU. Due to this advancement, GPU’s can handle more than just graphics, they can also be used for processing things such as physics or audio.


References:

Multi-threaded Programming Lecture

Race Conditions, Mutual Exclusions, and Deadlocks Lecture

Common Design Patterns Lecture

Keywords and memory order Lecture

Key words and Memory order Tutorial

Common Patterns Tutorial

IBMKnowledgeCenter, 2020. Introduction To Asynchronous Processing. [online] Ibm.com. Available at: <https://www.ibm.com/support/knowledgecenter/SSGMGV_3.1.0/com.ibm.cics.ts31.doc/dfht7/dfht7am.htm> [Accessed 9 May 2020].

Comments


Commenting on this post isn't available anymore. Contact the site owner for more info.
  • Twitter
  • LinkedIn
  • Mail_edited_edited_edited_edited
bottom of page