SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding Shared Objects in Operating Systems

diella avatar
17 diapositives · 310 Views · Jul 30, 2014

In this lesson, we explore the complexities of shared objects within operating systems (OS). While the OS doesn't inherently need to support sharing between users and processes, it does facilitate performance that relies on such sharing. We’ll examine critical concepts including mutual exclusion, synchronization mechanisms like Peterson's Solution and semaphores, and issues such as race conditions and priority inversion. Additionally, we discuss strategies for ensuring atomic operations and preventing deadlocks, emphasizing the need for effective coordination among processes to maintain system integrity.

Understanding Shared Objects in Operating Systems - slide 1
01 / 17Understanding Shared Objects in Operating Systems
1 / 17

Télécharger la présentation

Understanding Shared Objects in Operating Systems
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Secure Operating Systems Lesson 5: Shared Objects

  2. Where are we? • We have got more of the fundamental security structures of our OS in our heads • But now we have to face a real challenge: shared objects

  3. The OS doesn’t HAVE TO… • I’ve used that heading before, but it’s true • There’s no requirement for our OS to support sharing between users and processes… but it sure comes in handy • Once again, we have a tension between performance and security

  4. Two Parts of the Problem • Sharing actual information • Synchronizing between threads and/or processes

  5. Peterson’s Solution • Two shared variables: • int turn;boolean flag[2] • Code: • flag[i] = TRUE;turn = j;while (flag[j] && turn == j); // Do Critical Sectionflag[i] = FALSE;

  6. Peterson’s Solution II PROCESS 0 PROCESS 1 flag[1] = TRUE;turn = 0;while(flag[0] && turn == 0); // Critical Sectionflag[1] = FALSE; • flag[0] = TRUE;turn = 1;while(flag[1] && turn == 1); // Critical Sectionflag[0] = FALSE;

  7. Hardware Support • The challenge of disabling interrupts is that it’s expensive • Many OS provide a hardware “test and set” instruction, which allows atomic access to a chunk of memory • Swap: void Swap(boolean *a, boolean *b) {boolean temp = *a; *a = *b; *b = temp; }

  8. Implemented as… • do { key = TRUE; while (key == TRUE) swap(&lock, &key); // Critical Section lock = FALSE;} while (TRUE); • Mutual-exclusion with Swap…

  9. Semaphores • wait(S) { while (S <= 0); //nop S--;} • signal(S) { S++;} • This really looks like a spinlock…

  10. Semaphores • wait(semaphore *S) { S->value--; if (S->value < 0) { add this proc to S->list; block(); // SLEEP }} // This will halt until we own the semaphore

  11. Deadlocks • P0 • wait(S);wait(Q);…signal(S);signal(Q); • P1 • wait(Q);wait(S);…signal(Q);signal(S);

  12. Priority Inversion • Imagine we have three procii, L, M and H, where L is Low Priority, M, medium, and H, High • L is holding a resource which is blocking H, but gets swapped out for M • This is known as Priority Inversion… and it’s a real problem! • Probably we should talk about different scheduling approaches

  13. Mars Sojourner • Long running, medium priority Comms task • Low priority weather task • High priority information bus thread • Low priority wx task acquires a mutex for the bus… gets interrupted by the Comms task (long running), blocking the high priority bus thread… tada! Priority Inversion • Can be a security issue too! • Can be solved by priority inheritance

  14. Atomicity • Making sure something is atomic is pretty easy on a single core system • On a more complex system it can get REALLY hard • One approach is transactional memory – move the problem to the memory not the programmer • None of this has even touched on how we SHARE information between processes…

  15. Race Conditions • Poor synchronization can lead to race conditions – a subset of which is called TOCTOU • Race conditions arise from interdependence that is unrealized or incorrectly implemented

  16. Things to Do • Read “An Investigation of the Therac-25 Accidents”, Nancy Leveson, Clark S. Turner

  17. Questions & Comments • What do you want to know?