06.1 (conspect) MultiTasking

MultiTasking

The property of the operating system or run time to allow parallel (or pseudo-parallel) processing of multiple tasks. Modern external devices can transmit data independently. For example, the processor waits for the end of input and output, but during this time the processor does not do input and output and does not calculate anything. Such tasks can be performed within a single processor almost in parallel

Human is one of the slowest external devices. A person does not have time to notice the difference between a millisecond and a microsecond. If the task is performed quickly or very quickly, then there is no difference for the person.

Problems

Complexity of choosing an implementation strategy.

Solution:

Preemptive multitasking - processor time is divided into pieces and one program runs on the processor for a moment and then they change.

Finishing
We need support for timer interrupts, and we need to respond to every request from the processor
Switch
The scheduler saves the entire process context and registers

The necessity to save memory.

Solution:

Which hardware or software should be implemented?

Hardware switching is quite expensive, because of the structure of the processors themselves. Starting 2 tasks starts 3, because there is still a scheduler.

Ensuring that process memory is protected from each other.

Solution:

Each process takes its own piece of addresses, so if you make a mistake, you will start contacting the wrong address. There are 3 ways to protect yourself:

If not your index-> deny access

Simultaneous consumption of a large amount of memory.

Solution:

Paging. The unnecessary part is uploaded to disk

Cache efficiency .

There are more places than the cache, so they will start to conflict.

Solution:

The associative cache is slower than the direct cache, but it is larger.

Direct is very fast and very simple it doesn't start working well.

It is necessary to choose both!

The Direct is so large that it will cover hot spots, and the associative one will keep the most active ones.

Virtual memory.

A hybrid between hardware protection and topological protection that simultaneously solves memory and addressing problems. Structure:

Structure:

virtual_memory.png

Complexity of dividing large RAM correctly.

Solution:

You need to make the user and supervisor mode.

User-a process that does not have additional access.

The processor runs in supervisor mode, and it is the only one.

Shared memory.

We can make several processes run on the same physical memory

Solution:

Paging.The most unnecessary ones are temporarily uploaded to disk, and when they are needed, they are loaded back.

Swap. The entire process is uploaded

Multiprocessing.

In dreams

In reality

HSE/ProgrammingOS/06_MultiTasking/Conspect_en (последним исправлял пользователь VasilyKireenko 2020-02-18 20:33:33)