Lib Sub-System: Threading

01 The Semys Library (and probably its using application code) are working on a multithreaded basis. Because the relevant functions for multithreaded applications are not standardized, the common ones are abstracted within the Threading sub-system.
02 The following three objects are required as a basis for Semys applications:
  • Thread: Obviously
  • LocalMutex: To secure data that is accessed by several threads
  • Signal: To notify a thread about a certain event / condition
03

Thread

A thread consists of a run function that ends the thread if the function returns and an abort function to be able to notify the thread about a stop request.
04 There exist no possibilities to halt or abort a thread natively. Halting threads is considered insecure and aborting threads probably leads to resource (memory) leaks.
Every thread can be stopped gracefully.
05 Thread Functions:
06

LocalMutex

A mutex object is a barrier that allows only one thread to access a locked resource at a time (mutually exclusive). The mutex object used in Semys is called 'local' because some environments differ between mutex objects that can be seen only by the process and those seen by all processes.
07

Note: See the basic idea about the messaging system: When used properly, there hardly is any need of mutex objects within the application; Only the message queues need to be locked.

08 These mutex objects can not be locked recursively.
09 LocalMutex Functions:
10

Signal

A signal object is used to notify a thread about an event or condition. It is called a signal because the signal stays set (signalled) until the thread that waits for the signal has actually recognized it. There is the possibility that a signal becomes set but the thread waiting for the signal wasn't currently watching it.
11 A signal object is always meant to be waited for by only one thread. (Although several threads may set the signal - even the to-be-signalled thread itself.)
12 Signal Functions:
13 Reference: SemysThreading.h
Implementation: Semys Library

Goto: Main Page; This page is part of the Semys software documentation. See About: Documentation for details.