Threading makes an application program implementation faster an Experimental view

M. Shanthi & George T. Manohar

Introduction

A thread is a single line of execution within the process of application. That means that inside the application, more than one thing can happen at the same time virtually. All threads can have direct access to the data in application. Here are some typical situations where threads are used: To move a time-consuming initialization task out of the main thread, so that the GUI comes up faster. Examples of time-consuming tasks include making extensive calculations and blocking for network or disk I/O (loading images, for example).

Multithreading is the technology through which we can develop applications that perform concurrent tasks. Multithreading is effective on both single-processor and multiprocessor systems. Today's traditional single-core processors can only process one thread at a time, spending a majority of time waiting for data from memory. 

Multithreaded and distributed computing are gaining a wide popularity in the area of high performance computing. Availability of high performance computer networks and sophisticated software environments are allowing to  perform parallel/concurrent computing on commodity hardware. Recently, threads have become powerful entities to express parallelism on these shared memory multiprocessor (SMPs) and multi computer (MPPs/Clusters) systems. In multiprocessors, threads are primarily used to simultaneously utilize all the available processors whereas, in uniprocessor/ multicomputer system, threads are used to utilize system resources effectively by ex- piloting the asynchronous behavior (i.e., opportunity for computation and communication overlap) of threads. These factors have given an impetus for further popularity of multithreading

Multithreaded Applications

Developers design multithreaded applications to maximize processor performance capabilities. Multiple threads   can make an application more responsive. When multiple threads are executed, performance is increased because the OS can execute one thread while another thread is idle waiting for data or other input. However, only one thread can execute at the same instant in time.  With HT Technology capable processors, the OS can dispatch two threads from a multithreaded application to run concurrently, one on each of the two logical processors. The HT Technology processor using out-of-order instruction execution and resource sharing accomplishes this. Multithreaded applications gain even more performance on processors than on HT Technology processors .

Performance Estimations

Duplication of processor resources increases the performance potential of the processor. HT Technology benchmark tests show some server applications can experience a 30 percent gain in performance if both logical units are 100% utilized. The greatest gain comes when a thread may stall, such as when a thread waits for data from memory or from a disk drive. In this case, the second thread can fully utilize the execution unit. The Power of Multithreading determining how the code should run, but it could be important for licensed software where the number of physical processors determines the cost of the application, such as the operating system seat licenses. There isn't a significant performance difference between a multithreaded application and multiple single threaded processes as far as HT Technology is concerned, so long as the CPU utilization isn't bunched up within a single process.

The advantages  of  multithreading

  • Reduces computation time
  • Improves performance
  • Improves responsiveness
  • Enables better interaction between users and multithreaded applications
  • Increases efficiency when managing resources
  • Reduces time to market
  • Reduces human resources costs
  • Provides portability
  • Improves users' perceptions of the products
  • Increases competitiveness
  • Reduces contentions for resources such as OS structures, disk, memory, CPU, and so on                    

Disadvantages

  • There is a runtime overhead associated with creating and destroying threads.
  • Having too many threads running at the same time decreases the performance of  entire system. Careful design required while using multithreading otherwise  application will be difficult to maintain and extend.
  • Threading bugs are difficult to debug and resolve.
  • More threads does not mean a faster responsive application, instead it can decrease the performance of application.

Experimental study

Threading in Application databases

Program is written in Java with and without threads for banking application. When we run the program, program with thread takes less time than the program with out thread. In this application we considered only two operations deposit and withdraw. Database contains 20 records. The time is varying based on the number of records and the amount deposit. For example the following table shows the data for deposit of Rs.1000.  the program is run in Pentium  processor with HT supported machine and database used MS ACCESS AND JAVA SWING .

Table I  -  CPU time for Database  Interactions

S.No

 With out thread

 With thread

1

281

140

2

485

125

3

172

109

4

437

125

5

219

94

6

625

156

7

172

156

8

157

152

9

250

187

10

171

156

If average is considered   296ms   for with out thread and 140 ms for with thread. From the above table it is observed that threading is really advantage in all types of applications                    
Multithreading in multimedia applications

Threading is really advantages because it increases the processor time irrespective of the image format. This is observed by writing a multimedia program in Java for loading the images. The program is written with and with out threading concept and executed in Pentium IV Processor with HT enabled systems. Based on the tabulated values, it was evident that threading gives better performance.

Table II  -  CPU time for Multimedia Image Loading

S.No

No of threads

Time in ms

1

Without thread

203

2

one

188

3

two

187

Conclusion 

From the above study , it is very clear that  threading is advantages. But to avoid overhead  involved in creation and deletion of threads, threads can be created before initializing the task or pre fetch  arrangement can me made. In future this can be implemented in application programs to reduce the overhead.

References

[1].Effects  of  HTT  in  the   response   time   of business applications white paper 2004

[2)Developing Multithreaded Applications: A Platform Consistent  Approach.  
Intel Development Group .

[3] Introduction to Hyper-Threading Technology:

[4]  Multithreaded Programming for Next Generation MultiProcessing Technology:
http://www.intel.com/technology/hyperthread/multi_nexgen/

[5] Dean  M.  Tullsen,  Jack  L.  Lo,  Susan  J. Eggers,  and  Henry  M.  Levy.  Supporting  fine- grained             synchronization   on   a         simultaneous multithreading  processor.  In  Proceedings  of the Fifth      International             Symposiumon      High- Performance  Computer Architecture,  pages  54–58, Orlando, Florida, January 9–13, 1999. IEEE Computer Society TCCA.

Description  of Authors

Author 1

M.SHANTHI
Asst.Professor
Dept. of Computer Applications, Velammal Engineering College,
Chennai – 600 066, India.
Phone No. 26591507 , 26591537
Email : sha_karnan@yahoo.com
 
Author 2
GEORGE T. MANOHAR
Dept. of Electrical Engg., IIT Madras,
Chennai – 600 036, India.








}