Design III Chapter 13 9/20/2018 Crowley OS Chap. 13.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Part IV: Memory Management
Names and Bindings.
Computer Organization and Architecture
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Computer Organization and Architecture
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Processes CSCI 444/544 Operating Systems Fall 2008.
Multiprocessing Memory Management
CS 104 Introduction to Computer Science and Graphics Problems
Memory Management 2010.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CH12 CPU Structure and Function
System Calls 1.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 8: Main Memory.
Computer Systems Organization CS 1428 Foundations of Computer Science.
1 Names, Scopes and Bindings Aaron Bloomfield CS 415 Fall
Chapter 4 Storage Management (Memory Management).
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
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 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
COP4020 Programming Languages Subroutines and Parameter Passing Prof. Xin Yuan.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
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.
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
Smalltalk Implementation Harry Porter, October 2009 Smalltalk Implementation: Optimization Techniques Prof. Harry Porter Portland State University 1.
Chapter Overview General Concepts IA-32 Processor Architecture
CS 140 Lecture Notes: Virtual Memory
Introduction to Operating Systems
Processes and threads.
Names and Attributes Names are a key programming language feature
WWW and HTTP King Fahd University of Petroleum & Minerals
Chapter 8: Main Memory.
Naming and Binding A computer system is merely a bunch of resources that are glued together with names Thus, much of system design is merely making choices.
Day 12 Threads.
Chapter 9 – Real Memory Organization and Management
Chapter 8 Main Memory.
Processes in Unix, Linux, and Windows
Threads & multithreading
I/O Devices Chapter 14 9/20/2018 Crowley OS Chap. 14.
The Hardware Interface
CS 140 Lecture Notes: Virtual Memory
Design IV Chapter 18 11/14/2018 Crowley OS Chap. 18.
Introduction to Operating Systems
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
CS 140 Lecture Notes: Virtual Memory
Memory Management Tasks
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Lecture 30 Syed Mansoor Sarwar
CS510 Operating System Foundations
C Data Types and Variable
CSE 153 Design of Operating Systems Winter 2019
Chapter 11 Processor Structure and function
CS 140 Lecture Notes: Virtual Memory
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Dynamic Binary Translators and Instrumenters
CSE 542: Operating Systems
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

Design III Chapter 13 9/20/2018 Crowley OS Chap. 13

Key concepts in chapter 13 Multiplexing Late binding binding time lazy creation Static versus dynamic when each is best Space-time tradeoffs Using simple analytic models 9/20/2018 Crowley OS Chap. 13

Design technique: Multiplexing Multiplexing: sharing a resource between two or more users space multiplexing: each user gets a part of the resource (simultaneous use) e.g. two processes in memory, two non-overlapping windows on a display screen time multiplexing: each user get the whole resource for a limited length of time (serial reuse) e.g.processes getting time slices of the processor, switching a window between two documents 9/20/2018 Crowley OS Chap. 13

Examples of multiplexing OS examples memory: space multiplexed, also time multiplexed with virtual memory windows: time and space multiplex a screen Other examples Sharing communication links: time multiplexed and space (by frequency) multiplexed 9/20/2018 Crowley OS Chap. 13

Space-multiplexing a display 9/20/2018 Crowley OS Chap. 13

Time-multiplexing a display 9/20/2018 Crowley OS Chap. 13

Time- and space-multiplexing 9/20/2018 Crowley OS Chap. 13

Time-multiplexing satellite channels 9/20/2018 Crowley OS Chap. 13

Design technique: Late binding Late binding: delay a computation or resource allocation as long as possible Motivating example: In virtual memory we delay allocating page frames until the page is accessed for the first time 9/20/2018 Crowley OS Chap. 13

Late binding examples OS examples CS examples Virtual memory Network routing: decide route at late moment CS examples Stack allocation: allocate procedure variables when the procedure is called Key encoding: send key numbers, bind to ASCII codes later in the processing Manufacturing: “just in time” inventory, don’t keep inventory very long 9/20/2018 Crowley OS Chap. 13

Binding time A concept taken from programming languages: binding a value to an attribute binding a variable to a value: late, assignment time binding a local variable to storage: late, at procedure call time binding a variable to a type early in most languages, compile time late in Lisp, Smalltalk, etc., a run time 9/20/2018 Crowley OS Chap. 13

Lazy creation Wait to create objects until they are needed Fetch web page images only when they are visible Create windows only when they are about to become visible Copy of a large memory area: use copy-on-write to create the copy as late as possible Lazy evaluation: of function arguments, only evaluate them when they are used, not at the time of the function call. 9/20/2018 Crowley OS Chap. 13

Late binding issues Sometime late bindings do not have to be done at all so we save resources (e.g. the browser never scrolls down to the image) Resources are not used until they are needed Late binding is often more expensive than early binding (where you can combine binding as get economies of scale) Compilers use early binding of source to code and interpreters use late binding 9/20/2018 Crowley OS Chap. 13

More late binding issues Reservations: a form of early binding used where the cost of waiting for a resource is high Connectionless protocols use late binding, connection protocols use early binding Dynamic = late binding Static = early binding 9/20/2018 Crowley OS Chap. 13

Design technique: Static vs. dynamic Static: done before the computation begins static solutions are usually faster static solutions use more memory static computation are done only once Dynamic: done after the computation begins dynamic solutions are usually more flexible dynamic solutions use more computation dynamic computation are often done several times 9/20/2018 Crowley OS Chap. 13

Static and dynamic activities 9/20/2018 Crowley OS Chap. 13

OS examples Programs are static, processes are dynamic Relocation: can be done statically by changing the code or dynamically by changing the addresses Linking: can be static or dynamic Process creation: static in a few very specialized OSs Scheduling: static in many real-time OSs static scheduling is more predictable 9/20/2018 Crowley OS Chap. 13

Static scheduling of processes 9/20/2018 Crowley OS Chap. 13

CS examples Memory allocation: static or dynamic Compilers are static, interpreters are dynamic Type checking: static in strongly typed languages (C++, Ada, etc), dynamic in Smalltalk, Lisp, Tcl, Perl, etc. Instruction counting: static = count instructions in the code, dynamic = count instruction executions in a process 9/20/2018 Crowley OS Chap. 13

Design technique: Space/time tradeoffs We can almost always trade computation time for memory use memory to save the results of previous computations compute results again rather than storing them Example: counting bits in a word see the code on the following slides 9/20/2018 Crowley OS Chap. 13

Bit counting: one at a time inline int CountBitsInWordByBit( int word ); int CountBitsInArray( int words[ ], int size ) { int totalBits = 0; for( int i = 0; i < size; ++i ) { totalBits += CountBitsInWordByBit(words[i]); } return totalBits; } enum{ BitsPerWord=32 }; inline int CountBitsInWordByBit( int word ) { int bitsInWord = 0; for( int j = 0; j < BitsPerWord; ++j ) { // Add in the low order bit. bitsInWord += word & 1; word >>= 1; } return bitsInWord; } 9/20/2018 Crowley OS Chap. 13

Bit counting: four at a time enum{ HalfBytesPerWord=8, ShiftPerHalfByte=4, MaskHalfByte=0xF }; // Number of 1 bits in the first 16 binary integers // 0000=0 0001=1 0010=1 0011=2 0100=1 0101=2 0110=2 // 0111=3 1000=1 1001=2 1010=2 1011=3 1100=2 1101=3 // 1110=3 1111=4 int BitsInHalfByte[16] = {0, 1, 1, 2, 1, 2, 3, 3, 1, 2, 2, 3, 2, 3, 3, 4}; inline int CountBitsInWordByHalfByte( int word ) { int bitsInWord = 0; for( int j = 0; j < HalfBytesPerWord; ++j ) { // Index the table by the low order 4 bits bitsInWord += BitsInHalfByte[word & MaskHalfByte]; word >>= ShiftPerHalfByte; } return bitsInWord; } 9/20/2018 Crowley OS Chap. 13

Bit counting: eight at a time inline int CountBitsInWordByByte( int word ); int CountArrayInitialized = 0; int CountBitsInArray( int words[ ], int size ) { int totalBits = 0; if( !CountArrayInitialized ) { InitializeCountArray(); CountArrayInitialized = 1; } for( int i = 0; i < size; ++i ) { totalBits += CountBitsInWordByByte(words[i]); } return totalBits; } 9/20/2018 Crowley OS Chap. 13

Bit counting: eight at a time enum{BytesPerWord=4,ShiftPerByte=8,MaskPerByte=0xFF}; int BitsInByte[256]; void InitializeCountArray( void ) { for( int i = 0; i < 256; ++i ) { BitsInByte[i] = CountBitsInWordByBit( i ); } } inline int CountBitsInWordByByte( int word ) { int bitsInWord = 0; for( int j = 0; j < BytesPerWord; ++j ) { bitsInWord += BitsInByte[word & MaskPerByte]; word >>= ShiftPerByte; } return bitsInWord; } 9/20/2018 Crowley OS Chap. 13

Time/space tradeoff examples Caching: uses space to save time In-line procedures: use space to save time Encoded fields: use (decoding) time to save space Redundant data (e.g., extra links in a data structure): use space to save time Postscript: uses time to save space Database indexes: use space to save time any index trades of space for time 9/20/2018 Crowley OS Chap. 13