pyfinity Documentation

Size: px
Start display at page:

Download "pyfinity Documentation"

Transcription

1 pyfinity Documentation Release Frank Singleton January 26, 2014

2

3 Contents 1 Fast Counters pyfinity.counter_manager_versioned Indices and tables 13 Python Module Index 15 i

4 ii

5 pyfinity is a fast, versioned, mmap counter framework for instrumenting code with low overhead (approximately 4 usec on my old laptop). These counters also exists outside the python vm both during and after the process writing counters has exited. This mmap framework can be used to to decouple counter mutation (writing) from counter reading. The latter is planned to run as a consumer of the counter data, via polling. Contents 1

6 2 Contents

7 CHAPTER 1 Fast Counters This API provides for memory mapped (typically < 4 usec) counter manipulation to support application instrumentation. By using mmap, clients can be written to read the counters periodically and forward them to other destinations as required. MMAP region indexing In order to avoid locking on a common mmap region, the following items are used as input into determining which mmap region should be used. counter group name counter type PID of invoking code TID of invoking code (actually id(tid)) 1.1 pyfinity.counter_manager_versioned pyfinity Copyright (C) , Frank Singleton Utilities for storing and mutating counters in memory mapped structure using mmap. Provides options to increment/decrement 8/16/32/64 bit counters This implementation avoids contention/overhead from mutex/locking. Single writer per mmap region based on f(pid,tid) without locking. Readers also do not use locks, but can be notified if a read was interleaved with a write. This is accomplished by using counter versions. In essence each counter has 2 copies of a version associated with it. 3

8 Counter Versioning Counter version [version_lhs] [counter] [version_rhs] The versions are stepped in the order shown as counters are mutated. If a read attempt reveals that the versions are same or different, the reader can respond appropriately. The assumption is that a read attempt interleaved write will reveal different counter versions and the reader can choose to count that read attempt as invalid. Note: There is one case of a false positive (false counter valid) and that is if the reader reads version_lhs, then the counter, but then 2^32 writes occur (for 32 bit counters) occur, and the writer version_rhs matches the version_lhs when the reader reads that value. If we assume a write takes 1 usec, that means a reader would have to stall during its read for 1e-6 * 2^32 = 4295 seconds in order to have this problem. Hmm, I encourage folks to use 32 and 64bit counters :-) NOTE: counter_index is NOT mmap offset, so do not treat it that way. Work in progress, testing execution times, typically < 4usec. The aim is to have a region of shared memory (via mmap) that threads and processes can access to provide counters for (near realtime) instrumentation capabilities. Currently there are regions dedicated for uint8, uint16, uint32, uint64 unsigned integers. 4 Chapter 1. Fast Counters

9 Supported counter types The following list indicates which counters are currently supported via mmap regions. Unsigned 8 bit counter Unsigned 16 bit counter Unsigned 32 bit counter Unsigned 64 bit counter Also, to avoid locking between process and threads when writing, each group/pid/tid/type combination will have its own mmap region. These files contain enough information for clients to attach via mmap and read counters in a robust manner. The writing of counters is independent of the reader(s) that consume this data. This provides low overhead and flexible consumer design. An example of this are writers updating counters in (near) realtime and readers polling this data on a slower interval to minimize impact on the running system. The counter framework is designed such that every writer (process/thread) writes without contention to their own mmap region, to avoid locking etc. The counter files remain on the file system until explicitly unregistered or reaped by a reaper process. This means processes outside the running Python VM s can also read counters. Timing: Laptop (Fedora 16 VM), typically < 4 usec for uint64 increment pyfinity.counter_manager_versioned.register_user(num_counters, counter_group) Register user and create corresponding mmap counter regions for requested counter type Returns num_counters The number of counters required for this user counter_type, counter_type (COUNTER_TYPE_UINT8, COUNTER_TYPE_UINT16, COUNTER_TYPE_UINT32, COUNTER_TYPE_UINT64) The counter type required for this counter group counter_group (string.) The counter group that this counter belongs to. boolean (True/False) Indicates if registration was successful or not 1.1. pyfinity.counter_manager_versioned 5

10 from pyfinity.counter_manager_versioned import COUNTER_TYPE_UINT32 register_user(10, COUNTER_TYPE_UINT32, counter_group= com.example.superapp ) This example creates space to hold 10 counters. The counters are 32 bit unsigned integers pyfinity.counter_manager_versioned.unregister_user(counter_type, counter_group, remove_file=true) Unregister user and delete corresponding mmap counter regions for requested counter type mmap is flushed first, then file is deleted if requested (default) By default, remove the related counter file. from pyfinity.counter_manager_versioned import COUNTER_TYPE_UINT32 unregister_user(counter_type_uint32, counter_group= com.example.superapp ) This example unregisters the existing 32 bit unsigned mmap region. from pyfinity.counter_manager_versioned import COUNTER_TYPE_UINT64 unregister_user(counter_type_uint64, counter_group= com.example.superapp, remove_file=false) This example unregisters the existing 64 bit unsigned mmap region. It leaves the counter file that was previously created and mmap d in place. This is sometimes useful for post analysis pyfinity.counter_manager_versioned.increment_counter_uint8(counter_index, counter_group, counter_increment=1) Increment an 8 bit unsigned integer counter for specified counter index counter_index (int) The index of the counter to increment ( 0 <= counter_index < num_counters). counter_increment The integer amount to increment the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None increment_counter_uint8(86, counter_group= com.example.superapp ) This example increments an 8 bit unsigned integer belonging to the counter group com.example.superapp at index 86 by 1 (default increment) increment_counter_uint8(4, counter_group= com.example.superapp, counter_increment=3) This example increments an 8 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.increment_counter_uint16(counter_index, counter_group, counter_increment=1) Increment a 16 bit unsigned integer counter for specified counter index 6 Chapter 1. Fast Counters

11 counter_index (int) The index of the counter to increment ( 0 <= counter_index < num_counters). counter_increment The integer amount to increment the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None increment_counter_uint16(42, counter_group= com.example.superapp ) This example increments a 16 bit unsigned integer belonging to the counter group com.example.superapp at index 42 by 1 (default increment) increment_counter_uint16(4, counter_group= com.example.superapp, counter_increment=3) This example increments a 16 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.increment_counter_uint32(counter_index, counter_group, counter_increment=1) Increment a 32 bit unsigned integer counter for specified counter index counter_index (int) The index of the counter to increment ( 0 <= counter_index < num_counters). counter_increment The integer amount to increment the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None increment_counter_uint32(2, counter_group= com.example.superapp ) This example increments a 32 bit unsigned integer belonging to the counter group com.example.superapp at index 2 by 1 (default increment) increment_counter_uint32(4, counter_group= com.example.superapp, counter_increment=3) This example increments a 32 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.increment_counter_uint64(counter_index, counter_group, counter_increment=1) Increment a 64 bit unsigned integer counter for specified counter index 1.1. pyfinity.counter_manager_versioned 7

12 counter_index (int) The index of the counter to increment ( 0 <= counter_index < num_counters). counter_increment The integer amount to increment the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None increment_counter_uint64(3, counter_group= com.example.superapp ) This example increments a 64 bit unsigned integer belonging to the counter group com.example.superapp at index 3 by 1 (default increment) increment_counter_uint64(4, counter_group= com.example.superapp, counter_increment=3) This example increments a 64 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.decrement_counter_uint8(counter_index, counter_group, counter_decrement=1) Decrement a uint8 counter for specified counter index counter_index (int) The index of the counter to decrement ( 0 <= counter_index < num_counters). counter_increment The integer amount to decrement the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None decrement_counter_uint8(42, counter_group= com.example.superapp ) This example decrements an 8 bit unsigned integer belonging to the counter group com.example.superapp at index 42 by 1 (default decrement) decrement_counter_uint8(4, counter_group= com.example.superapp, counter_decrement=3) This example decrements an 8 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.decrement_counter_uint16(counter_index, counter_group, counter_decrement=1) Decrement a uint16 counter for specified counter index 8 Chapter 1. Fast Counters

13 counter_index (int) The index of the counter to decrement ( 0 <= counter_index < num_counters). counter_increment The integer amount to decrement the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None decrement_counter_uint16(42, counter_group= com.example.superapp ) This example decrements a 16 bit unsigned integer belonging to the counter group com.example.superapp at index 42 by 1 (default decrement) decrement_counter_uint16(4, counter_group= com.example.superapp, counter_decrement=3) This example decrements a 16 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.decrement_counter_uint32(counter_index, counter_group, counter_decrement=1) Decrement a uint32 counter for specified counter index counter_index (int) The index of the counter to decrement ( 0 <= counter_index < num_counters). counter_increment The integer amount to increment the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None decrement_counter_uint32(42, counter_group= com.example.superapp ) This example decrements a 32 bit unsigned integer belonging to the counter group com.example.superapp at index 42 by 1 (default decrement) decrement_counter_uint32(4, 3, counter_group= com.example.superapp, counter_decrement=3) This example decrements a 32 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.decrement_counter_uint64(counter_index, counter_group, counter_decrement=1) Decrement a uint64 counter for specified counter index 1.1. pyfinity.counter_manager_versioned 9

14 counter_index (int) The index of the counter to decrement ( 0 <= counter_index < num_counters). counter_increment The integer amount to decrement the counter by. counter_group (string.) The counter group that this counter belongs to. Returns None decrement_counter_uint64(42, counter_group= com.example.superapp ) This example decrements a 64 bit unsigned integer belonging to the counter group com.example.superapp at index 42 by 1 (default decrement) decrement_counter_uint64(4, counter_group= com.example.superapp, counter_decrement=3) This example decrements a 64 bit unsigned integer belonging to the counter group com.example.superapp at index 4 by 3 pyfinity.counter_manager_versioned.get_counter_file_mmap(counter_filename) Return a mmap.mmap object for a given counter filename Assumes that counter_filename has correct format and exists on the local file system. counter_filename The counter group that this counter belongs to. Returns mmap mmap.mmap() instance or None if not supported platform pyfinity.counter_manager_versioned.get_counter_uint8_from_mmap_ref(counter_index, mmap_ref ) Returns uint8 counter value at specified counter_index, or raises an exception if mismatched counter versions are detected This function is provided as a convenience for those callers that already have a valid mmap_ref and want to avoid the overhead of repeatedly creating a mmap_ref for each call to get_counter_file_mmap(counter_filename) counter_index (int) The counter index to read counter from. mmap_ref The memory map reference to use when fetching a counter CounterInvalidState if counter is unstable pyfinity.counter_manager_versioned.get_counter_uint16_from_mmap_ref(counter_index, mmap_ref ) Returns uint16 counter value at specified counter_index, or raises an exception if mismatched counter versions are detected This function is provided as a convenience for those callers that already have a valid mmap_ref and want to avoid the overhead of repeatedly creating a mmap_ref for each call to get_counter_file_mmap(counter_filename) counter_index (int) The counter index to read counter from. mmap_ref The memory map reference to use when fetching a counter CounterInvalidState if counter is unstable 10 Chapter 1. Fast Counters

15 pyfinity.counter_manager_versioned.get_counter_uint32_from_mmap_ref(counter_index, mmap_ref ) Returns uint32 counter value at specified counter_index, or raises an exception if mismatched counter versions are detected This function is provided as a convenience for those callers that already have a valid mmap_ref and want to avoid the overhead of repeatedly creating a mmap_ref for each call to get_counter_file_mmap(counter_filename) counter_index (int) The counter index to read counter from. mmap_ref The memory map reference to use when fetching a counter CounterInvalidState if counter is unstable pyfinity.counter_manager_versioned.get_counter_uint64_from_mmap_ref(counter_index, mmap_ref ) Returns uint64 counter value at specified counter_index, or raises an exception if mismatched counter versions are detected This function is provided as a convenience for those callers that already have a valid mmap_ref and want to avoid the overhead of repeatedly creating a mmap_ref for each call to get_counter_file_mmap(counter_filename) counter_index (int) The counter index to read counter from. mmap_ref The memory map reference to use when fetching a counter CounterInvalidState if counter is unstable pyfinity.counter_manager_versioned.get_counter(counter_index, counter_filename) Get a counter from a counter file at specified counter index Returns counter_index The index of the counter to fetch ( 0 <= counter_index < num_counters). counter_filename The name of the mmap counter file that user wishes to read. int (uint8/uint16/uint32/uint64) Unsigned integer representing counter value CounterInvalidState If counter is unstable get_counter(4, /tmp/counter_com.example.mondec.examples.example1_10_uint_64_mmap_3898_ This example fetches the 64 bit unsigned integer counter belonging to the counter group com.example.superapp at index 4 pyfinity.counter_manager_versioned.get_counters(counter_filename) Get all counters for specified counter filename counter_filename The name of the mmap counter file that user wishes to read. Returns int (uint8/uint16/uint32/uint64) List of Unsigned integers representing counter value. CounterInvalidState If ANY counter is unstable pyfinity.counter_manager_versioned 11

16 get_counter( /tmp/counter_com.example.mondec.examples.example1_10_uint_64_mmap_3898_ This example fetches ALL the 64 bit unsigned integer counter belonging to the specified counter filename pyfinity.counter_manager_versioned.get_counter_group_attributes(counter_filename) For a given counter group filename, return the following attributes as a named tuple of strings (group_name, group_size, group_type, group_pid, group_tid) 12 Chapter 1. Fast Counters

17 CHAPTER 2 Indices and tables genindex modindex search 13

18 14 Chapter 2. Indices and tables

19 Python Module Index p pyfinity.counter_manager_versioned, 3 15

Shared Mutable State SWEN-220

Shared Mutable State SWEN-220 Shared Mutable State SWEN-220 The Ultimate Culprit - Shared, Mutable State Most of your development has been in imperative languages. The fundamental operation is assignment to change state. Assignable

More information

prompt Documentation Release Stefan Fischer

prompt Documentation Release Stefan Fischer prompt Documentation Release 0.4.1 Stefan Fischer Nov 14, 2017 Contents: 1 Examples 1 2 API 3 3 Indices and tables 7 Python Module Index 9 i ii CHAPTER 1 Examples 1. Ask for a floating point number: >>>

More information

ECE 122 Engineering Problem Solving with Java

ECE 122 Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction Outline Problem: How do I input data and use it in complicated expressions Creating complicated expressions

More information

Synchronization COMPSCI 386

Synchronization COMPSCI 386 Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose

More information

G52CON: Concepts of Concurrency

G52CON: Concepts of Concurrency G52CON: Concepts of Concurrency Lecture 4: Atomic Actions Natasha Alechina School of Computer Science nza@cs.nott.ac.uk Outline of the lecture process execution fine-grained atomic actions using fine-grained

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE

More information

IV. Process Synchronisation

IV. Process Synchronisation IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.

More information

nptdms Documentation Release Adam Reeve

nptdms Documentation Release Adam Reeve nptdms Documentation Release 0.11.4 Adam Reeve Dec 01, 2017 Contents 1 Contents 3 1.1 Installation and Quick Start....................................... 3 1.2 Reading TDMS files...........................................

More information

MultiJav: A Distributed Shared Memory System Based on Multiple Java Virtual Machines. MultiJav: Introduction

MultiJav: A Distributed Shared Memory System Based on Multiple Java Virtual Machines. MultiJav: Introduction : A Distributed Shared Memory System Based on Multiple Java Virtual Machines X. Chen and V.H. Allan Computer Science Department, Utah State University 1998 : Introduction Built on concurrency supported

More information

ECE 341. Lecture # 19

ECE 341. Lecture # 19 ECE 341 Lecture # 19 Instructor: Zeshan Chishti zeshan@ece.pdx.edu December 3, 2014 Portland State University Announcements Final exam is on Monday, December 8 from 5:30 PM to 7:20 PM Similar format and

More information

SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine p. 1

SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine p. 1 SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine David Bélanger dbelan2@cs.mcgill.ca Sable Research Group McGill University Montreal, QC January 28, 2004 SABLEJIT: A Retargetable

More information

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores

More information

IntSet Documentation. Release David R. MacIver

IntSet Documentation. Release David R. MacIver IntSet Documentation Release 1.0.0 David R. MacIver October 29, 2015 Contents Python Module Index 3 i ii IntSet Documentation, Release 1.0.0 class intset.intset(wrapped) An IntSet is a compressed immutable

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Distributed File System

Distributed File System Distributed File System Project Report Surabhi Ghaisas (07305005) Rakhi Agrawal (07305024) Election Reddy (07305054) Mugdha Bapat (07305916) Mahendra Chavan(08305043) Mathew Kuriakose (08305062) 1 Introduction

More information

Erlangen API Documentation

Erlangen API Documentation Erlangen API Documentation Max Rottenkolber Monday, 20 November 2017 Table of Contents 1 erlangen (Package) 1 1.1 *agent-debug* (Variable).................... 1 1.2 *default-mailbox-size* (Variable)...............

More information

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

Recap. Contents. Reenterancy of synchronized. Explicit Locks: ReentrantLock. Reenterancy of synchronise (ctd) Advanced Thread programming.

Recap. Contents. Reenterancy of synchronized. Explicit Locks: ReentrantLock. Reenterancy of synchronise (ctd) Advanced Thread programming. Lecture 07: Advanced Thread programming Software System Components 2 Behzad Bordbar School of Computer Science, University of Birmingham, UK Recap How to deal with race condition in Java Using synchronised

More information

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6. Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure

More information

Dealing with Issues for Interprocess Communication

Dealing with Issues for Interprocess Communication Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed

More information

Chapter 7: Process Synchronization!

Chapter 7: Process Synchronization! Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors 7.1 Background Concurrent access to shared

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic

More information

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

based on a previously created custom model an entirely new model

based on a previously created custom model an entirely new model Chapter 11: Custom Library Com'X 510 User Manual Custom Models The Com'X 510 supports the use of custom models. A custom model is any model other than a Built-in model from Schneider Electric. To use a

More information

pyvcd Documentation Release Peter Grayson and Steven Sprouse

pyvcd Documentation Release Peter Grayson and Steven Sprouse pyvcd Documentation Release Peter Grayson and Steven Sprouse Nov 08, 2017 Contents 1 vcd 3 2 vcd.writer 5 3 vcd.gtkw 9 4 PyVCD 15 4.1 Quick Start................................................ 15 5 Indices

More information

semidbm Documentation

semidbm Documentation semidbm Documentation Release 0.4.0 James Saryerwinnie Jr September 04, 2013 CONTENTS i ii semidbm is a pure python implementation of a dbm, which is essentially a persistent key value store. It allows

More information

Process Synchronization

Process Synchronization Process Synchronization Chapter 6 2015 Prof. Amr El-Kadi Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly

More information

Python Statsd Documentation

Python Statsd Documentation Python Statsd Documentation Release 1.0 Rick van Hattem April 14, 2012 CONTENTS i ii Python Statsd Documentation, Release 1.0 Contents: CONTENTS 1 Python Statsd Documentation, Release 1.0 2 CONTENTS CHAPTER

More information

Script Step Reference Information

Script Step Reference Information Script Step Reference Information This chapter lists all the steps available for use in creating scripts. These steps are accessed using the palette pane (see Using the Palette Pane, page 8). This chapter

More information

Cross-platform daemonization tools.

Cross-platform daemonization tools. Cross-platform daemonization tools. Release 0.1.0 Muterra, Inc Sep 14, 2017 Contents 1 What is Daemoniker? 1 1.1 Installing................................................. 1 1.2 Example usage..............................................

More information

DELHI PUBLIC SCHOOL TAPI

DELHI PUBLIC SCHOOL TAPI Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed

More information

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes CSC 4103 - Operating Systems Spring 2008 Lecture - III Processes Tevfik Ko!ar Louisiana State University January 22 nd, 2008 1 Roadmap Virtual Machines Processes Basic Concepts Context Switching Process

More information

Unit 1 Lesson 4. Introduction to Control Statements

Unit 1 Lesson 4. Introduction to Control Statements Unit 1 Lesson 4 Introduction to Control Statements Essential Question: How are control loops used to alter the execution flow of a program? Lesson 4: Introduction to Control Statements Objectives: Use

More information

I/O handling. Purpose. Seven-segment displays. Digital Systems 15 hp

I/O handling. Purpose. Seven-segment displays. Digital Systems 15 hp Namn: Laborationen godkänd: Digital Systems 15 hp I/O handling Purpose The purpose of this laboratory exercise is to demonstrate how to write programs that interact with the different I/O devices available

More information

Process Synchronization

Process Synchronization Process Synchronization Concurrent access to shared data may result in data inconsistency Multiple threads in a single process Maintaining data consistency requires mechanisms to ensure the orderly execution

More information

Dept. of CSE, York Univ. 1

Dept. of CSE, York Univ. 1 EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared

More information

Increment and the While. Class 15

Increment and the While. Class 15 Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment

More information

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

Multitasking / Multithreading system Supports multiple tasks

Multitasking / Multithreading system Supports multiple tasks Tasks and Intertask Communication Introduction Multitasking / Multithreading system Supports multiple tasks As we ve noted Important job in multitasking system Exchanging data between tasks Synchronizing

More information

Products and Records

Products and Records Products and Records Michael P. Fourman February 2, 2010 1 Simple structured types Tuples Given a value v 1 of type t 1 and a value v 2 of type t 2, we can form a pair, (v 1, v 2 ), containing these values.

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Operating Systems (2INC0) 2017/18

Operating Systems (2INC0) 2017/18 Operating Systems (2INC0) 2017/18 Condition Synchronization (07) Dr. Courtesy of Prof. Dr. Johan Lukkien System Architecture and Networking Group Agenda Condition synchronization motivation condition variables

More information

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

More information

Operating Systems 2010/2011

Operating Systems 2010/2011 Operating Systems 2010/2011 Input/Output Systems part 1 (ch13) Shudong Chen 1 Objectives Discuss the principles of I/O hardware and its complexity Explore the structure of an operating system s I/O subsystem

More information

Concurrency User Guide

Concurrency User Guide Concurrency User Guide Release 1.0 Dylan Hackers January 26, 2019 CONTENTS 1 Basic Abstractions 3 1.1 Executors................................................. 3 1.2 Queues..................................................

More information

1 Process Coordination

1 Process Coordination COMP 730 (242) Class Notes Section 5: Process Coordination 1 Process Coordination Process coordination consists of synchronization and mutual exclusion, which were discussed earlier. We will now study

More information

Find the flaw. Also show a timing diagram that indicates the sequence of actions for several interleavings.

Find the flaw. Also show a timing diagram that indicates the sequence of actions for several interleavings. ECS150 Winter 2004 Homework Assignment 3 Due: Wednesday, 10 March 2004, 4:30PM, HW box, EUII Question 1: Tanenbaum, Chapter 2-35 Question 2: Tanenbaum, Chapter 2-36 Question 3: Jurassic Park consists of

More information

COP 4225 Advanced Unix Programming. Synchronization. Chi Zhang

COP 4225 Advanced Unix Programming. Synchronization. Chi Zhang COP 4225 Advanced Unix Programming Synchronization Chi Zhang czhang@cs.fiu.edu 1 Cooperating Processes Independent process cannot affect or be affected by the execution of another process. Cooperating

More information

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1 CSE123 LECTURE 3-1 Program Design and Control Structures Repetitions (Loops) 1-1 The Essentials of Repetition Loop Group of instructions computer executes repeatedly while some condition remains true Counter-controlled

More information

Multiprocessor Cache Coherence. Chapter 5. Memory System is Coherent If... From ILP to TLP. Enforcing Cache Coherence. Multiprocessor Types

Multiprocessor Cache Coherence. Chapter 5. Memory System is Coherent If... From ILP to TLP. Enforcing Cache Coherence. Multiprocessor Types Chapter 5 Multiprocessor Cache Coherence Thread-Level Parallelism 1: read 2: read 3: write??? 1 4 From ILP to TLP Memory System is Coherent If... ILP became inefficient in terms of Power consumption Silicon

More information

Process Synchronization

Process Synchronization TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Process Synchronization [SGG7] Chapter 6 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin

More information

Synchronization for Concurrent Tasks

Synchronization for Concurrent Tasks Synchronization for Concurrent Tasks Minsoo Ryu Department of Computer Science and Engineering 2 1 Race Condition and Critical Section Page X 2 Algorithmic Approaches Page X 3 Hardware Support Page X 4

More information

Process Synchronization

Process Synchronization CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem

More information

Lecture 9: Introduction to Monitors

Lecture 9: Introduction to Monitors COMP 150-CCP Concurrent Programming Lecture 9: Introduction to Monitors Dr. Richard S. Hall rickhall@cs.tufts.edu Concurrent programming February 14, 2008 Abstracting Locking Details Recall our discussion

More information

Lesson 6: Process Synchronization

Lesson 6: Process Synchronization Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

CompSci 125 Lecture 11

CompSci 125 Lecture 11 CompSci 125 Lecture 11 switch case The? conditional operator do while for Announcements hw5 Due 10/4 p2 Due 10/5 switch case! The switch case Statement Consider a simple four-function calculator 16 buttons:

More information

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are

More information

Programming in C++ 5. Integral data types

Programming in C++ 5. Integral data types Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long

More information

Background. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.

Background. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling. Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency

More information

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks

More information

Parallel Programming Languages COMP360

Parallel Programming Languages COMP360 Parallel Programming Languages COMP360 The way the processor industry is going, is to add more and more cores, but nobody knows how to program those things. I mean, two, yeah; four, not really; eight,

More information

CT 229. Java Syntax 26/09/2006 CT229

CT 229. Java Syntax 26/09/2006 CT229 CT 229 Java Syntax 26/09/2006 CT229 Lab Assignments Assignment Due Date: Oct 1 st Before submission make sure that the name of each.java file matches the name given in the assignment sheet!!!! Remember:

More information

142

142 Scope Rules Thus, storage duration does not affect the scope of an identifier. The only identifiers with function-prototype scope are those used in the parameter list of a function prototype. As mentioned

More information

The check bits are in bit numbers 8, 4, 2, and 1.

The check bits are in bit numbers 8, 4, 2, and 1. The University of Western Australia Department of Electrical and Electronic Engineering Computer Architecture 219 (Tutorial 8) 1. [Stallings 2000] Suppose an 8-bit data word is stored in memory is 11000010.

More information

GNU ccscript Scripting Guide IV

GNU ccscript Scripting Guide IV GNU ccscript Scripting Guide IV David Sugar GNU Telephony 2008-08-20 (The text was slightly edited in 2017.) Contents 1 Introduction 1 2 Script file layout 2 3 Statements and syntax 4 4 Loops and conditionals

More information

1007 Imperative Programming Part II

1007 Imperative Programming Part II Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be

More information

Python Working with files. May 4, 2017

Python Working with files. May 4, 2017 Python Working with files May 4, 2017 So far, everything we have done in Python was using in-memory operations. After closing the Python interpreter or after the script was done, all our input and output

More information

Scheduling API. Getting Started. Scheduling API Overview CHAPTER

Scheduling API. Getting Started. Scheduling API Overview CHAPTER 2 CHAPTER Revised January 30, 2013 The Cisco TelePresence Exchange System provides the Scheduling Application Programming Interface (API) to facilitate the development of scheduling portals and other software

More information

Threads. Concurrency. What it is. Lecture Notes Week 2. Figure 1: Multi-Threading. Figure 2: Multi-Threading

Threads. Concurrency. What it is. Lecture Notes Week 2. Figure 1: Multi-Threading. Figure 2: Multi-Threading Threads Figure 1: Multi-Threading Figure 2: Multi-Threading Concurrency What it is 1. Two or more threads of control access a shared resource. Scheduler operation must be taken into account fetch-decode-execute-check

More information

Process Synchronization (Part I)

Process Synchronization (Part I) Process Synchronization (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Process Synchronization 1393/7/14 1 / 44 Motivation

More information

DATA STRUCTURE AND ALGORITHM USING PYTHON

DATA STRUCTURE AND ALGORITHM USING PYTHON DATA STRUCTURE AND ALGORITHM USING PYTHON Advanced Data Structure and File Manipulation Peter Lo Linear Structure Queue, Stack, Linked List and Tree 2 Queue A queue is a line of people or things waiting

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

Outline. Introduction. Survey of Device Driver Management in Real-Time Operating Systems

Outline. Introduction. Survey of Device Driver Management in Real-Time Operating Systems Survey of Device Driver Management in Real-Time Operating Systems Sebastian Penner +46705-396120 sebastian.penner@home.se 1 Outline Introduction What is a device driver? Commercial systems General Description

More information

Concurrent Counting using Combining Tree

Concurrent Counting using Combining Tree Final Project Report by Shang Wang, Taolun Chai and Xiaoming Jia Concurrent Counting using Combining Tree 1. Introduction Counting is one of the very basic and natural activities that computers do. However,

More information

The Big Python Guide

The Big Python Guide The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String

More information

Atropos User s manual

Atropos User s manual Atropos User s manual Jan Lönnberg 22nd November 2010 1 Introduction Atropos is a visualisation tool intended to display information relevant to understanding the behaviour of concurrent Java programs,

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

Advance Operating Systems (CS202) Locks Discussion

Advance Operating Systems (CS202) Locks Discussion Advance Operating Systems (CS202) Locks Discussion Threads Locks Spin Locks Array-based Locks MCS Locks Sequential Locks Road Map Threads Global variables and static objects are shared Stored in the static

More information

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A DEBUGGING TIPS COMPUTER SCIENCE 61A 1 Introduction Every time a function is called, Python creates what is called a stack frame for that specific function to hold local variables and other information.

More information

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2 CONTENTS: Compilation Data and Expressions COMP 202 More on Chapter 2 Programming Language Levels There are many programming language levels: machine language assembly language high-level language Java,

More information

Introduction to Assembler Language Programming

Introduction to Assembler Language Programming Introduction to Assembler Language Programming Fibonacci # Compute first twelve Fibonacci numbers and put in array, then print.data fibs:.word 0 : 12 # "array" of 12 words to contain fib values size:.word

More information

Chapter 3 Structured Program Development in C Part II

Chapter 3 Structured Program Development in C Part II Chapter 3 Structured Program Development in C Part II C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 3.7 The while Iteration Statement An iteration statement (also called

More information

27 Designing Your Own Program

27 Designing Your Own Program 27 Designing Your Own Program 27.1 Using API s...27-2 27.2 Device Access APIs...27-19 27.3 Cache Buffer Control APIs...27-30 27.4 Queuing Access Control APIs...27-36 27.5 System APIs...27-39 27.6 SRAM

More information

Exceptions. Exceptions. Can have multiple except suites and/or one unnamed except suite

Exceptions. Exceptions. Can have multiple except suites and/or one unnamed except suite Exceptions An exception is an error which occurs while a program is running. try-except statement: o monitor code that could produce an error o provide error-specific recovery code suite to handle specific

More information

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski Operating Systems Design Fall 2010 Exam 1 Review Paul Krzyzanowski pxk@cs.rutgers.edu 1 Question 1 To a programmer, a system call looks just like a function call. Explain the difference in the underlying

More information

Chapter 6: Process Synchronization. Module 6: Process Synchronization

Chapter 6: Process Synchronization. Module 6: Process Synchronization Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

VERIS H8035 and H8036

VERIS H8035 and H8036 VERIS H8035 and H8036 MODBUS IMPLEMENTATION SPECIFICATION OVERVIEW This document describes the implementation of Modbus protocol used in the Veris H8035 and H8036 power meters. It is intended to assist

More information

spnav Documentation Release 0.9 Stanley Seibert

spnav Documentation Release 0.9 Stanley Seibert spnav Documentation Release 0.9 Stanley Seibert February 04, 2012 CONTENTS 1 Documentation 3 1.1 Setup................................................... 3 1.2 Usage...................................................

More information

Data structure and algorithm in Python

Data structure and algorithm in Python Data structure and algorithm in Python Array-Based Sequences Xiaoping Zhang School of Mathematics and Statistics, Wuhan University Table of contents 1. Python s Sequence Types 2. Low-Level s Arrays 3.

More information

OpenVMS Performance Update

OpenVMS Performance Update OpenVMS Performance Update Gregory Jordan Hewlett-Packard 2007 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Agenda System Performance Tests

More information

Tracing User Guide. Release 1.0. Bruce Mitchener, Jr.

Tracing User Guide. Release 1.0. Bruce Mitchener, Jr. Tracing User Guide Release 1.0 Bruce Mitchener, Jr. January 15, 2019 CONTENTS 1 Instrumenting Your Code 3 1.1 Setting up Sampling........................................... 3 2 The TRACING-CORE module

More information

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

C++ Programming Lecture 7 Control Structure I (Repetition) Part I C++ Programming Lecture 7 Control Structure I (Repetition) Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department while Repetition Structure I Repetition structure Programmer

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

Process Management And Synchronization

Process Management And Synchronization Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the

More information

Chapters 5 and 6 Concurrency

Chapters 5 and 6 Concurrency Operating Systems: Internals and Design Principles, 6/E William Stallings Chapters 5 and 6 Concurrency Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Concurrency When several processes/threads

More information

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information