STM32 Barrier Instructions.

If you have never looked into how a microcontroller works, you probably think it executes instructions sequentially, one after another. That is exactly how the first MCUs worked, but over time their architecture became more complex to increase performance.
It is important to note that executing an instruction itself consists of stages. In general terms, from the MCU's point of view it looks like this: fetch the instruction from memory, execute it, store the result.

Let's look at the improvements that the engineers of the RISC architecture, which underlies ARM, made to the mechanism described above. In case anyone has forgotten, ARM stands for Advanced RISC Machine, which literally means an improved RISC architecture.
STM32 Barrier Instructions.
The picture shows that the developers implemented a pipeline inside the MCU, meaning that on each clock cycle all instructions shift one step to the right. While a new instruction is being fetched, the previously fetched instruction is being decoded, and so on. I should point out right away that a pipeline always has a limited length, because a pipeline works well only when executing the next instruction does not depend on the result of the previous one; otherwise the pipeline stalls.

ISB
The Instruction Synchronization Barrier (ISB) instruction ensures that
the effect of all completed memory accesses will be visible to
subsequent instructions.

This instruction is often used to make the pipeline finish its work before the next instruction is executed. In other words, to make certain settings take effect at a specific moment, for example so that the MCU finishes its business before going to sleep.
Another good example of using the ISB instruction is a program that contains self-modifying code. Using it right after the program code has been modified guarantees that the modified code will be executed from then on.

DSB
The Data Synchronization Barrier (DSB) instruction ensures that all
pending memory accesses are completed before the next
instruction begins executing.

In simple terms, DSB completes only after all explicit memory accesses initiated before it have been performed.
It should be used when interrupt priorities are changed while an interrupt is being handled. This guarantees that the change takes effect when the DSB instruction completes. Another interesting problem that DSB helps solve is related to context switching, namely making changes to the MCU settings take effect immediately after a context switch.

DMB
The Data Memory Barrier (DMB) instruction ensures that all pending
memory accesses are completed before the next memory access.

In simple terms, DMB lets you define the order of memory accesses: accesses placed before the barrier are guaranteed to be performed before those placed after it.
If a program modifies the interrupt vector table and then enables interrupts, a DMB instruction must be placed before enabling them. This guarantees that, when an interrupt occurs, the MCU will look up the vector table at the new address.