Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Some Thread Fundamentals

Threads, sometimes referred to as lightweight tasks, allow an application process to be divided into precise sub-processes executing concurrently. Conceptually, a thread is the smallest amount of processor context state necessary to encapsulate a computation. Practically speaking, a thread consists of a register set, a program counter, and a stack. Due to the minimal context state requirements, threads have a very fast context switch time. Since threads operate within the application’s context, each thread has full application global access and shares the same address space, file access paths, and other system resources associated with the application.

Although threads have many benefits, the two most important are ease of logical program structure and performance. Program structure is simplified because each application task can be coded as an almost independent subsystem. If tasks interact and/or share resources, they must use synchronization objects, which the API provides. Performance is enhanced since some threads can make progress while one or more other threads may be in a wait state. For example, a keyboard thread waiting for a keystroke does not have to block all other code executions.

Concurrent thread execution means two or more threads are in process at the same time. If one thread blocks for some reason, another thread from the same program executes in its place. This feature is especially relevant to the FairCom Server, or any other I/O bound application. Parallelism occurs when two or more threads execute simultaneously across multiple processors, utilizing the power of multi-processor systems.

Multi-threaded benefits, particularly performance, are directly related to efficient thread management. This is precisely why FairCom determined that a well written, portable thread management subsystem was the key to its multi-thread support. By allowing our ctThrd API functions to handle your thread management needs, you will have an efficient, system-independent approach for your multi-threaded application development.