From Surf Wiki (app.surf) — the open knowledge base
Cooperative multitasking
Computer multitasking that does not preempt processes
Computer multitasking that does not preempt processes
Cooperative multitasking, also known as non-preemptive multitasking, is a computer multitasking technique in which the operating system never initiates a context switch from a running process to another process. Instead, in order to run multiple applications concurrently, processes voluntarily yield control periodically or when idle or logically blocked. This type of multitasking is called cooperative because all programs must cooperate for the scheduling scheme to work.
In this scheme, the process scheduler of an operating system is known as a cooperative scheduler whose role is limited to starting the processes and letting them return control back to it voluntarily.{{cite web | access-date = August 15, 2015 | access-date = August 15, 2015 | archive-date = August 19, 2019 | archive-url = https://web.archive.org/web/20190819072905/http://www.classiccmp.org/cini/pdf/HT68K/HT68K%20TCJ30p37.pdf | url-status = dead
This is related to the asynchronous programming approach.
Usage
Although it is rarely used as the primary scheduling mechanism in modern operating systems, it is widely used in memory-constrained embedded systems and in specific applications such as CICS or the JES2 subsystem. Cooperative multitasking was the primary scheduling scheme for 16-bit applications employed by Microsoft Windows before Windows 95 and Windows NT, and by the classic Mac OS. Windows 9x used non-preemptive multitasking for 16-bit legacy applications, and the PowerPC Versions of Mac OS X prior to Leopard used it for classic applications. NetWare, which is a network-oriented operating system, used cooperative multitasking up to NetWare 6.5. Cooperative multitasking is still used on RISC OS systems.{{cite web
Cooperative multitasking is similar to async/await in languages, such as JavaScript or Python, that feature a single-threaded event-loop in their runtime. This contrasts with cooperative multitasking in that await cannot be invoked from a non-async function, but only an async function, which is a kind of coroutine.{{cite web |access-date=30 January 2023 |access-date=30 January 2023
Cooperative multitasking allows much simpler implementation of applications because their execution is never unexpectedly interrupted by the process scheduler; for example, various functions inside the application do not need to be reentrant.
Problems
As a cooperatively multitasked system relies on each process regularly giving up time to other processes on the system, one poorly designed program can consume all of the CPU time for itself, either by performing extensive calculations or by busy waiting; both would cause the whole system to hang. In a server environment, this is a hazard that is often considered to make the entire environment unacceptably fragile, though as noted above, cooperative multitasking has been used frequently in server environments, including NetWare and CICS.
In contrast, preemptive multitasking interrupts applications and gives control to other processes outside the application's control.
The potential for system hang can be alleviated by using a watchdog timer, often implemented in hardware; this typically invokes a hardware reset.
References
de:Multitasking#Kooperatives Multitasking
This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.
Ask Mako anything about Cooperative multitasking — get instant answers, deeper analysis, and related topics.
Research with MakoFree with your Surf account
Create a free account to save articles, ask Mako questions, and organize your research.
Sign up freeThis content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.
Report