Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Threads, SMP, and Microkernels
Part IV: Memory Management
Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Instruction Set Design
Computer Organization and Architecture
Prof. Necula CS 164 Lecture 141 Run-time Environments Lecture 8.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Processes CSCI 444/544 Operating Systems Fall 2008.
CS 536 Spring Run-time organization Lecture 19.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
Run time vs. Compile time
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH. Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
A. Frank - P. Weisberg Operating Systems Real Memory Management.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 9 – Real Memory Organization and Management Outline 9.1 Introduction 9.2Memory Organization.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Tutorial 6 Memory Management
System Calls 1.
COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Lecture 3 Page 1 CS 111 Summer 2015 Processes and Threads CS 111 Operating System Principles Peter Reiher.
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Runtime Environments Compiler Construction Chapter 7.
Lecture 5 Page 1 CS 111 Winter 2014 Processes CS 111 Operating Systems Peter Reiher.
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
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.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
Process by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
Lecture 11 Page 1 CS 111 Online Memory Management: Paging and Virtual Memory CS 111 On-Line MS Program Operating Systems Peter Reiher.
Chapter 4 Memory Management Virtual Memory.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Lecture 2 Page 1 CS 111 Online System Services for OSes One major role of an operating system is providing services – To human users – To applications.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Processes and Virtual Memory
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
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.
Lecture 7 Page 1 CS 111 Online Process Communications and Concurrency CS 111 On-Line MS Program Operating Systems Peter Reiher.
What is a Process ? A program in execution.
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Lecture 10 Page 1 CS 111 Online Memory Management CS 111 On-Line MS Program Operating Systems Peter Reiher.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Lecture 5 Page 1 CS 111 Online Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Embedded Real-Time Systems
Introduction to Operating Systems Concepts
Lecture 3 Translation.
Process Management Process Concept Why only the global variables?
Outline Paging Swapping and demand paging Virtual memory.
Chapter 9 – Real Memory Organization and Management
Run-time organization
Process Realization In OS
Intro to Processes CSSE 332 Operating Systems
Modularity and Memory Clearly, programs must have access to memory
Design III Chapter 13 9/20/2018 Crowley OS Chap. 13.
Operating Systems Lecture 3.
Operating Systems: A Modern Perspective, Chapter 6
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 2019
Presentation transcript:

Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher

Lecture 5 Page 2 CS 111 Online Outline Processes and threads Going from conceptual to real systems How does the OS handle processes and threads? Creating and destroying processes

Lecture 5 Page 3 CS 111 Online Processes and Threads Threads are a simple concept They are used in real operating systems But they aren’t the actual key interpreter abstraction of real operating systems Systems like Linux and Windows use another abstraction – The process

Lecture 5 Page 4 CS 111 Online What Is a Process? Essentially, a virtual machine for running a program So it contains state And resources required to do its work – Like threads, virtual memory, communications primitives Most machines run multiple processes – Serially and simultaneously

Lecture 5 Page 5 CS 111 Online Processes and Programs A program is a static representation of work to be done A process is the dynamic, running instantiation of a program Most programs are run many different times – On the same or different machines Each individual run is represented by a unique process – Which has a discrete start and (usually) end

Lecture 5 Page 6 CS 111 Online How Does a Process Differ From a Thread? Processes are a higher level abstraction They can contain multiple threads – Implying that there can be simultaneous actions within one program – Which is not possible in a thread They typically encapsulate an entire running program They are heavier weight

Lecture 5 Page 7 CS 111 Online The OS and Processes There is one physical machine and multiple virtual machines Something must handle proper multiplexing of virtual to physical That’s the operating system’s job Aspects of the job: – Safety – Fairness – Performance

Lecture 5 Page 8 CS 111 Online What Must the OS Do For Processes? Set them up to run properly Isolate them from other processes Ensure that all processes get a chance to do their work Start and end processes Share the physical resources properly

Lecture 5 Page 9 CS 111 Online Multiplexing Processes Similar in many ways to multiplexing states There are one or more physical cores that can execute threads There are a bunch of processes to run – Each with one or more threads The OS must assign processes (and their threads) to cores – Switching as necessary This requires setting up process state

Lecture 5 Page 10 CS 111 Online Process State Similar to thread state Need information on: – What instruction to run next – Where the process’ memory is located – What are the contents of important registers – What other resources (physical or virtual) are available to the process – Perhaps security-related information (like owner)

Lecture 5 Page 11 CS 111 Online Process State and Registers Several registers required for each process General registers – Operands and results of arithmetic/logical operations – Addresses and indexes for operands in memory Program counter – Address of the next instruction to fetch & execute Processor status word – Condition codes, execution mode, other CPU state

Lecture 5 Page 12 CS 111 Online Process State and Memory Processes have several different types of memory segments – The memory holding their code – The memory holding their stack – The memory holding their data Each is somewhat different in its purpose and use

Lecture 5 Page 13 CS 111 Online Process Code Memory The instructions to be executed to run the process Typically static – Loaded when the process starts – Then they never change Of known, fixed size Often, a lot of the program code will never be executed by a given process running it

Lecture 5 Page 14 CS 111 Online Implications for the OS Obviously, memory object holding the code must allow execution – Need not be writeable Self-modifying code is a bad idea, usually – Should it be readable? Can use a fixed size domain – Which can be determined before the process executes Possibility of loading the code on demand

Lecture 5 Page 15 CS 111 Online Process Stack Memory Memory holding the run-time state of the process Modern languages and operating systems are stack oriented – Routines call other routines – Expecting to regain control when the called routine exits – Arbitrarily deep layers of calling The stack encodes that

Lecture 5 Page 16 CS 111 Online Stack Frames Each routine that is called keeps its relevant data in a stack frame – Its own piece of state Stack frames contain: – Storage for procedure local (as opposed to global) variables – Storage for invocation parameters – Space to save and restore registers Popped off stack when call returns

Lecture 5 Page 17 CS 111 Online Characteristics of Stack Memory Of unknown and changing size – Grows when functions are called – Shrinks when they return Contents created dynamically – Not the same from run to run – Often data-dependent Not inherently executable – Contains pointers to code, not code itself A compact encoding of the dynamic state of the process

Lecture 5 Page 18 CS 111 Online Implications for the OS The memory domain for the stack must be readable and writeable – But need not be executable OS must worry about stack overrunning the memory area it’s in – What to do if it does? Extend the domain? Kill the process?

Lecture 5 Page 19 CS 111 Online Process Data Memory All the data the process is operating on Of highly varying size – During a process run – From run to run of a process Read/write access required – Usually not execute access – Few modern systems allow processes to create new code

Lecture 5 Page 20 CS 111 Online Implications for the OS Must be prepared to give processes new domains for dynamic data – Since you can’t generally predict ahead of time how much memory a process will need – Need strategy if process asks for more memory than you can give it Should give read/write permission to these domains – Usually not execute

Lecture 5 Page 21 CS 111 Online Layout of Process in Memory 0x xFFFFFFFF codedatastack

Lecture 5 Page 22 CS 111 Online Layout of Process in Memory In Unix systems, data segment grows up Stack segment grows down They aren’t allowed to meet 0x xFFFFFFFF codedatastack

Lecture 5 Page 23 CS 111 Online Loading Programs Into Processes The program represents a piece of code that could be executed The process is the actual dynamic executing version of the program To get from the code to the running version, you need to perform the loading step – Initializing the various memory domains we just mentioned

Lecture 5 Page 24 CS 111 Online Loading Programs The load module (output of linkage editor) – All external references have been resolved – All modules combined into a few segments – Includes multiple segments (code, data, symbol table) A computer cannot “execute” a load module – Computers execute instructions in memory – Memory must be allocated for each segment – Code must be copied from load module to memory