Process Scheduling and Multitasking

The Process Scheduler is the component responsible for providing system resources to the applications and other processes you run, and for scheduling processes to allow multiple applications to run concurrently.

The Process Scheduler also schedules processes in a way that allows multiple applications and other processes to run concurrently. Windows 95 uses two methods for concurrent process scheduling — cooperative multitasking and preemptive multitasking.

With Windows 3.1, applications ran concurrently through a method known as cooperative multitasking. Using this method, the operating system required an application to check the message queue periodically and to relinquish control of the system to other running applications. Applications that did not check the message queue frequently would effectively "hog" CPU time and prevent the user from switching to another application. For compatibility reasons, Windows 95 cooperatively multitasks Win16-based applications.

Windows 95 uses preemptive multitasking for Win32-based applications. This means that the operating system takes control away from or gives control to another running task, depending on the needs of the system.

Unlike Win16-based applications, Win32-based applications do not need to yield to other running tasks to multitask properly. Win32-based applications can take advantage of multithreading, a mechanism that Windows 95 provides to facilitate the ability to run applications concurrently. A Win32-based application running in the system is called a process in terms of the operating system. Each process consists of at least a single thread of execution that identifies the code path flow as it is run by the operating system. A thread is a unit of code that can get a time slice from the operating system to run concurrently with other units of code, and must be associated with a process. However, a Win32-based application can initiate multiple threads for a given process to enhance the application for the user by improving throughput, enhancing responsiveness, and aiding background processing. Because of the preemptive multitasking nature of Windows 95, threads of execution allow code to be smoothly processed in the background.

A good illustration of this is the Windows 95 shell itself. Although the shell is a Win32-based process, each folder window that opens is a separate thread of execution. As a result, when you initiate a copy operation between two shell folder windows, the operation is performed on the thread of the target window. You can still use the other windows in the shell without interruption, or you can start a different copy in another window.

In another example, a word processing application (a process) can implement multiple threads to enhance operation and simplify interaction with the user. The application can have a separate thread that responds to keys typed on the keyboard by the user to place characters in a document, while another thread performs back-ground operations such as spelling checking or paginating, and while a third thread spools a document to the printer in the background.

Note

Some Win16-based applications may have provided functionality similar to this; however, because Windows 3.1 didn't provide a mechanism for supporting multithreaded applications, it was up to application vendors to implement their own threading schemes. The use of threads in Windows 95 makes it easy for application vendors to add asynchronous processing of information to their applications.