Systems Programming/ C and UNIX

Size: px
Start display at page:

Download "Systems Programming/ C and UNIX"

Transcription

1 Systems Programming/ C and UNIX A. Fischer CSCI 4547/6647 What is Time? November 6, 2017 A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

2 Outline 1 What is time? 2 Representations of Time Time Functions A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

3 What is time? What is time? Real Time and Elapsed Time Universal Time Time Accuracy A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

4 What is time? Real Time and Elapsed Time We use the word time in two ways: When: at what point in the history of the universe did an event take place. What time is it now? I will use time or clock time or real time to talk about when. How long: how many time units elapsed between the beginning and the end of an event? I will call this elapsed time. This seems like a simple subject but it is truly NOT simple. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

5 What is time? Universal Time We have to measure a physical phenomenon, like time, before we can talk about it, store it, or use it. The world has an official time standard, maintained by a standards committee. It is based on astronomical observations and an atomic clock: UT1 is one form of Universal time, established by measuring the Earth s movement relative to a distant quasar. It is the same if measured anywhere on earth. The problem is that Earth s rotation is slightly irregular. UTC, or Coordinated Universal Time is measured using a completely regular atomic clock. It approximates UT1 and is the basis for world-wide civil time. This is kept synchronized with UT1 by adding leap-seconds to the UTC clock when the drift reaches.9 seconds. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

6 What is time? Time Accuracy We set our clocks from some Universal Time reference clock, and hope they stay accurate. Any clock could be off in two ways: Drift: A clock could run a bit too fast or a bit too slow, or irregularly, and thus differ from the actual global time standard by some number of time units. Resolution: A time could be exactly on the global time standard, but be expressed in units that offer little precision. A measurement in seconds is less precise than a measurement in nanoseconds. When we record a real-time value, it might be recorded in an absolute frame of reference (UTC, or Universal Time) or in a relative frame of reference (Eastern Standard Time). A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

7 What is time? Drift Are our clocks always right? If a clock loses power and stops, it must be reset before it can be used at all. When the seasons change, clocks are set forward or back for daylight savings time. If a clock s time drifts gradually, it must be reset eventually. However, the drift may be small and not be noticed or corrected for a while. When a clock is corrected, its time suddenly jumps forward or back. People can cope with these changes. Computers cope less well. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

8 What is time? Resolution What units do we use to measure time? Years? Good enough for ages. Days? Good enough for due dates. Seconds? Good enough for most human work, and to time program execution on a Commadore-64 The system s software clock measures time in jiffies:.01 to.001 seconds, depending on the version of your kernel. Microseconds? Appropriate for timing events at the scale of today s CPU. Modern computers are able to measure time at this resolution. The resolution of our clocks and timers must be meaningful for the measurement task. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

9 System Time How Time is Used in Unix Representations of Time A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

10 System Time Most computers have a battery-powered hardware clock that the system reads at boot time in order to initialize the system s software clock. The software clock defines the system time. Unix systems run a daemon that constantly communicates using the SNTP protocol (Simple Network Time Protocol) to stay synchronized with the official network time authority. The system clock is adjusted to conform to the network clock. It could be set either forward or backward. It is probable that some of the protocols will gradually slow down a clock that is too fast, until it comes into synchrony with the standard. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

11 System Time Star time Global time International Telecommunication Union Network Time System Time A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

12 How Time is Used in Unix Unix uses an absolute coordinate system that is based on global time. Each file has a creation time, a time of last modification, and a time of last access, recorded in system time. File times are the basis for maintaining consistency and currency among related files and file systems. cron jobs are executed automatically to do tasks such as backup at specific system times. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

13 How Intervals are Used in Unix Each process maintains a total elapsed time, the total execution time of system calls, and the total execution time of the user code, including all daughter threads, and excluding system calls. Execution time is used for time-sharing the CPU, for measuring performance and for charging customers on shared commercial systems. Modern systems support measurement of microsecond intervals, some smaller. Intervals are used to end timeouts (sleep). A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

14 Mirrors and Backups These programs use date the of last modification of a file. rsync is a brilliant algorithm developed by Andrew Tridgell. It is capable of maintaining a backup mirror of a directory either locally or remotely over the network. The number of bytes that must be transmitted is minimized by sending differences, not whole files. I use the rsync command constantly to move files from one to another of my four personal machines. rsync machine1:source/ machine1:destination/ I can push files from here to elsewhere, or pull from there to here. rsync. machine2:destination/ rsync machine1:source/. My home file directory is backed up automatically each night by a cron job running rdiff-backup, which is based on the rsync library. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

15 Problems with Time Because our time tools are not perfect Recorded Unix times are absolute, but they are displayed in local time coordinates. A translation must therefore be done each time a date is displayed. A time recorded by non-unix-aware software might be in a relative, not absolute, coordinate system. The real time, recorded simultaneously on two different Unix machines, might be different if one is not connected to the internet. Systems like rsync rely on the accuracy of the timestamps of files on two different machines. If one machine is off, the software cannot work properly. When the local time is adjusted to synchronize with network time, it might need to go backwards. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

16 Representations of Time Representations of Time and Date The basic Unix times representation is an integer type, time_t, giving milliseconds since Jan 1, 1970 Negative date values go back to December 13, On February 13, 2009 at 23:31:30 (UTC) the Unix time was Worldwide, people had parties to celebrate this event. Currently, type time_t is the same length as a long int. This representation will be good until January 19, Before then, the Unix world will need to begin using more than 4 bytes for a date. Already, our hardware is beginning to support 8-byte integers. Also, we already need a finer mesh than milliseconds. So... it will change and we don t know when. So... don t rely on any particular implementation use type time_t and library functions to process dates.. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

17 Representations of Time The Time Structure A secondary time representation is broken down into readable fields: #include <time.h> struct tm { int tm_sec; // seconds int tm_min; // minutes int tm_hour; // hours int tm_mday; // day of the month int tm_mon; // month int tm_year; // year int tm_wday; // day of the week int tm_yday; // day in the year int tm_isdst; // daylight saving time }; Standard functions are used to convert between time_t and struct tm. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

18 Representations of Time High-resolution Time The timespec structure is normally used in combination with time_t to provide finer resolution for binary times. struct timeval { // defined in <sys/time.h> time_t tv_sec; // seconds since Jan suseconds_t tv_usec; // and microseconds }; struct timespec { // defined in <time.h> time_t tv_sec; // Seconds since 00:00:00 GMT Jan 1, 1970 long tv_nsec; // Additional nanoseconds since then } timespec_t; A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

19 Representations of Time More Time Definitions useconds_t // defined in <unistd.h> an integer rep for microseconds that depends on the hardware. struct timezone { int tz_minuteswest; int tz_dsttime; }; // defined in <sys/time.h> // of Greenwich // type of dst correction to use struct itimerval { // defined in <sys/time.h> struct timeval it_interval; // timer interval struct timeval it_value; // current value }; A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

20 Time Functions Time Functions All of these are in time.h. System time is stored as UTC (Coordinated Universal Time) time_t now = time( NULL ); // Read the system clock. Once you have a time_t, it can be converted to and from other forms using library functions: struct tm nowstruct = localtime( now ); struct tm nowstruct = gmtime( now ); These two formats can be converted to printable strings: char nowstring[25] = ctime( now ); char* now2 = asctime( &nowstruct ); tools contains a set of functions to extract the date (today()) and time (oclock()) separately. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

21 Time Functions Time Functions Use these variables: time_t time1, time2, elapsed; struct tm timestr; Convert from struct to integer format in current time zone: time1 = mktime( &timestr ); Convert from struct to integer format in UTC time: time1 = timegm( &timestr ); Interval from time1 to time2, in seconds. elapsed = difftime(time2, time1); A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

22 Time Functions Functions for Formatting Times Use these variables: int resultlength; struct tm timestr; char *st; char buffer[25]; Format the time, producing a string. (Like a Java tostring().) See man page for format details. resultlength = strftime(buffer, 25, format, &imestr); The opposite operation from strftime(). Parse the string st, according to the format given, and fill in the fields of timestr. Return a pointer to the first character in st that has not been converted. st = strptime( st1, "%H:%M:%S", &timestr); A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

23 Time Functions Hi-res Time Functions useconds_t ualarm( useconds_t, useconds_t ); A simplified interface to setitimer The first argument is the total lifetime of this timer. The second argument is the frequency at which the alarm should ring. int usleep( useconds_t usecs ); suspend thread execution for usecs microseconds int nanosleep( const struct timespec *rqtp, struct timespec *rmtp); suspend thread execution for rqtp nanoseconds The interval may be slightly longer, but will be as close as the system hardware can measure the interval. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

24 Time Functions Adding and Subtracting Hi-Res Times The C libraries do not contain functions for adding and subtracting hi-res times. The code for working on microsecond-times is given at this website: libc Elapsed time This code can be easily modified to work on nanosecond-times. Basically, an addition or subtraction is done on the microsecond member of the timeval, and if that overflows, a carry is added to the member representing seconds. A. Fischer CSCI 4547/6647[1ex]What is Time? Systems Programming Lecture /24 November 6, / 24

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX A. Fischer CSCI 4547 / 6647 November 1, 2013 A. Fischer CSCI 4547 / 6647 () Systems Programming Lecture 8... 1/41 November 1, 2013 1 / 41 Outline 1 Signals for Threads Signals

More information

Overview of Time Related Data Structures and Functions in Unix/C. It s About Time

Overview of Time Related Data Structures and Functions in Unix/C. It s About Time Overview of Time Related Data Structures and Functions in Unix/C It s About Time 1. time_t Same as an unsigned long. Time in seconds since Midnight GMT Jan 1, 1970. a. char * ctime(time_t x) will return

More information

Examination C++ Programming

Examination C++ Programming LUND INSTITUTE OF TECHNOLOGY 1(8) Department of Computer Science Examination C++ Programming 2011 08 20, 8.00 13.00 Aid at the exam: one C++ book. The copies of the lecture slides are not allowed. You

More information

Timekeeping. 5February :09

Timekeeping. 5February :09 Timekeeping UNIX timekeeping is an untidy area, made more confusing by national and international laws and customs. Broadly, there are two kinds of functions: one group is concerned with getting and setting

More information

Interacting with Unix

Interacting with Unix Interacting with Unix Synopsis Getting the Process ID #include pid_t getpid(void); Example: #include #include int main(){ pid_t n = getpid(); printf("process id is %d\n",

More information

SYSTEM INFORMATION. UNIX Programming 2015 Fall by Euiseong Seo

SYSTEM INFORMATION. UNIX Programming 2015 Fall by Euiseong Seo SYSTEM INFORMATION UNIX Programming 2015 Fall by Euiseong Seo Host Information POSIX defines host information as follows OS name (Linux) OS release (3.13.0) OS version (#60-Ubuntu SMP Web Aug 13) Node

More information

Avoid Using POSIX time_t for Telling Time

Avoid Using POSIX time_t for Telling Time Avoid Using POSIX time_t for Telling Time John Sauter 2018-07-15 Abstract The POSIX data type time_t is defined in a way that leads to errors in application programs when it is used for telling time. Here

More information

Chapter 6. System Data Files and Information

Chapter 6. System Data Files and Information Chapter 6. System Data Files and Information System Programming http://www.cs.ccu.edu.tw/~pahsiung/courses/pd 熊博安國立中正大學資訊工程學系 pahsiung@cs.ccu.edu.tw Class: EA-104 (05)2720411 ext. 33119 Office: EA-512

More information

Preview. Review. System Data Files (Password File) System Data Files (Password File) System Data Files (Password File)

Preview. Review. System Data Files (Password File) System Data Files (Password File) System Data Files (Password File) Review Preview link(), unlink() System Call remove(), rename() System Call Symbolic Links Symbolic link to directory Symbolic link to a executable file symlink() System Call File Times utime() System Call

More information

Structs (1) In data processing, a collection of data that can be treated as a single unit is a record. The components of this collection (fields or

Structs (1) In data processing, a collection of data that can be treated as a single unit is a record. The components of this collection (fields or Structs (1) In data processing, a collection of data that can be treated as a single unit is a record. The components of this collection (fields or members or attributes) are uniquely named and have values.

More information

Outline. Computer programming. Usage of time and date functions. Date and Time: time.h. Date and Time: time.h. Time functions:

Outline. Computer programming. Usage of time and date functions. Date and Time: time.h. Date and Time: time.h. Time functions: Outline Computer programming "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr Working with time I/O redirection Variable length argument lists Command

More information

Computer programming. "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr

Computer programming. An expert is a man who has made all the mistakes which can be made, in a narrow field. Niels Bohr Computer programming "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr 1 Outline Working with time I/O redirection Variable length argument lists Command

More information

18-642: Time and Date

18-642: Time and Date 18-642: Time and Date 2/21/2018 Date and Time Anti-Patterns for Date and Time: Daylight savings time hard-coded Time kept without handling time problems Daylight savings time, time zones, mobility Internationalization

More information

CPSC 427a: Object-Oriented Programming

CPSC 427a: Object-Oriented Programming CPSC 427a: Object-Oriented Programming Michael J. Fischer (with thanks to Ewa Syta for help with the slides) Lecture 14 October 20, 2011 CPSC 427a, Lecture 14 1/22 More on Course Goals Demo: Stopwatch

More information

Time. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 37

Time. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 37 Time Computer Science and Engineering College of Engineering The Ohio State University Lecture 37 Interval vs Point Different questions: How long did it take to run 5k? When is our final exam? Answering

More information

Computer Engineering Department. Yarmouk University ABSTRAT

Computer Engineering Department. Yarmouk University ABSTRAT Computer Engineering Department Yarmouk University ABSTRAT Anwar Hamdan Al-assaf Abdel_ ellah noor Al-shabatat Khawla Ali Al-Zou bi 2002971019 2002971009 2002971039 Network synchronization using GPS satellite

More information

CITS2002 Systems Programming. Identifying related data. 1 next CITS2002 CITS2002 schedule. Let's consider the st project for CITS1002.

CITS2002 Systems Programming. Identifying related data. 1 next CITS2002 CITS2002 schedule. Let's consider the st project for CITS1002. 1 next CITS2002 CITS2002 schedule Identifying related data Let's consider the 2012 1st project for CITS1002. The goal of the project was to manage the statistics of AFL teams throughout the season, calculating

More information

CSE 158/258. Web Mining and Recommender Systems. Tools and techniques for data processing and visualization

CSE 158/258. Web Mining and Recommender Systems. Tools and techniques for data processing and visualization CSE 158/258 Web Mining and Recommender Systems Tools and techniques for data processing and visualization Some helpful ideas for Assignment 2... 1. How can we crawl our own datasets from the web? 2. How

More information

Basic Device Management

Basic Device Management This chapter contains the following sections: About, page 1 Licensing Requirements for, page 2 Default Settings for Basic Device Parameters, page 3 Changing the Device Hostname, page 3 Configuring the

More information

Time Handling in Programming Language

Time Handling in Programming Language CSE 237B Fall 2009 Time Handling in Programming Language Rajesh Gupta University of California, San Diego System Characteristics Complexity in function (and in size) Concurrent control of separate components

More information

Genesys Info Mart. date-time Section

Genesys Info Mart. date-time Section Genesys Info Mart date-time Section 11/27/2017 date-time Section date-time-max-days-ahead date-time-min-days-ahead date-time-start-year date-time-table-name date-time-tz first-day-of-week fiscal-year-start

More information

Algorithm Analysis CISC4080 CIS, Fordham Univ. Instructor: X. Zhang

Algorithm Analysis CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Algorithm Analysis CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Last class Review some algorithms learned in previous classes idea => pseudocode => implementation Correctness? Three sorting algorithms:

More information

19: I/O Devices: Clocks, Power Management

19: I/O Devices: Clocks, Power Management 19: I/O Devices: Clocks, Power Management Mark Handley Clock Hardware: A Programmable Clock Pulses Counter, decremented on each pulse Crystal Oscillator On zero, generate interrupt and reload from holding

More information

Programming Date and Time APIs

Programming Date and Time APIs System i Programming Date and Time APIs Version 6 Release 1 System i Programming Date and Time APIs Version 6 Release 1 Note Before using this information and the product it supports, read the information

More information

Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski

Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski Distributed Systems Clock Synchronization: Physical Clocks Paul Krzyzanowski pxk@cs.rutgers.edu Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution

More information

Lecture 21 Disk Devices and Timers

Lecture 21 Disk Devices and Timers CS 423 Operating Systems Design Lecture 21 Disk Devices and Timers Klara Nahrstedt Fall 2011 Based on slides by YY Zhou and Andrew S. Tanenbaum CS 423 - Fall 2011 Overview Administrative announcements

More information

Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers

Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers NAME SYNOPSIS Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep clock_gettime clock_getres clock_nanosleep clock

More information

F28HS Hardware-Software Interface: Systems Programming

F28HS Hardware-Software Interface: Systems Programming : Systems Programming Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 2 2017/18 0 No proprietary software has been used in producing these slides

More information

Programming Language B

Programming Language B Programming Language B Takako Nemoto (JAIST) 28 January Takako Nemoto (JAIST) 28 January 1 / 20 Today s quiz The following are program to print each member of the struct Student type object abe. Fix the

More information

tag 220 tan[f l] struct { int i; double d; } sa, sb; struct { int i; double d; } s1, s2;

tag 220 tan[f l] struct { int i; double d; } sa, sb; struct { int i; double d; } s1, s2; tag 220 T tag The identifier that may optionally follow the keyword struct, union, or enum in a structure, union, or enumerated type definition, respectively. The tag is used later to refer to that particular

More information

This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy,

This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy, Libffi This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy, distribute and/or modify this document under the

More information

Synchronization Part 1. REK s adaptation of Claypool s adaptation of Tanenbaum s Distributed Systems Chapter 5

Synchronization Part 1. REK s adaptation of Claypool s adaptation of Tanenbaum s Distributed Systems Chapter 5 Synchronization Part 1 REK s adaptation of Claypool s adaptation of Tanenbaum s Distributed Systems Chapter 5 1 Outline! Clock Synchronization! Clock Synchronization Algorithms! Logical Clocks! Election

More information

C Structures in Practice

C Structures in Practice CS 2060 Use of C Structures in Unix/Linux To further illustrate C structures, we will review some uses of struct in system calls. Here is a function from BSD to get the current time (found in sys/time.h):

More information

Any of the descriptors in the set {1, 4} have an exception condition pending

Any of the descriptors in the set {1, 4} have an exception condition pending Page 1 of 6 6.3 select Function This function allows the process to instruct the kernel to wait for any one of multiple events to occur and to wake up the process only when one or more of these events

More information

Real Time Operating Systems and Middleware

Real Time Operating Systems and Middleware Real Time Operating Systems and Middleware Real-Time Programming Interfaces Luca Abeni abeni@dit.unitn.it Real Time Operating Systems and Middleware p. 1 Needs for a Real-Time Interface Real-Time applications

More information

Processes. Processes (cont d)

Processes. Processes (cont d) Processes UNIX process creation image-file arg1 arg2 Shell command line example ls -l Equivalent to /bin/ls -l Why? How do you find out where the image file is? Background processes ls -l & Execute a process

More information

ETC II Modbus Communications Protocol Reference Guide

ETC II Modbus Communications Protocol Reference Guide ETC II Modbus Communications Protocol Reference Guide SATEC Ltd. BG0595 Rev. A1 Every effort has been made to ensure that the material herein is complete and accurate. However, the manufacturer is not

More information

Overview. POSIX signals. Generation of signals. Handling signals. Some predefined signals. Real-time Systems D0003E 3/3/2009

Overview. POSIX signals. Generation of signals. Handling signals. Some predefined signals. Real-time Systems D0003E 3/3/2009 Overview Real-time Systems D0003E Lecture 13: More on inter-process communication (Burns & Wellings ch. 8, 11 & 10.6) Posix signals Posix timers timers in cygwin (lab environment) event-loop pattern semaphores

More information

Timing Measurement (Linux) Introduction Timekeeping Architecture Related System Calls

Timing Measurement (Linux) Introduction Timekeeping Architecture Related System Calls Lecture 3 - Timer Timing Measurement (Linux) Introduction Timekeeping Architecture Related System Calls Case study - S3C2410 Timer Block Diagram Timer Operations Registers 1 Introduction Within a system,

More information

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 ... 1/16 CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 Alice E. Fischer February 3, 2016 ... 2/16 Outline Basic Types and Diagrams ... 3/16 Basic Types and Diagrams Types in C C has

More information

Timers 1 / 46. Jiffies. Potent and Evil Magic

Timers 1 / 46. Jiffies. Potent and Evil Magic Timers 1 / 46 Jiffies Each timer tick, a variable called jiffies is incremented It is thus (roughly) the number of HZ since system boot A 32-bit counter incremented at 1000 Hz wraps around in about 50

More information

Pointer Arithmetic and Lexical Scoping. CS449 Spring 2016

Pointer Arithmetic and Lexical Scoping. CS449 Spring 2016 Pointer Arithmetic and Lexical Scoping CS449 Spring 2016 Review Pitfall 1 from previous lecture void foo(char *s) { s = "World"; int main() { char *str = "Hello"; foo(str); printf("%s\n", str); return

More information

Linked lists, stacks, queues

Linked lists, stacks, queues Linked lists, stacks, queues Data and File Structures Laboratory Data and File Structures Laboratory Linked lists, stacks, queues 1 / 9 Preliminaries: measuring time Motivation: to measure the amount of

More information

Manual Configuration of Time Settings of SG200, SG300, and SG500 Series Switches

Manual Configuration of Time Settings of SG200, SG300, and SG500 Series Switches Manual Configuration of Time Settings of SG200, SG300, and SG500 Series Switches Objective System time can be set manually by the user, dynamically from an SNTP Unicast/ Multicast/Anycast server, or synchronized

More information

Lecture 6: Real-Time Timing + Real-Time Objects

Lecture 6: Real-Time Timing + Real-Time Objects Lecture 6: Real-Time Timing + Real-Time Objects 1 Lecture: RT Timing (30) Lab Exercise: Watchdog + auxiliary clock timers (25) Lecture: RT Objects-Events (15) Lab Exercise: Events (30) Project Work (rest

More information

When.py Documentation

When.py Documentation When.py Documentation Release 0.4.0 Andy Dirnberger February 27, 2016 Contents 1 Usage 3 2 A note about future and past 9 3 Indices and tables 11 Python Module Index 13 i ii When.py provides user-friendly

More information

A read or write being atomic means that its effect is as if it happens instantaneously.

A read or write being atomic means that its effect is as if it happens instantaneously. A read or write being atomic means that its effect is as if it happens instantaneously. Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There

More information

Odds and Ends. Data and File Structures Laboratory. DFS Lab (ISI) Odds and Ends 1 / 8

Odds and Ends. Data and File Structures Laboratory.   DFS Lab (ISI) Odds and Ends 1 / 8 Odds and Ends Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2017/index.html DFS Lab (ISI) Odds and Ends 1 / 8 Topics 1. Generic functions (e.g., swap) 2. Function activation records;

More information

Common Configuration Options

Common Configuration Options Common Configuration Options Unless otherwise noted, the common configuration options that this chapter describes are common to all Genesys server applications and applicable to any Framework server component.

More information

Programming RT systems with pthreads

Programming RT systems with pthreads Programming RT systems with pthreads Giuseppe Lipari http://feanor.sssup.it/~lipari Scuola Superiore Sant Anna Pisa December 1, 2011 Outline 1 Timing utilities 2 Periodic threads 3 Scheduler selection

More information

Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such

Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such events, to which we sometimes refer as exceptions and interrupts.

More information

EE109 Lab Need for Speed

EE109 Lab Need for Speed EE109 Lab Need for Speed 1 Introduction In this lab you will parallelize two pieces of code. The first is an image processing program to blur (smooth) or sharpen an image. We will guide you through this

More information

QPM Ethernet Protocol

QPM Ethernet Protocol QPM Ethernet Protocol 2002 The Stanley Works, All Rights Reserved Page 1 of 16 General For this document, the term Sigma refers to all Stanley QPM Sigma based systems including the Gamma controller. The

More information

A process. the stack

A process. the stack A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes

More information

Distributed Systems COMP 212. Lecture 17 Othon Michail

Distributed Systems COMP 212. Lecture 17 Othon Michail Distributed Systems COMP 212 Lecture 17 Othon Michail Synchronisation 2/29 What Can Go Wrong Updating a replicated database: Customer (update 1) adds 100 to an account, bank employee (update 2) adds 1%

More information

Program Execution Time Measurements

Program Execution Time Measurements / Notes on Program Execution Time Measurements on Linux/Unix/Solaris Intended audience: Those who would like to learn more about measuring program execution time in modern computer systems. Used: CPE 631

More information

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management Last class: OS and Architecture OS and Computer Architecture OS Service Protection Interrupts System Calls IO Scheduling Synchronization Virtual Memory Hardware Support Kernel/User Mode Protected Instructions

More information

ChorusOS man pages section 3STDC: Standard C Library Functions. Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA U.S.A.

ChorusOS man pages section 3STDC: Standard C Library Functions. Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA U.S.A. ChorusOS man pages section 3STDC: Standard C Library Functions Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, CA 94303-4900 U.S.A. Part No: 806-3335 December 10, 1999 Copyright 1999 Sun Microsystems,

More information

Atomic Time Manager 400 Product Documentation

Atomic Time Manager 400 Product Documentation Atomic Time Manager 400 Product Documentation Version 1.2.3 March 24, 2004 Copyright 2003-2004, Client Server Development, Inc. and Davis Software Services, Inc. All Rights Reserved 1. Introduction...4

More information

CSCI 6610: Review. Chapter 7: Numbers Chapter 8: Characters Chapter 11 Pointers

CSCI 6610: Review. Chapter 7: Numbers Chapter 8: Characters Chapter 11 Pointers ... 1/27 CSCI 6610: Review Chapter 7: Numbers Chapter 8: Characters Chapter 11 Pointers Alice E. Fischer February 1, 2016 ... 2/27 Outline The Trouble with Numbers The char Data Types Pointers ... 3/27

More information

LECTURE 9 The Standard Library Part 3

LECTURE 9 The Standard Library Part 3 LECTURE 9 The Standard Library Part 3 THE STANDARD LIBRARY In this lecture, we will briefly cover each of the remaining Standard Library modules that you absolutely must know about. Some of the remaining

More information

CSE 421: Introduction to Operating Systems

CSE 421: Introduction to Operating Systems Recitation 5: UNIX Signals University at Buffalo, the State University of New York October 2, 2013 About Me 4th year PhD student But TA first time From South Korea Today, We will study... What UNIX signals

More information

What is concurrency? Concurrency. What is parallelism? concurrency vs parallelism. Concurrency: (the illusion of) happening at the same time.

What is concurrency? Concurrency. What is parallelism? concurrency vs parallelism. Concurrency: (the illusion of) happening at the same time. What is concurrency? Concurrency Johan Montelius KTH 2017 Concurrency: (the illusion of) happening at the same time. A property of the programing model. Why would we want to do things concurrently? What

More information

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics.

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics. Question 1. (10 points) (Caches) Suppose we have a memory and a direct-mapped cache with the following characteristics. Memory is byte addressable Memory addresses are 16 bits (i.e., the total memory size

More information

Synchronization of Network Devices Time by GPS Based Network Time Protocol Output

Synchronization of Network Devices Time by GPS Based Network Time Protocol Output Synchronization of Network Devices Time by GPS Based Network Time Protocol Output Ajay Rajput Department of Electronics & Communication Engineering Lord Krishna College of Technology, Indore, Madhya Pradesh,

More information

Call DLL from Limnor Applications

Call DLL from Limnor Applications Call DLL from Limnor Applications There is a lot of computer software in the format of dynamic link libraries (DLL). DLLCaller performer allows your applications to call DLL functions directly. Here we

More information

Concurrency. Johan Montelius KTH

Concurrency. Johan Montelius KTH Concurrency Johan Montelius KTH 2017 1 / 32 What is concurrency? 2 / 32 What is concurrency? Concurrency: (the illusion of) happening at the same time. 2 / 32 What is concurrency? Concurrency: (the illusion

More information

Market Data Platform Real Time. SNAPSHOT DATA Currency Derivatives Market

Market Data Platform Real Time. SNAPSHOT DATA Currency Derivatives Market TECHNICAL DOCUMENT Market Data Platform Real Time SNAPSHOT DATA Currency Derivatives Market (STANDARD PRODUCT) Version 1.2 22 FEB 2018 DOTEX INTERNATIONAL LIMITED EXCHANGE PLAZA, PLOT NO. C/1, G BLOCK,

More information

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals EECS 3221 Operating System Fundamentals Instructor: Prof. Hui Jiang Email: hj@cse.yorku.ca Web: http://www.eecs.yorku.ca/course/3221 General Info 3 lecture hours each week 2 assignments (2*5%=10%) 1 project

More information

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals General Info EECS 3221 Operating System Fundamentals Instructor: Prof. Hui Jiang Email: hj@cse.yorku.ca Web: http://www.eecs.yorku.ca/course/3221 3 lecture hours each week 2 assignments (2*5%=10%) 1 project

More information

Processes. Johan Montelius KTH

Processes. Johan Montelius KTH Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other

More information

Programming 2. Object Oriented Programming. Daniel POP

Programming 2. Object Oriented Programming. Daniel POP Programming 2 Object Oriented Programming Daniel POP Week 4 Agenda 1. Self-reference 2. Modifiers: static 3. Modifiers: const 4. Modifiers: mutable 5. Modifiers: friend Wrap-up last week Constructors Definition:

More information

A USER S GUIDE TO THE NPL TELEPHONE TIME SERVICE

A USER S GUIDE TO THE NPL TELEPHONE TIME SERVICE A USER S GUIDE TO THE NPL TELEPHONE TIME SERVICE Contents 1. NPL s Computer Time Services 2. How to use the NPL Telephone Time Service 3. Additional information about the service 4. Contacting NPL Appendix

More information

20-EECE-4029 Operating Systems Fall, 2015 John Franco

20-EECE-4029 Operating Systems Fall, 2015 John Franco 20-EECE-4029 Operating Systems Fall, 2015 John Franco Final Exam name: Question 1: Processes and Threads (12.5) long count = 0, result = 0; pthread_mutex_t mutex; pthread_cond_t cond; void *P1(void *t)

More information

Internet Engineering Task Force (IETF) Category: Standards Track ISSN: March 2014

Internet Engineering Task Force (IETF) Category: Standards Track ISSN: March 2014 Internet Engineering Task Force (IETF) K. Gross Request for Comments: 7164 AVA Networks Updates: 3550 R. van Brandenburg Category: Standards Track TNO ISSN: 2070-1721 March 2014 Abstract RTP and Leap Seconds

More information

Software Design Abstract Data Types

Software Design Abstract Data Types Software Design Abstract Data Types 1 Software Design top down, bottom up, object-oriented abstract data types 2 Specifying a ClassClock date and time in a C++ program encapsulating C code public and private

More information

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. OS and Computer Architecture Last class: OS and Architecture OS and Computer Architecture OS Service Protection Interrupts System Calls IO Scheduling Synchronization Virtual Memory Hardware Support Kernel/User Mode Protected Instructions

More information

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components Last class: OS and Architecture Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation

More information

Main Memory. ICS332 Operating Systems

Main Memory. ICS332 Operating Systems Main Memory ICS332 Operating Systems Main Memory The OS must manage main memory because it manages processes that share main memory Main memory: A large array of bytes (words), each with its own address

More information

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 4, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts

More information

Operating-System Structures

Operating-System Structures Operating-System Structures System Components Operating System Services System Calls System Programs System Structure System Design and Implementation System Generation 1 Common System Components Process

More information

A USER'S GUIDE TO THE NPL TELEPHONE TIME SERVICE

A USER'S GUIDE TO THE NPL TELEPHONE TIME SERVICE A USER'S GUIDE TO THE NPL TELEPHONE TIME SERVICE Contents 1. NPL's Computer Time Services 2. How to use the NPL Telephone Time Service 3. Additional information about the service 4. Contacting NPL Appendix

More information

Process Synchronization(2)

Process Synchronization(2) CSE 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Computer Science and Engineering York University Semaphores Problems with the software solutions. Not easy

More information

Time Synchronization and Logical Clocks

Time Synchronization and Logical Clocks Time Synchronization and Logical Clocks CS 240: Computing Systems and Concurrency Lecture 5 Mootaz Elnozahy Today 1. The need for time synchronization 2. Wall clock time synchronization 3. Logical Time

More information

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating Systems Concepts with Java, by Silberschatz, Galvin, and Gagne (2007). Many, if not

More information

Performance Measuring on Blue Horizon and Sun HPC Systems:

Performance Measuring on Blue Horizon and Sun HPC Systems: Performance Measuring on Blue Horizon and Sun HPC Systems: Timing, Profiling, and Reading Assembly Language NPACI Parallel Computing Institute 2000 Sean Peisert peisert@sdsc.edu Performance Programming

More information

Managing System of Standalone EAP

Managing System of Standalone EAP Managing System of Standalone EAP CHAPTERS 1. Configure the User Account 2. Configure the System Time 3. Reboot and Reset the EAP 4. Backup and Restore the Configuration 5. Update the Firmware This guide

More information

Chapter 3: Operating-System Structures

Chapter 3: Operating-System Structures Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1

More information

Process Synchronization(2)

Process Synchronization(2) EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.

More information

Process Synchronization(2)

Process Synchronization(2) EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.

More information

Time in Distributed Systems

Time in Distributed Systems in Distributed Systems There is no common universal time (Einstein) but the speed of light is constant for all observers irrespective of their velocity event e2 at earth time t2 ---- large distances ----

More information

Εργαστήριο 9 I/O Multiplexing

Εργαστήριο 9 I/O Multiplexing Εργαστήριο 9 I/O Multiplexing Στοεργαστήριοθαμελετηθούν: Server High Level View I/O Multiplexing Solutions for Concurrency nonblocking I/O Use alarm and signal handler to interrupt slow system calls. Use

More information

Module 3: Operating-System Structures. Common System Components

Module 3: Operating-System Structures. Common System Components Module 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1 Common

More information

Homework 2 COP The total number of paths required to reach the global state is 20 edges.

Homework 2 COP The total number of paths required to reach the global state is 20 edges. Homework 2 COP 5611 Problem 1: 1.a Global state lattice 1. The total number of paths required to reach the global state is 20 edges. 2. In the global lattice each and every edge (downwards) leads to a

More information

In this lesson you will learn: how to add and multiply positive binary integers how to work with signed binary numbers using two s complement how fixed and floating point numbers are used to represent

More information

Mon Sep 17, 2007 Lecture 3: Process Management

Mon Sep 17, 2007 Lecture 3: Process Management Mon Sep 17, 2007 Lecture 3: Process Management September 19, 2007 1 Review OS mediates between hardware and user software QUIZ: Q: Name three layers of a computer system where the OS is one of these layers.

More information

Input/Output Systems

Input/Output Systems Input/Output Systems CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those from an earlier edition of the course text Operating

More information

F28HS Hardware-Software Interface: Systems Programming

F28HS Hardware-Software Interface: Systems Programming F28HS Hardware-Software Interface: Systems Programming Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 2 2016/17 0 No proprietary software has

More information

Arrays. What if you have a 1000 line file? Arrays

Arrays. What if you have a 1000 line file? Arrays Arrays Chapter 8 page 477 11/8/06 CS150 Introduction to Computer Science 1 1 What if you have a 1000 line file? Read in the following file and print out a population graph as shown below. The maximum value

More information

Programming Assignment 2 (PA2) - Binary Clock

Programming Assignment 2 (PA2) - Binary Clock Programming Assignment 2 (PA2) - Binary Clock Milestone Due: Final Due: Wednesday, May 2 @ 11:59 pm Wednesday, May 9 @ 11:59 pm Example Input Milestone Functions Unit Testing Extra Credit Detailed Overview

More information