Multitasking in systems is a method in which multiple tasks, also known as processes, share common processing resources such as CPU, GPU, and so on. In the case of a computer with a single CPU, it is said that only one task is running at any given time, which means that the CPU is actively executing instructions for that task. Multitasking solves the problem by scheduling which task can be presented at any time and when another waiting task gets its turn. The CPU's action of transferring from one task to another is called a context switch. When context switches occur frequently enough, an illusion of parallelism is achieved. Even on computers with more than one CPU, multitasking allows many more tasks to be performed than there are processors.

Cooperative Multitasking
When computer usage shifted from batch mode to interactive mode, multiprogramming was no longer a suitable approach. Each user wanted to see their program running as if it were the only program on the computer. Time-sharing made this possible, with the quality that the computer would not seem as slow to any user as it would actually be if it only ran that user's program. Since a cooperative multitasking system relies on each process to periodically yield time to other processes in the system, a poorly designed program could consume all of the processor's time or cause the entire system to halt. In a server environment, this is a risk that makes the network vulnerable. Programs must be evaluated and tested in a test environment before being deployed on the main server, otherwise the entire network will either slow down or stop when any program on the server malfunctions.

Preemptive Multitasking (NT and Linux)
Preemptive multitasking allows the computer to more reliably guarantee each process a regular "slice" of working time. It also allows the system to quickly respond to external important events, such as input data, which may require immediate attention from one process or another. Operating systems were developed to take advantage of these hardware capabilities and implement preemptive multitasking of multiple processes. For example, preemptive multitasking was implemented in the earliest versions of Unix in 1969 and is standard in Unix and Unix-like operating systems, including Linux, Solaris, and BSD with its distributions. Any process can be grouped into two categories: those waiting for input or output (called "I/O bound") and those that fully utilize the processor (CPU bound). In primitive systems, programs often "poll" or "busy wait" waiting for required input (for example, from disk, keyboard, or network input). During this time, the system was not performing useful work. With the advent of interrupts and preemptive multitasking, I/O-related processes can be "blocked" or suspended while waiting for necessary data to arrive, allowing other processes to use the processor. As the arrival of required data would trigger an interrupt, blocked processes can be guaranteed to resume execution in a timely manner. A similar model is used in Windows 9x and the Windows NT family, where native 32-bit applications are multitasking, while older 16-bit Windows 3.x programs are multitasked in a single process, though in the NT family this is possible to force a 16-bit application to run as a separate preemptive multitasking process. The 64-bit releases of Windows, for both x86-64 and Itanium architectures, no longer provide support for legacy 16-bit applications, and thus provide preemptive multitasking for all supported applications.

Multithreading
As multitasking significantly improved computer throughput, programmers began implementing applications as sets of cooperating processes (for example, one process for gathering input data, one process for processing input data, one process for writing results to disk). This, however, required certain tools that would allow processes to efficiently exchange data. Threads were born from the idea that the most efficient way to exchange data and process cooperation would be to share their entire memory space. Thus, threads are essentially processes that operate in the same memory context. Threads are described as lightweight processes because transitions between threads do not involve changes in memory context.
Source: https://cis2.oc.ctc.edu/oc_apps/Westlund/xbook/xbook.php?unit=04&proc=book#s5
Subscribe to my channels:
Ամենօրյա Նորություններ!
Կիբերանվտանգություն հայերենով - https://t.me/cybersecarm
Cyber security in English - https://t.me/cyberseceng
Кибер безопасность на русском - https://t.me/cybersecruss









Comments (0)