9.1 Overview

I l @ ve RuBoard

Many networked applications lend themselves naturally to multithreading because processing tasks can be separated from I/O tasks . Multithreading is particularly convenient in servers that manage connection-oriented or connectionless network associations for many clients simultaneously . Today's increasingly powerful OS support for multithreading helps networked applications to:

  • Leverage hardware advances, such as symmetric multiprocessing that enables true execution parallelism ,

  • Increase performance by overlapping computation and communication,

  • Improve response time for GUIs and network servers to ensure that time-sensitive tasks are scheduled as needed, and

  • Simplify program structure by enabling applications to use intuitive synchronous programming mechanisms, rather than more complex asynchronous programming mechanisms.

This chapter describes the following ACE classes that networked applications can use to spawn and manage one or more threads of control within a process:

ACE Class Description
ACE Thread Manager Allows applications to portably create and manage the lifetime, synchronization, and properties of threads.
ACE_Sched_Params A portable encapsulation of OS scheduling class features that's used in conjunction with the ACE_OS::sched_params () wrapper method to control various properties of real-time threads.
ACE_TSS Encapsulates thread-specific storage mechanisms to allow objects that are "physically" private to a thread to be accessed as though they were "logically" global to a program.

These wrapper facades provide the following benefits:

  • Ensure portability across heterogeneous OS platforms. Operating systems have diverse multithreading syntax and semantics, which ACE hides via its wrapper facades. For example, the ACE_Thread_Manager class ensures detached/joinable threads behave the same regardless of the underlying OS threading mechanisms.

  • Manage a group of threads as a cohesive collection. Concurrent networked applications often require multiple threads to start and end as a unit. The ACE_Thread_Manager class provides a thread group capability that allows other threads to wait for an entire group of threads to exit before proceeding with their processing.

  • Influence thread scheduling policies and priorities. Many networked applications require tight control over the priorities of their threads. Real-time and general-purpose operating systems often differ in their scheduling capabilities, and multiplatform networked applications need a way to manage the disparate scheduling properties portably. The ACE_Sched_Params class is designed to offer access to run-time scheduling information in a uniform, portable, and easy-to-use manner.

  • Efficiently use and manage thread-specific storage (TSS). TSS is a mechanism that enables multiple objects and methods to manage information that's specific to each thread. ACE's TSS wrapper facade class overcomes syntax differences, as well as capability differences, between platforms.

This chapter motivates and describes the capabilities of the ACE multithreading classes. We present examples of each class to illustrate how they can simplify and optimize various aspects of our networked logging service.

I l @ ve RuBoard


C++ Network Programming
C++ Network Programming, Volume I: Mastering Complexity with ACE and Patterns
ISBN: 0201604647
EAN: 2147483647
Year: 2001
Pages: 101

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net