Multiple approaches to multithreaded applications
Multithreaded Applications: Multithreaded programming is coming more to the fore with the Intel Pentium 4's support of Hyper-Threading Technology. The approach you choose for thread synchronization--using locks or lock-free--depends on the type of application you're building. More on software multithreading and multithreaded programming

by George Walsh, freelance researcher and writer. Intel Corp.

The different means of building multithreaded applications have been a source of some debate. Some developers think the traditional method—using locks—is best, while others are proponents of avoiding the use of locks entirely. Though the different camps each have their points, here are the basics of the different methods, along with an attempt to outline their respective pros and cons.

Multithreaded programming, until recently, provided the greatest benefits to those building applications in the world of servers, where execution on multiple processors with access to shared memory was the norm. While programmers of server applications are still building programs that distribute the processing burden across more than one processor, the advent of the Intel® Pentium® 4 with Hyper-Threading Technology (HTT) has brought multithreading to the desktop. HTT makes a single physical processor function as two logical processors, allowing developers of desktop software to take advantage of the virtues of multiprocessing. Whether you're building server applications or discovering the advantage of desktop multithreading, you'll find—as in all types of programming—different schools of thought on how to best reap the benefits of distributing and synchronizing threads while avoiding such pitfalls as deadlock. Here, we'll try to make some sense of the design of multithreading systems.

Synchronization: The Key to Multitasking Benefits
Threading is nothing new to most programmers. Even those targeting single-processor, non-HTT environments may use threads as a matter of convenience in programming and debugging. Sometimes, separate threads are spawned off to handle specific tasks. However, on multiprocessor or HTT systems, programs can be designed to run optimally by performing a number of tasks simultaneously. To take advantage of this capability, the threads must be synchronized appropriately to do what they need to do at the right time.

In order to avoid race conditions during the execution of a threaded application, mutual exclusion to shared resources is required to allow a single thread to access and change the state of shared resources. The shared resource can be a data structure or variable in the address space. Minimizing synchronization overheads is critical to application performance. In multithreaded applications, while a thread is executing a code section that accesses a shared resource (critical region), other threads waiting to access that resource are either spinning or waiting in a queue.

Typically, synchronization duties are handled by making use of locks (semaphores being a generalized form) which are a means of limiting or controlling access to a resource when many threads are executing. Locks can be implemented in many ways and are the more traditional means of handling synchronization between threads. In addition to conventional multithreading methodologies, some developers also vehemently believe that there can be performance benefits gained by developing multithreaded applications that either don't use locks or use them very sparingly.

Subscribers who liked this article also read:
Branch and loop reorganization to prevent misdirects
by Jeff Andrews, application engineer, Intel Corp. Proven technique...

If you're interested in this topic, these articles may be helpful:

Nuts and Bolts of Multithreaded Programming
By Tim Mattson Get the basics about parallel algorithms, parallel p...
Deadlock Analysis using DevPartner Studio
Multi-threaded applications open the door to difficult-to-diagnose thr...
Multithreaded technology and multi-core processors
by Craig Szydlowski, Infrastructure Processor Division, Intel Corp. ...
Developing Multithreaded Applications: A Platform Consistent Approach
Multithreading Consistency Guide The objective of the Multithreading ...
CMP Implementation in Systems Based on the Intel® Core™ Duo processor
The Intel Core™ Duo processor is the first mobile processor to i...

Related Jobs:

Software Development Engineer - Simple Storage Service (S3) #022484 - WA - Seattle - Amazon.com, Inc.
Software Development Engineer - Simple Storage Service (S3) 022484...
SW Engineer III #7582 - JAVA ONE 2005 - CA - Redwood City - Electronic Arts Inc.
Post Description Online Platform Development will have a broad range...
Development Lead #90284078 - India - Hyderabad - Microsoft Corporation
Ever wondered how we get printed pictures and documents back into the ...
Flash Developer #41744 - CA - North Hollywood - The Walt Disney Internet Group
Flash Developer posted 10/11/2006 North Hollywood, CA JOB DESC...
C++/Linux Developer - NY - Manhattan - Athena Archiver
Athena Archiver is a software development company that focuses on exce...
Software Development Engineer #148900 - WA - Redmond - Microsoft Corporation
SQL Server has become one of the most important products at Microsoft ...
FX Leave Orders GUI Developer #2578559 - NY - New York - Ajilon Consulting
Title : FX Leave Orders GUI Developer Posted : 01-13-2006 ...
SW Engineer II #8421 - CA - Redwood City - Electronic Arts Inc.
Post Description Key responsibilities: The Software Engineer II - O...
Sr. Software Engineer #058151 - CA - Santa Monica - Symantec Corporation
Job Requisition # : 058151 Job Title : Sr. Software Engineer Locat...
Software Engineer #STN-SEALCM - IL - Lombard - SunGard
Reference No.: STN-SEALCM Opening Date: September 27, 2006 Job Tit...