1 Time In Systems Ashok K. Agrawala Department of Computer Science University of Maryland College park, MD 20742 agrawala@cs.umd.edu 6/27/2016 University of Maryland, College Park 2 View of a System • Collection of active entities (agents) – Active Entity » State » Communication • Exchange information with – other entities – environment -- non-specific entities » Actions • Actuators • Means for interaction • Hierarchical Views – Aggregation – Refinement • Observability – States/actions/messages visible • System Dynamics – Changes over time 6/27/2016 University of Maryland, College Park 3 Real Time and Virtual Time • Real Time – Monotonic – Universal – Uncontrolled variable • Virtual Time – Attached to an activity – Progresses only when the activity makes a progress » Gets mapped to real time • Coordination among activities – Defined with respect to the virtual time – Carried out in real time 6/27/2016 University of Maryland, College Park 4 Virtual time for a process • Virtual Single-Process Machine Abstraction • The time seen by the process in this abstraction is the Virtual Time • Process – Sequence of steps » Assign time for each step • May be assigned as a function - depending on the processor speed etc. » Assign Virtual Time to the process – When can the assignment be done? » Fixed execution sequence » Data dependent execution sequence 6/27/2016 University of Maryland, College Park 5 Example - Video Tape Video tape – Sequence of frames {n} – Each frame has to be displayed at a fixed time relative to the start of the tape – When we hit start » assign the real time of start instant to the virtual time for the first frame of the tape » Subsequent frames are assigned real time linearly – Pause » Real time progresses while virtual time has stopped – Fast Forward » Virtual Time runs faster than real time – Rewind » Real Time moves forward, virtual time moves backwards 6/27/2016 University of Maryland, College Park 6 Pause Play Pause Play Virtual Time of Process i Real Time 6/27/2016 University of Maryland, College Park 7 Fast Forward of Virtual Time Play Fast Forward Play Virtual Time of Process i Real Time 6/27/2016 University of Maryland, College Park 8 Rewind of Virtual Time of Process j Process j virtual time Rewind Undo code operation Real Time 6/27/2016 University of Maryland, College Park 9 Multi- Process Environment • Single processor shared among several processes • The virtual time of a process only makes progress when CPU is assigned to it • The Resource Manager (operating System) has to be treated as another process which takes resources/time 6/27/2016 University of Maryland, College Park 10 Mapping of Virtual Time Process 1 virtual time Process 2 virtual time Process 3 virtual time Real Time 6/27/2016 University of Maryland, College Park 11 Synchronization • Process synchronization requirements are usually specified with respect to the virtual time • They have to be carried out in real time • Synchronization mechanisms – Coordinate the mapping of multiple processes virtual time to a common real time with the scheduling constraints 6/27/2016 University of Maryland, College Park 12 Synchronization of Multiple processes Process 1 virtual time Process 2 virtual time Process 3 virtual time Real Time 6/27/2016 University of Maryland, College Park 13 Virtual Time in Virtual Worlds • In Virtual Worlds we control all activities explicitly • With explicit understanding of virtual time we can more effectively manage/control/understand the interactions 6/27/2016 University of Maryland, College Park 14 View of Processing • Collection of Requests • Request – A collection of activities – Defined constraints » Static » Dynamic • To meet the processing requirements the requests must be processed meeting all the constraints 6/27/2016 University of Maryland, College Park 15 Designing a System • Decomposition – – – – Modular Design Functionality Resources Interfaces • Aggregation – Coordination – Composition » Functionality » Behavior • Performance • Timing • Interfaces – Functional -- Temporal Role of time in system design University of Maryland, College Park 6/27/2016 16 Absolute Time • • • • • Continuous, real number Universal Notion of Present, Past and Future Spatial locality Absolute Time at different spatial localities – Related » In quantifiable way – Relativity Theory 6/27/2016 University of Maryland, College Park 17 Physical Time/Local Time • As used in a physical system • Related to Absolute Time through CLOCK – Physical Device Abs Time » defined local time Clock » observable Local Time – Granularity - Tick Time - Finite – Accuracy is finite – In a Good clock » Relationship with Absolute Time is an invariant 6/27/2016 University of Maryland, College Park 18 Knowledge of Time • Only way of knowing Local Time is by reading the clock • Read the clock – Takes time to read the clock » If fixed, can factor it » If variable, limits the accuracy about the knowledge of time – Local Time • Only know that the local time is > time read from the clock • If we know the properties of the clock, can relate the time read to Absolute Time 6/27/2016 University of Maryland, College Park 19 Notion of Time in Systems • Local Time – When a system is distributed there may be multiple local times in a system • Time Horizon – Ignore before and after • Time scale – Granularity – Simultaneity 0 Past Horizon Future Horizon 6/27/2016 University of Maryland, College Park 20 Local Time • • • • Specified by a clock Granularity > granularity of clock Accuracy of representation Accuracy of observation – Depends on the variability of reading latency 6/27/2016 University of Maryland, College Park 21 Time Granularity Granularity • Human notions of time – non-uniformity of time scale • Machine notions of time – Uniform time scale – Models of dynamics » Differential Equation Models – Uniform notion of time – Granularity » greater than the granularity of the clock used Time • Should we use the non-uniform time granularities in systems? – Used to some degree today 6/27/2016 University of Maryland, College Park 22 Fusion • All interactions requires temporal coordination as well as spatial coordination – Interactions are physical exchange of information/signals • The control of interactions is through the use of local time but takes place in absolute time • Fusion of local time is required – Commonality of units, scale, origin, etc. 6/27/2016 University of Maryland, College Park 23 Fusion • When two active entities have to interact – Must have common notion of local time » From the knowledge of TA, A should be able to infer TB with reasonable accuracy » Use • Common clock • Synchronized clock • Execute special protocol for coordination 6/27/2016 University of Maryland, College Park 24 Buffers • Entities which can hold a signal for some time – Fixed time – When cleared • Buffers are the primary means of providing one directional temporal matching – A places information in the buffer » B can pick it up any time after that • Use of buffers increases latencies and delays 6/27/2016 University of Maryland, College Park 25 Temporal Locality: Simultaneity • What A and B consider to be simultaneous • May be within the granularity of their clocks • Simultaneity should carry with it the time scale/granularity 6/27/2016 University of Maryland, College Park 26 Distributed System • Has multiple localities • Each locality has a local time • Distributed system must maintain time fusion for all localities (temporal consistency) • Inaccuracies in time fusion – Longer delays - lower throughputs – Larger buffers – etc. 6/27/2016 University of Maryland, College Park 27 Coordination • Activities of multiple autonomous units have to be coordinated – WHY???? • A key to all systems • Coordination of – Two – More than two 6/27/2016 University of Maryland, College Park 28 Modes of Coordination • Event based – A causes an event E which is visible to B • Time based – Agree to carry out a coordinated action at prearranged time 6/27/2016 University of Maryland, College Park 29 Event Based Coordination • Event visible to A and B – Example - signal sent by A to B • Signal takes time to propagate from A to B • B must be monitoring the signal for it to see – A can not make B to do anything unless B is listening – If B starts monitoring after A sends the signal, it is lost – And B must have some temporal coordination before they get in the event based coordination mode 6/27/2016 University of Maryland, College Park 30 Event Based Coordination • Most monitoring is done in a loop with finite latency – There are delays of transfer of signal and the latency of monitoring cycle • Handshake protocols may confirm to A that B saw the signal – Cause additional latency • Most software systems used Event based coordination • Buffers may be used to account for delayed detection of signal (temporal Matching) Temporal variability may continue to increase when multiple step coordination is required 6/27/2016 University of Maryland, College Park 31 Time Based Coordination • A and B must have a common notion of local time – Time Fusion – Knowledge of drift and drift correction • Must prearrange the time, TAB, for coordinated action – Arrangement must be completed before TAB » It may be dynamic • Most hardware systems use time based coordination – Clock Based synchronous circuits • Buffers may be used for temporal matching 6/27/2016 University of Maryland, College Park 32 Coordination • With the same clock resolution – Time based coordination can be » temporally more accurate » require less overhead of messages and signals than event based coordination 6/27/2016 University of Maryland, College Park 33 Coordination among Multiple Agents • The complexity of Event based schemes increases as the number of agents increases – Communication medium » Point to Point • Many messages- sequential or in parallel » Broadcast • Complexity of Time based schemes remains the same 6/27/2016 University of Maryland, College Park 34 What takes time • Agent uses ITS resources to carry out an activity • Use of resources takes time 6/27/2016 University of Maryland, College Park 35 Coherence of a System • Coherence – The way interaction/coordination is managed in time • Completely Coherent – All interactions take place at precisely known times • Incoherent – All interactions are event driven with no notions of time mentioned explicitly • Controlled Coherence – Time variability of interactions is within defined/know bounds 6/27/2016 University of Maryland, College Park 36 Coherent Systems • Time Based Coordination • Accurate Clock • Knowledge of global time – Implicit – explicit • Resource Implications – Need clock interrupt for any impending action • Brittle • Rigid/Inflexible 6/27/2016 University of Maryland, College Park 37 Incoherent Systems • Event Driven Coordination • No explicit knowledge of time • Significant variability in temporal performance • Overhead – Buffer space for holding messages – Detection of message arrival » interrupt » Polling 6/27/2016 University of Maryland, College Park 38 Controlled Coherence The temporal variability for any interaction is controlled in that the variability does not propagate • Bounded interval for performing all interactions • Knowledge of time – Local with bounded/known variability from global time • Use knowledge of resource/time requirements and their bounds to coordinate • May use time based or event based coordination mechanisms 6/27/2016 University of Maryland, College Park 39 Resource Requirements • For every task » Arrival » Processing » Departure – Resources Required – Processing Time » Bounds on variabilities { ta , tb} – Coordination Requirements • For every Task – Define a time before which departure is not permitted • Consequence is that the variability of the departure time is bounded – Trading variability for latency 6/27/2016 University of Maryland, College Park 40 Variability Control • Departure Time d • Arrival Time a • Processing time S da a ds s d 6/27/2016 University of Maryland, College Park 41 Example : Cyclone Network temporal regulator cyclonode Non cyclone network University of Maryland, College Park Non cyclone network 6/27/2016 42 Approach • Space-time management of all resources • Periodic operation with fixed period length for the network • Fixed chunk size for the network • Slot – Time and space description of a chunk at a location at a time instant 6/27/2016 University of Maryland, College Park 43 Link Model • • • • Point to point link Same slot id for both ends Timing determined by sending side Slots managed as circular buffer 6/27/2016 University of Maryland, College Park 44 Cyclonode controller • Synchronized local clock • Calendar based switching operation • Controller operation – Clock synchronization – Control message processing – Calendar management 6/27/2016 University of Maryland, College Park 45 Cyclonode incoming link 1 incoming link m next free slot pointer switch controller outgoing link 1 outgoing link n slot buffer pointer buffer free slot list marker checker 6/27/2016 University of Maryland, College Park 46 Temporal Regulator • Special cyclonode interfaces hosts • Buffers absorb host timing variability • Supports multiple traffic types 6/27/2016 University of Maryland, College Park 47 Temporal Regulator host nfsp incoming link 1 outgoing link 1 nfsp incoming link m nfsp nfsp controller outgoing link n free slot slot buffer pointer buffer free slot list marker checker nfsp next free slot pointer 6/27/2016 University of Maryland, College Park 48 Concluding Remarks • Controlled Coherence provides an approach to designing complex systems with known,bounded temporal variability • Scalability - support for modular design • Efficient mechanisms can be designed • Flexibility increased • Brittleness reduced • Local Synchronized Clocks are sufficient 6/27/2016 University of Maryland, College Park