May 8 2009

MultiThreading and C++

Multithreading and C++Grasping the jist:


Multithreading is growing in pertinence in modern programming for a good many number of reasons, one of the most primary being that Windows supports multithreading. While C++ does not feature built-in support for multithreading, it can be used to created multithreaded programs, which is the subject of this article. It is taken from chapter three of The Art of C++, written by Herbert Schildt (McGraw-Hill/Osborne, 2004; ISBN: 0072255129).


C++ is not carrying built-in support for multithreaded processes but, is dependent on OS for it. The question that now pops up is that what benefits can a C++ program have with no built-in support for multithreading.


Advantages of No Built-In Support for Multithreading in C++


The absence of a built-in support for Multithreading makes C++ programs directly utilize the multithreading features of the operating system provided in Kernel and C++ programs, take up less time and deliver better performance than the ones written in other languages like Java that need to internally call C++ programs.



Let’s understand this further:


For example, the access to a shared resource can be controlled using the synchronization objects like semaphores, mutexes, event objects, waitable timers, and critical sections. The calls for accessing these objects will be different in Windows and Unix based systems and one needs to be careful while porting applications between the operating systems. However, this extra step of changing the calls from one OS to other can be traded for the better performance of the program as supported by OS. With C++, one can gain access to all the features that the operating system provides. This is a major advantage when writing high performance code.

2 Comments on this post

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog