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
- 1. It is difficult to choose an implementation strategy.
- 2. It is necessary to save memory.
- 3. Ensuring that processes' memory is protected from each other.
- 4. Simultaneous consumption of a large amount of memory.
- 5. Cache efficiency.
- 6. Virtual memory.
- 7. It is difficult to divide large RAM correctly.
- 8. Shared memory.
- 9. Multiprocessing.
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:
1. Deny access programmatically. it is slow and can be broken if you write directly in Assembly language, but with virtual machines inside it is implemented.
2. Hardware support. When the kernel allocates memory for code and data, it is marked. This is convenient because you can prove mathematically that they can't get access to others.
If not your index-> deny access
3. Topological.There is an address that the process uses, but in reality, the address is different, and the program can only use a virtual one.
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:
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
- The 2x increase.
In reality
- The murder of caches
- It is very difficult to arrange the intersection of caches: it is very time-consuming