Secure Operating Systems Lesson 5: Shared Objects.

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Operating Systems Part III: Process Management (Process Synchronization)
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6: Process Synchronization
Background Concurrent access to shared data can lead to inconsistencies Maintaining data consistency among cooperating processes is critical What is wrong.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
1 CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
1 Operating Systems, 122 Practical Session 5, Synchronization 1.
Mutual Exclusion.
CH7 discussion-review Mahmoud Alhabbash. Q1 What is a Race Condition? How could we prevent that? – Race condition is the situation where several processes.
Interprocess Communication
Cpr E 308 Spring 2004 Recap for Midterm Introductory Material What belongs in the OS, what doesn’t? Basic Understanding of Hardware, Memory Hierarchy.
Synchronization. Shared Memory Thread Synchronization Threads cooperate in multithreaded environments – User threads and kernel threads – Share resources.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Objectives Understand.
Chapter 2.3 : Interprocess Communication
02/23/2004CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
02/17/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Synchronization (other solutions …). Announcements Assignment 2 is graded Project 1 is due today.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Synchronization Solutions
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
02/19/2007CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
1 Race Conditions/Mutual Exclusion Segment of code of a process where a shared resource is accessed (changing global variables, writing files etc) is called.
Monitors: An Operating System Structuring Concept
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Process Synchronization Continued 7.2 Critical-Section Problem 7.3 Synchronization Hardware 7.4 Semaphores.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Mutual Exclusion. Readings r Silbershatz: Chapter 6.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
Discussion Week 2 TA: Kyle Dewey. Overview Concurrency Process level Thread level MIPS - switch.s Project #1.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 11: October 5, 2010 Instructor: Bhuvan Urgaonkar.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-5 Process Synchronization Department of Computer Science and Software.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Operating Systems CMPSC 473 Signals, Introduction to mutual exclusion September 28, Lecture 9 Instructor: Bhuvan Urgaonkar.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
Process Synchronization I CPE Operating Systems
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
CS703 – Advanced Operating Systems
Process Synchronization
Chapter 5: Process Synchronization
Background on the need for Synchronization
Chapter 5: Process Synchronization
Synchronization.
Chapter 5: Process Synchronization
Topic 6 (Textbook - Chapter 5) Process Synchronization
Synchronization Issues
Lecture 2 Part 2 Process Synchronization
Critical section problem
Chapter 6: Process Synchronization
CSCI1600: Embedded and Real Time Software
CSE 153 Design of Operating Systems Winter 19
Chapter 6: Synchronization Tools
CSCI1600: Embedded and Real Time Software
CSE 542: Operating Systems
CSE 542: Operating Systems
Operating Systems {week 10}
Presentation transcript:

Secure Operating Systems Lesson 5: Shared Objects

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

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

Two Parts of the Problem  Sharing actual information  Synchronizing between threads and/or processes

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

Peterson’s Solution II PROCESS 0  flag[0] = TRUE; turn = 1; while(flag[1] && turn == 1); // Critical Section flag[0] = FALSE; PROCESS 1  flag[1] = TRUE; turn = 0; while(flag[0] && turn == 0); // Critical Section flag[1] = FALSE;

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; }

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

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

Semaphores  wait(semaphore *S) { S->value--; if (S->value list; block(); // SLEEP } } // This will halt until we own the semaphore

Deadlocks  P0 wait(S); wait(Q); … signal(S); signal(Q);  P1 wait(Q); wait(S); … signal(Q); signal(S);

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

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

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…

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

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

Questions & Comments  What do you want to know?