- Get link
- X
- Other Apps

Whatever the operating system, it faces a whole range of tasks. And we will need to return to this topic more than once in order to examine them all, at least in the most general terms. The theme of our today's narration will be the distribution of the operating system of the CPU time among various tasks. Today we will get an answer to the question that every curious user sooner or later arises: how does the operating system distribute the processor time to solve several tasks at the same time? After all, under the colorful wallpaper of the desktop lies a tireless worker, capable of day and night to solve the tasks set for her by the user. She has a difficult load of worries behind her, but usually she carries it with ease, except for certain situations when the user demands the impossible from her assistant.

All tasks performed by the operating system can be grouped into six categories:
- Processor management
- Memory Management
- Device Management
- Storage Management
- Application Interface
- User Interface
Readers may note that a modern operating system can do many things that do not fit into any of these six groups. And they will be right. The developers of operating systems equip them with a variety of auxiliary utilities and additional functions. But these six categories that we have to consider constitute the very essence of what the operating system should do.
CPU Management

Controlling a computer's processor is reduced to solving two, closely related problems:
- Ensuring each software process and application is sufficient for the correct operation of the processor time
- The use of processor cycles to the extent that is really necessary for work
The basic unit of software, which the operating system allocates processor time, is the process or thread (thread). It depends on the specific operating system.
You could even say that the operating system tends to perceive the process as an application. But this simplification does not describe the complexity of the interaction of processes with the operating system and computer hardware. The process is any application: a text editor, spreadsheet or game. But the application can lead to the launch of additional processes that provide interaction with devices or other computers.
When the operating system is running, it runs a lot of processes that do not even let you know about your existence. For example, in Windows XP or UNIX, dozens of background processes are running. The list of their tasks includes: ensuring the operation of the network, managing the memory of the computer and its disks, checking the system for viruses. Of course, this does not exhaust their circle of tasks.
A process is software that does some work. Each process must be controlled by someone or something: the operating system, another application, or directly by the user.
The operating system manages processes rather than applications, and it is them that schedules the CPU. In single-tasking operating systems, this schedule is linear. The operating system allows the application to start, interrupting its execution only for those time intervals required by the user to enter data or other interruptions.
Interrupts are special signals emanating from hardware and software. They occur when one or another part of the computer suddenly requires the attention of the central processor. Sometimes the operating system determines the priority of processes and masks some interruptions. That is, it ignores interrupts from some sources, allowing the processor to first cope with the work already done by it.
But some interrupts are crucial and not ignored. We are talking about memory problems and errors. These interrupts are called nonmaskable, and they are processed immediately, regardless of what tasks the processor is currently working on. As the most vivid (but, of course, not the only) example of a non-maskable interrupt, an interruption on the termination of power supply can be given. It is easy to understand that such an interruption always leads to the cessation of the processor for a very good reason.
Interrupts make even a single-tasking operating system more difficult. Everyday work of a multitasking operating system is even more difficult. Today, the operating system must execute applications in such a way that it looks to you as events occurring simultaneously. Modern multi-core processors and multiprocessor computers are, of course, very efficient, but each processor core can still perform only one task at a time.
To create the impression of simultaneously occurring events, the operating system has to switch between processes thousands of times in one second only. Now consider how this all happens in reality:
- The process takes up a certain amount of RAM (RAM, RAM). It can also use registers, stacks and queues within the memory of the processor and operating system.
- When two processes are executed simultaneously in multitasking mode, the operating system allocates a certain number of processor execution cycles to one program.
- After executing this sequence of loops, the operating system copies the state of all the registers, stacks and queues used in the process of executing the process and marks the point at which the process was suspended.
- It then loads all the registers, stacks and queues used by the second process and allows the processor to devote a certain number of cycles to it.
- When all this has already happened, it again copies the state of all the registers, stacks and queues used by the second program and once again loads the first program.
Process control block

All the information needed to track the process is contained in a data packet called the process control block. Thus, the process state is not lost when switching between tasks. In general, the process control block contains:
- ID number identifying this process
- Pointers and positions of the program and its data at the time of the last processing process
- Register content
- States of various features and switches
- List of open files by process
- Process priority
- The status of all input and output devices required by this process.
Each process is characterized by its associated status (state). Many processes in certain situations do not require CPU time. For example, a process might be waiting for a user to press a key. In this state, the process is called suspended. When a keystroke arrives, the operating system changes its status. In this particular example, we are talking about the fact that the waiting status is replaced by the execution status. To continue the process of using the information from its control unit.
Swapping processes do not require direct user intervention. Each process has at its disposal enough processor cycles to complete its task within a reasonable amount of time. Problems occur when the user starts simultaneously working with too many processes. The operating system itself requires a certain number of processor cycles to save all registers and queues and switch between tasks. The operating system is not perfect, and it may happen that it starts using most of its processor cycles to switch between processes and not to start them. This is called slip and usually requires user intervention. He needs to complete some processes and bring order to the system.
Everything we discussed above applies to cases where the computer has only one processor. On machines with two or more processors, the operating system has to distribute its workload between them. And at the same time try to maintain a balance between the needs of the processes and the number of available cycles of different processors. Asymmetric operating systems allocate one of the processors for their own needs, and the application processes are distributed among the rest. Symmetric operating systems distribute their needs across multiple processors, even in cases where no other tasks are running anymore.
In the future, we will have to talk about five categories of tasks that the most ordinary operating system of any computer constantly “keeps in mind”.
To be continued…
Based on computer.howstuffworks.com
The article is based on materials .
- Get link
- X
- Other Apps
Comments
Post a Comment