Das Video kommt von YouTube: erst beim Abspielen verbindet sich die Seite mit YouTube (Google).
Mutex Lock
Das Wichtigste aus dem Video
Tipp auf eine Zeit – das Video springt genau dorthin.
Transkriptautomatisch erstellt · 13 Zeilen
- Now, in real life if I want to keep other people from taking my things or messing with things they shouldn't, I use
- a lock to stop them. In threaded programming, we use a similar concept to protect memory. Let's say that inside some procedure, there's
- a block where I manipulate some data, in our example, the variable a. And I need to be sure that no other thread
- touches this variable while I am working on it. Whether executing this procedure or another one. Well then, I can declare a lock
- variable, which should reside in shared memory, and put the lock on before I have it do my manipulation,
- and unlock it afterwards. And I should do the same wherever I manipulate this variable a. If some other
- thread running this code simply accesses the shared resource without using the lock, it won't be able to stop
- him. But if he does try to acquire the lock first, then this call to mutex lock will block until
- the lock variable shows that has been unlocked. And only then will this code proceed. And, of course, if
- the schedule had worked things out so that this call had been called first, then he would get the lock.
- And this call to acquire the mutex lock would block until this data manipulation was finished, and the mutex variable
- had been unlocked. And this way the threads are able to mutually exclude each other from using resources, hence these
- are called mutex locks.
Zum Nachlesen
MutexEin kritischer Abschnitt (engl. critical section oder critical region) ist derjenige Teil im ausführbaren Code, in dem ein wegen des Mutex ungestörter …
SpinlockEs ist eine Sperre (Lock) zum Schutz einer gemeinsam genutzten Ressource durch konkurrierende Prozesse bzw. Threads (siehe Kritischer Abschnitt) nach dem …
ProzesssynchronisationGemeinsamer Zugriff auf Daten. Dabei muss verhindert werden, dass durch gleichzeitigen Zugriff Inkonsistenzen in den Daten entstehen. Dies wird durch Mutex- …
Nicht-blockierende SynchronisationNicht-blockierende Synchronisation (englisch non-blocking oder auch lock-free synchronization) ist eine Technik in der Informatik, um parallele Prozesse zu …