COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.

Slides:



Advertisements
Similar presentations
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
Advertisements

Process Description and Control
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Protection and the Kernel: Mode, Space, and Context.
COP 5611 Operating Systems Spring 2010 Dan C. Marinescu Office: HEC 439 B Office hours: M-Wd 2:00-3:00 PM.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Enforcing Modularity Junehwa Song CS KAIST. Network Computing Lab. How to run multiple modules? Emacs X server Mail Reader File Server.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
COP 5611 Operating Systems Spring 2010 Dan C. Marinescu Office: HEC 439 B Office hours: M-Wd 2:00-3:00 PM.
Processes & Threads Introduction to Operating Systems: Module 5.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
What is a Process ? A program in execution.
COP 4600 Operating Systems Fall 2010 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
COP 4600 Operating Systems Fall 2010
Processes and threads.
Process concept.
COT 4600 Operating Systems Fall 2009
Operating System Structure
Intro to Processes CSSE 332 Operating Systems
COP 4600 Operating Systems Fall 2010
Concurrency: Threads, Address Spaces, and Processes
COP 5611 Operating Systems Spring 2010
Threads, SMP, and Microkernels
ICS 143 Principles of Operating Systems
COP 4600 Operating Systems Spring 2011
COP 4600 Operating Systems Spring 2011
COT 5611 Operating Systems Design Principles Spring 2014
Chapter 26 Concurrency and Thread
CGS 3763 Operating Systems Concepts Spring 2013
COT 5611 Operating Systems Design Principles Spring 2012
COT 5611 Operating Systems Design Principles Spring 2014
COP 4600 Operating Systems Fall 2010
CGS 3763 Operating Systems Concepts Spring 2013
COP 4600 Operating Systems Spring 2011
Process Description and Control
COT 5611 Operating Systems Design Principles Spring 2012
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Description and Control
Threads Chapter 4.
Process Description and Control
Chapter 2: Operating-System Structures
Process Description and Control
Process Description and Control
COP 5611 Operating Systems Spring 2010
Process Description and Control
Process Description and Control
Operating Systems: A Modern Perspective, Chapter 6
Implementing Processes, Threads, and Resources
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Outline Operating System Organization Operating System Examples
Process Description and Control
Foundations and Definitions
Chapter 2: Operating-System Structures
COP 5611 Operating Systems Spring 2010
COMP755 Advanced Operating Systems
COT 5611 Operating Systems Design Principles Spring 2014
Presentation transcript:

COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM

Last time:  Midterm solutions Today: Virtualization for the three abstractions  Threads  Virtual Memory  Bounded buffer The kernel of an operating system Threads  State  Thread manager  Thread state  Kernel and application threads  Next time Processor switching Lecture 15 – Thursday, March 17, 2011 Lecture 152

Virtualization – relating physical with virtual objects Virtualization  simulating the interface to a physical object by: 1. Multiplexing  create multiple physical objects from one instance of a physical object. 2. Aggregation  create one virtual object from multiple physical objects 3. Emulation  construct a virtual object from a different type of a physical object. Emulation in software is slow. MethodPhysical Resource Virtual Resource Multiplexingprocessorthread real memoryvirtual memory communication channelvirtual circuit processorserver (e.g., Web server) AggregationdiskRAID coremulti-core processor EmulationdiskRAM disk system (e.g. Macintosh)virtual machine (e.g., Virtual PC) Multiplexing + Emulation real memory + diskvirtual memory with paging communication channel + processor TCP protocol 3Lecture 15

Virtualization of the three abstractions We analyze virtualization for the three abstractions 1. Interpreter  Threads 2. Communication link/channel  Bounded Buffer 3. Storage  Virtual Memory Lecture 154

(1) Virtualization of interpreter - Threads Process/Threads  a virtual processor Multiplexing or processor sharing is possible because  there is a significant discrepancy between processor bandwidth and the bandwidth of memory and of I/O devices  threads spend a significant percentage of their lifetime waiting for external events. Called:  Time-sharing  Processor multiplexing  Multiprogramming  Multitasking Processes versus thread:  Both represent a module in execution  A process may consist of multiple threads  A thread is a light-weight process, less overhead to create it. 5Lecture 15

6

Tight coupling between interpreter and storage We need a memory enforcement mechanism; to prevent a thread running the code of one module from overwriting the data of another module. Address space  the range of memory addresses a thread is allowed to access. Close relationship between a thread and an address space. Lecture 157

(2) Virtualization of storage - Virtual memory Address space – the storage a thread is allowed to access. Virtual address space – an address space of a standard size regardless of the amount of physical memory.  The physical memory may be too small to fit an application; otherwise each application would need to manage its own memory.  The size of the address space is a function of the number of bits in an address. For example, 32 bits addresses allow an address space of 2 32 (4 Gbytes), 64 bit addresses allow 2 64 Virtual Memory - a scheme to allow each thread to access only its own virtual address space (collection of virtual addresses). 8Lecture 15

Memory map of a process Lecture 159

10

(3) Virtualization of communication link - Bounded buffers Bounded buffers  implement the communication channel abstraction  Bounded  the buffer has a finite size. We assume that all messages are of the same size and each can fit into a buffer cell. A bounded buffer will only accommodate N messages.  Threads use the SEND and RECEIVE primitives. 11Lecture 15

12

Basic concepts Principle of least astonishment - study and understand simple phenomena or facts before moving to complex ones. For example:  Concurrency - an application requires multiple threads that run at the same time. Tricky. Understand sequential processing first.  Examine a simple operating system interface to the three abstractions At the same time we need concepts that can be extended; Recall the extension of the UNIX file systems to NFS!! Create a framework which can allow us to deal with more complex phenomena. Example: how to deal with concurrency  Serialization  Critical sections  code that must be executed by a single process to completion.  Locks  mechanisms to ensure serialization Interrupts – external events which require suspension of the current thread, identification of the cause of the interrupt, and reaction to the interrupt. State – critical concepts which allows us to interrupt the execution of a thread and restart it at a later point in time. Event – a change of the state of an interpreter (thread, processor) Lecture 1513

Side effects of concurrency Race condition  error that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence in order to be done correctly. Race conditions depend on the exact timing of events thus are not reproducible.  A slight variation of the timing could either remove a race condition or create.  Very hard to debug such errors. Lecture 1514

Lock Lock  a mechanism to guarantee that a program works correctly when multiple threads execute concurrently  a multi-step operation protected by a lock behaves like a single operation  can be used to implement before-or after atomicity  shared variable acting as a flag (traffic light) to coordinate access to a shared variable  works only if all threads follow the rule  check the lock before accessing a shared variable. 15Lecture 15

The kernel implements the three abstractions The kernel  is responsible for the management of all system resources including the processor  performs operations on behalf of users in response to system calls; in other words extends the instruction set of a processor with a number of operations. Two modes of operation of a computing system  kernel/privileged mode  user mode Multiple functions  Scheduling and thread management  Event handling  Memory management  Communication management Lecture 1516

Thread and VM management – virtual computer The kernel supports thread and virtual memory management Thread management:  Creation and destruction of threads  Allocation of the processor to a ready to run thread  Handling of interrupts  Scheduling – deciding which one of the ready to run threads should be allocated the processor Virtual memory management  maps virtual address space of a thread to physical memory. Each module runs in own address space; if one module runs multiple threads all share one address space. Thread + virtual memory  virtual computer for each module. Lecture 1517

Threads and the Thread Manager Thread  virtual processor - multiplexes a physical processor  a module in execution;  a module may have several threads.  sequence of operations: Load the module’s text Create a thread and lunch the execution of the module in that thread. Scheduler  system component which chooses the thread to run next Thread manager implements the thread abstraction.  Interrupts  processed by the interrupt handler which interacts with the thread manager  Exception  interrupts caused by the running thread and processed by exception handlers  Interrupt handlers run in the context of the OS while exception handlers run in the context of interrupted thread. Lecture 1518

The state of a thread; kernel versus application threads Thread state: Thread Id  unique identifier of a thread Program Counter (PC) -the reference to the next computational step Stack Pointer (SP) PMAR – Page Table Memory Address Register Other registers Application threads – threads running on behalf of users Kernel threads – threads running on behalf of the kernel Lecture 1519

Virtual versus real; the state of a processor Virtual objects need a physical support. In addition to threads we should be concerned with the processor or cores running a thread. A system may have multiple processors and each processor may have multiple cores The state of the processor or core: Processor Id/Core Id  unique identifier of a processor /core Program Counter (PC) -the reference to the next computational step Stack Pointer (SP) PMAR – Page Table Memory Address Register Other registers Lecture 1520

Lecture 1521

22Lecture 15

Virtual machines Allow  multiple operating systems on the same processor.  a processor with a certain instruction set to emulate another one with a different instruction set e.g., the Java Virtual Machines runs under Window, Linux, Mac OS, etc. Lecture 1523

Lecture 1524

Basic primitives for processor virtualization Memory CREATE/DELETE_ADDRESS SPACE ALLOCATE/FREE_BLOCK MAP/UNMAP UNMAP Interpreter ALLOCATE_THREAD DESTROY_THREAD EXIT_THREAD YIELD AWAIT ADVANCE TICKET ACQUIRE RELEASE Communication channel ALLOCATE/DEALLOCATE_BOUNDED_BUFFER SEND/RECEIVE 25Lecture 15

Switching the processor from one thread to another Thread creation: thread_id  ALLOCATE_THREAD(starting_address_of_procedure, address_space_id); YIELD  function implemented by the kernel to allow a thread to wait for an event.  Save the state of the current thread  Schedule another thread  Start running the new thread – dispatch the processor to the new thread YIELD  cannot be implemented in a high level language, must be implemented in the machine language.  can be called from the environment of the thread, e.g., C, C++, Java  allows several threads running on the same processor to wait for a lock. It replaces the busy wait we have used before. Lecture 1526

Thread states and state transitions Lecture 1527

The state of a thread and its associated virtual address space Lecture 1528