TipZone
  BugAlert
  Downloads
 How Tos
 Win98
 Books
 HealthyPC
 Linux
 and more

PC Magazine

  PC Tech

What's in a Thread?

Introduction

Threads: The Atomic Unit of Execution

Thread Scheduling

Uses for Multiple Threads

Hands On: Single vs. Multiple Threads

Further Reading



First USA!

NextCard Internet Visa - Apply Now

 
  Categories:
Operating Systems
What's in a Thread?
Uses for Multiple Threads

Continued from Thread Scheduling

Just how are multiple threads used in today's applications? Knowing exactly what an application is doing with its threads is difficult when you don't have access to its source code, but finding out how many threads an application uses is easy enough. One of the components that comes with Windows 95 is the System Monitor, found in the Start | Programs | Accessories | System Tools menu. (If you did not install it the first time around, click Start | Settings | Control Panel and open the Add/Remove Programs icon.) One of the items of information that System Monitor will display for you is the number of threads running in the system, as shown in Figure 2. By starting an application with System Monitor running and watching the thread count, you can determine how many threads the application uses. If the application uses a dedicated thread for background printing, you'll probably see the thread count bump up by 1 when you print a document.

You'll discover that Windows 95 uses several threads itself, because even with no applications other than System Monitor running, you'll never see the thread count drop below 12 or 13. Windows 95 uses one thread for nothing but fault handling, which makes it easier for the operating system to recover when an application suffers a general protection fault or causes other severe errors. It also runs animated cursors in a dedicated thread that is assigned a high priority but spends most of its time suspended, waiting for the moment to draw the next "frame."

The Windows 95 shell also takes advantage of the operating system's multithreading capabilities. For example, each window that you open in the shell is managed by a separate thread. If you drag-copy a file from one window to another, the thread associated with the window on the receiving end of the exchange performs the copy operation. The Taskbar is assigned its own thread, as is the window that represents the desktop. Shell-extension DLLs are run in separate threads so that if a shell extension goes down, it won't take the shell with it. The shell even uses one thread to gather file-change notifications and lump them together. This way a window doesn't get bombarded with notifications if someone opens a DOS window and copies 100 files to a folder whose contents are visible in an Explorer window.

Windows NT finds still other uses for threads. For example, Windows NT uses a priority-0 thread to zero the contents of unused memory pages. It also uses a dedicated raw-input thread to capture mouse and keyboard events, convert them into messages, and distribute the messages to the various message queues.

Continues...

Published as Tutor in the 12/05/95 issue of PC Magazine.


 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1997 Ziff-Davis Inc.