How the operating system allocates processor time?




Facts | How the operating system allocates processor time?

Whatever the operating system, it faces a range of challenges. And we need to repeatedly return to this topic in order to consider all of them at least in the most general terms. The theme of today’s story will be the distribution of the operating system of the CPU between multiple tasks. Today, we get an answer to a question that sooner or later there is every curious person: the operating system allocates processor time to solve several problems at once? Indeed, under the colorful desktop backgrounds lurks a tireless hard worker, capable of day and night to solve assigned to it by the user task. For her hard shoulders the burden of care, but it usually carries it with ease, except in some situations where the user requires from his assistant impossible.

Операционные системы

All tasks performed by the operating system can be grouped into six categories:

Control of the CPU (Processor management)
Memory Management (Memory management)
Device Management (Device management)
Managing storage (Storage management)
Application Interface (Application interface)
UI (User interface)

Readers may note that modern operating system is able to many things that do not fit into any of these six groups. And they will be right. Developers of operating systems equip them with a variety of additional tools and additional features. But these six categories, which we will consider are the very essence of what is necessary to make the operating system.
Management Processor

Операционная система

Management of the computer’s processor is reduced to the solution of two closely interconnected problems:

Provide each software process and application sufficient for the correct functioning of the CPU time
The use of processor cycles to the extent that it really needs to work

The basic unit of software that the operating system allocates processor time, is a process or thread (thread). This depends on the particular operating system.

You could even say that the operating system tends to perceive the process as an application. However, this simplification does not describe the complexity of the interaction processes with the operating system and the computer’s hardware. Process is any application: a word processor, a spreadsheet, or a game. But the application can lead to the launch of additional processes that enable interaction with devices or other computers.

When the operating system is running, it is running a number of processes that do not even let you know about its existence. For example, in Windows XP or UNIX, dozens of background processes. In the list of their tasks include: ensuring network performance, control your computer’s memory and disks, check the system for viruses. Of course, this range of tasks is not settled.

Process is a software that performs some work. Each process should be monitored by someone or something: the operating system, another application, or directly by the user.

The operating system manages the processes rather than applications, and that it puts them in a list of the central processor. In single-tasking operating systems, this schedule is linear. The operating system allows the application to run, interrupting his execution to only those intervals that the user is required to input data or other interruption.

Interrupt called special signals from the hardware and software. They occur when a particular part of the computer suddenly demands the attention of the CPU. Sometimes the operating system determines the priority of processes, and masks some interruption. That is, it ignores interrupts from some sources, allowing the processor to first deal with the work already carried out by them.

But some interruption is extremely important and not ignored. It’s about memory problems and errors. These interrupts are unmasked and are referred to as processed immediately, regardless of the fact of what tasks currently running in the processor. As the most striking (but certainly not the only) example of NMI can cause an interrupt to stop the power supply. It is not difficult to understand that such an interruption always leads to the cessation of operation of the processor for a very good reason.

Interrupts are making work even single-tasking operating system. Daily work of a multi-tasking operating system is even more difficult. Today, the operating system needs to run applications in such a way that it looked to you as the events occurring at the same time. Modern multi-core and multi-processor computers, of course, very efficient, but each core can still perform only one task at a time.

To create the impression of simultaneous events, the operating system has to switch between processes thousands of times per second only. Now let us see how it all happens in reality:

This process takes a certain amount of memory (RAM, RAM). It can also use the registers, stacks and queues in the memory of the processor and operating system
When the two processes are executed at the same time multi-tasking operating system allocates a certain number of program execution cycles of the processor
After performing this sequence of cycles, the operating system copies the state of the registers, stacks and queues used in the course of work on the implementation process and marks the point at which the performance of the process was suspended
Then loads all the registers, stacks and queues used by the second process and allows the processor to give it a certain amount of cycles
When all this happens, it re-copies the state of the registers, stacks and queues used by the second program, and once again loads the first program

The control unit of the process

Операционная система

All the information needed to monitor the process is contained in the data packet, called the control unit of the process (process control block). Thus the state of the process is not lost when switching between tasks. In general, the process control unit comprising:

Number identifier (ID), identifies the process
Pointers and regulations of the program and its data at the time of the last treatment process
Content Register
Status of the various signs and switches
List of files opened by the process
Priority of the process
The status of all necessary to the process input and output devices

Each process is characterized by the associated status (status). Many processes in some situations do not require CPU time. For example, the process may be in the standby state the user presses a key. In this state, the process is called suspended (suspended). Where information about the key is pressed, the operating system changes its status. In this particular example, we are talking about what the status of the execution status changes to expectations. To continue the process it uses information from the control unit.

Swapping process does not require direct user intervention. Each process has at its disposal sufficient CPU cycles to perform its task in a reasonable amount of time. Problems occur when the user starts to work simultaneously with too many processes. The operating system itself requires a certain amount of CPU cycles to save all registers and queues, and switching between tasks. The operating system is not perfect, and it may be that it will use much of the CPU cycles allocated to it by switching between processes, rather than on their launch. This is called slip and usually requires user intervention. He needs to complete some of the processes and bring order to the system.

Everything considered by us above for those cases when your computer has only one processor. On machines have two or more processors, the operating system has to allocate between its workload. 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 processor to fit your own needs, and the processes are distributed among the other applications. Symmetric operating systems allocate their needs across multiple processors, even in cases when no other tasks are no longer running.

In the future, we will talk more about the five categories of tasks that always “keeps in mind” is the most common operating system of any computer.

To be continued …

According to the materials
Back # photo of the day | The most volcanically active object in our solar system
Next Bimbo panorama Tokyo 150 gigapixel: so you have not seen it yet
Tags: Windows XP , operating system , CPU .


Tags: , ,

In: Technology & Gadgets Asked By: [15519 Red Star Level]

Answer this Question

You must be Logged In to post an Answer.

Not a member yet? Sign Up Now »