| | | | for the calling process and it cannot be inherited. Also as with processes, we can use the DuplicateHandle function to get a real handle to a thread from a pseudohandle. | | | | | | The term multitasking, also called multiprogramming, refers to the ability to manage multiple processes (or multiple threads) with a single processor. On the other hand, multiprocessing refers to the management of multiple processes or multiple threads with more than one processor. | | | | | | It is only in a multiprocessor environment that a computer can execute instructions from two different processes at the same time. However, even with a single processor, task switching can make it appear that more than one process is executing instructions at the same time. | | | | | | In the older 16-bit Windows operating system, there was only one thread in the entire system. Moreover, 16-bit Windows used a cooperative multitasking approach, meaning that each application was responsible for relinquishing the system's thread so that other applications could execute. If a program running under 16-bit Windows was performing a time-intensive task, such as formatting a floppy disk, all other loaded applications had to wait. Worse yet, if an errant program went into an infinite loop, the entire system would become unusable, requiring a cold reboot. | | | | | | Win32 is much different. First, it is multithreaded, which allows for the possibility of multiprocessing, among other things. Second, it uses a preemptive multitasking model, where the operating system controls when and for how long each thread gets CPU time, which is allocated in time slices. A time slice is referred to by Windows as a quantum. | | | | | | The length of a quantum is hardware dependent and can actually vary from thread to thread. Just to give a reference point, the base value is 20 milliseconds for Windows 95, 30 milliseconds for Windows NT Workstation (on a Pentium-based system), and 180 milliseconds for Windows NT Server. | | | | | | Let us explain, in very general terms, how Windows allocates quantums to the threads in a system. The process is quite similar, but not identical, for Windows 9x and Windows NT. | | | | | | Every thread in the system has a priority level, which is a number between 0 and 31. In brief, here are the facts. | | |