8

I have read that Windows 3.11 uses cooperative multitasking, which means that the OS does not do process scheduling whenever it wants, but rather the currently running process "yield" the execution to the OS whenever the process wants, and then the OS chooses the next process to run.

But what I want to know is what is this "yield" functionality, is it a Windows API function that a process must call in multiple places in the process's code?

rony_t
  • 201

2 Answers2

16

It was done in the GetMessage call.

The heart of a windows application is something like:

while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
    TranslateMessage(&Msg);
    DispatchMessage(&Msg);
}

Each iteration gets a message and dispatches it. If there isn't a message available, it blocks until a message is available. Under 16-bit Windows, the CPU was yielded while waiting for a new message.

Some other calls like Yield or SendMessage would work the same way. But GetMessage was the one that most GUI applications would have primarily used.

Source

Winston Ewert
  • 25,052
2

Aside from the explicit request to Yield(), there are other APIs provided by Windows which potentially have to wait for another process to provide an answer, like the heart of the message pump GetMessage(), asking a window for information with SendMessage() and many more.

Deduplicator
  • 9,209