Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mobile Systems Richard Yang.

Similar presentations


Presentation on theme: "Mobile Systems Richard Yang."— Presentation transcript:

1 Mobile Systems Richard Yang

2 Admin. Homework 4 due Friday Dec. 8th

3 Recap: J2ME and Windows CE/Mobile
Scale down a popular programming environment to ease learning Use virtual machines to mask (some) device heterogeneity Use versioning to avoid using lowest common denominator

4 TinyOS

5 Hardware Assembled from off-the-shelf components
4Mhz, 8bit MCU (ATMEL) 512 bytes RAM, 8KB ROM Devices 900Mhz Radio (RF monolithics) ft. range temperature sensor & light sensor LED outputs serial Port 1.5” x 1.5”

6 Schematic Diagram of a Mote

7 Sample Applications Active-badge-like location detection
Sensor network monitoring periodically transmit node measurements to a base station forward data for other nodes that are out of range of the base station dynamically determine the correct routing topology for the network

8 Requirements Small foot print
devices have limited memory and power resources Easy integration of hardware and software components think of a software component as a synthetic hardware components simulating the behavior of advanced hardware Many other requirements, e.g., robust operation should be reliable, and assist applications in surviving individual device failures

9 Example Application A simple TinyOS application which periodically reads in the light intensity value, computes a moving average, displays it on the LED How would you develop the system?

10 TinyOS: Components A tinyOS consists of one or more components linked together software components motivated by hardware component Each component specifies that it provides some interfaces allows other components to control it also uses some interfaces control other components

11 A uses interfaces I1 and I2
An interface declares a set of functions called commands that provider must implement and another set of functions called events that the interface user must implement A uses interfaces I1 and I2 I1 I2 commands events commands events B provides I1 C provides I2 C provides I3

12 Interface: Examples Timer.nc ADC.nc
StdControl.nc interface StdControl {   command result_t init();   command result_t start();   command result_t stop(); } Timer.nc interface Timer { command result_t start( char type, uint32_t interval);   command result_t stop();   event result_t fired(); } ADC.nc interface ADC { async command result_t getdata();   async command result_t getContinuousData();   event result_t dataReady(uint 16_t data); }

13 Linking Components Two types of components:
modules: individual components configurations : assemble components together, connecting interfaces (objects) used by components to interfaces (objects) provided by others

14 Example Application A simple TinyOS application which periodically reads in the light intensity value, computes a moving average, displays it on the LED See SenseTaskM.nc SenseTask.nc

15 TinyOS Component: Implementation
Component contains: commands and event handlers can invoke lower level commands, but cannot block event handler can signal higher level signals while command cannot frame (storage) statically allocated, fixed sized to know memory requirement and avoid overhead of dynamic allocation Component Internal Tasks Internal State Commands Events

16 TinyOS Execution Model
Concurrency model: only two threads long running tasks that can be interrupted by hardware event handlers Tasks perform the primary computation work commands and event handlers post tasks call lower level commands signal higher level events schedule other tasks within a component Each task is atomic with respect to other tasks run to completion, but can be preempted by events the task scheduler is a simple FIFO scheduler

17 Running tinyOS Program
make mica ncc -o main.exe -target=mica SenseTask.nc avr-objcopy --output-target=srec main.exe main.srec Use uisp to install

18 A More Complete Sample Application
Sensor network monitoring monitor temperature and light conditions periodically transmit measurements to a base station sensors can forward data for other sensors that are out of range of the base station dynamically determine the correct routing topology for the network

19 Internal Component Graph
RFM Radio byte Radio Packet UART UART Packet I2C Temp Light Active Messages Clocks bit byte packet Ad hoc Routing Application application HW SW Hardware abstraction components, like the RFM radio component, map physical hardware into our component model. They translate hardware interrupts into events, and export commands to manipulate the individual I/O pins of the hardware. Synthetic hardware components simulate the behavior of advanced hardware. For example, the Radio Byte component shifts data into or out of the underlying RFM module, and signals when an entire byte has completed. High level software components perform control, routing, and all data transformations.

20 Message Send Transition
Total propagation delay up the 5 layer radio communication stack is about 80 instructions Timing diagram of event propagation

21 Evaluation: Storage Scheduler only occupies 178 bytes
Component Name Code Size (bytes) Data Size (bytes) Routing AM_dispatch AM_temperature AM_light AM RADIO_packet RADIO_byte RFM Light Temp UART UART_packet I2C 88 40 78 146 356 334 810 310 84 64 196 314 198 32 8 1 Processor_init TinyOS scheduler C runtime 172 178 82 30 16 Total 3450 226 Scheduler only occupies 178 bytes Complete application only requires 3 KB of instruction memory and 226 bytes of data (less than 50% of the 512 bytes available) Only processor_init, TinyOS scheduler, and C runtime are required

22 Evaluation: Timing Operations Cost (cycles) Time (µs)
Normalized to byte copy Byte copy 8 2 1 Post an Event Call a Command Post a task to scheduler Context switch overhead 10 46 51 2.5 11.5 12.75 1.25 6 Interrupt (hardware cost) 9 2.25 Interrupt (software cost) 71 17.75

23 Mobile CPU Scheduling

24 Discussion What does CPU scheduling do in a traditional operating system? What (new) problems does CPU scheduling face in mobile computing?

25 CPU Power Consumption A major challenge of mobile CPU scheduling is to reduce power consumption CPU consumes 10%-30% of notebook power The power consumption rate P of a CMOS processor satisfies where k is a constant, C the capacitance of the circuit, f the CPU frequency, and V the voltage

26 CPU Power Consumption When the supply voltage is lower, charging/discharging time is longer; thus frequency should be lower Thus power consumption ~ O(V3) What does it imply?

27 Dynamic Voltage Scaling
Dynamic Voltage Scaling (DVS) allows voltage to be dynamically adjusted to save power DVS-enabled processors, e.g., AMD (PowerNow!) Intel (SpeedStep, XScale) Texas Instrument Transmata Discussion: what voltage to operate on? throughput

28 Dynamic Voltage Scaling
Basic idea: determining voltage according to program response time requirement For normal applications, give reasonable response time For multimedia applications, use the deadline to determine voltage

29 multimedia applications
Architecture multimedia applications monitoring requirements scheduling scheduler demand distribution profiler time constraint speed adaptor speed scaling CPU

30 Demand Prediction Online profiling and estimation: count number of cycles used by each job 1 CDF F(x) = P [X  x] cumulative probability Cmin=b0 b1 b2 br-1 br=Cmax

31 Demand distribution is stable or changes slowly
Observations Demand distribution is stable or changes slowly

32 CPU Resource Allocation
How many cycles to allocate to a multimedia job? Application should meet  percent of deadlines  each job meets deadline with probability   allocate C cycles, such that F (C ) =P [X  C ]   b1 b2 b0 br 1 br-1 cumulative probability F(x) C

33 How Fast to Run the CPU? Assume the strategy is to run job i at a fix (also called uniform) speed Si Assume it needs Ci cycles during a time duration of Pi Fact: since power is a convex function of frequency, if a job needs C cycles in a period P, then the optimal frequency is C/P, namely the lowest constant frequency.

34 Why Not Uniform Speed? Intuitively, uniform speed achieves
- minimum energy if use the allocated exactly However, jobs use cycles statistically - often complete before using up the allocated - potential to save more energy  stochastic DVS

35 Stochastic DVS For each job such that
find speed Sx for each allocated cycle x time is 1/Sx and energy is (1 - F(x))S3x such that

36 Observation: speed up the processor with increasing clock cycles
Example Speed Schedule cycle: speed: 100 MHz 200 MHz 400 MHz Job 1 2.5x106 cycles speed (MHz) 100 400 200 Job 2 1.2x106 cycles Observation: speed up the processor with increasing clock cycles

37 DVS A1 B1 A1 A1 A2 context switch Store speed for switched-out
New speed for switched-in speed up within job switch back A1 B1 A1 speed A1 A2 execution

38 Extension to Linux kernel 2.4.18
Implementation Hardware: HP N5470 laptop Athlon CPU (300, 500, 600, 700, 800, 1000MHz) round speed schedule to upper bound system call process control block DVS modules PowerNow speed scaling Soft real-time scheduling standard Linux scheduler Extension to Linux kernel 716 lines of C code

39 Evaluation: Normalized Energy
Reduces power consumption However, limited due to few speed options

40 Mobile File Systems

41 Discussion What challenges does the file system face in wireless/mobile environment?

42 The Problems Caused by Mobility
Read miss stalls progress (the user has to stop working) Synchronization/consistency issues may need to synchronize multiple copies of the same file if multiple users, may need to solve consistency problems Heterogeneous device types each device has its own file systems and naming convention, e.g., digital camera, ipod

43 Approaches Read miss Synchronization/consistency issues
explicit user file selection, e.g., MS briefcase automatic hoarding, e.g., CODA, SEER Synchronization/consistency issues keep modification logs and develop merge tools, e.g., Bayou efficient file comparisons and merging, e.g., rsync, LBFS Heterogeneous device types masks the differences , e.g., EnsemBlue

44 SEER: automatic prediction of related files to avoid user manual configuration of hoarding

45 SEER: A Predictive Hoarding System
Views user activities as composed of projects than individual files Predicates files in a project and fetch them together Discussion: how do you predicate all of the files a project may use?

46 Basic Idea of SEER: Semantic Distance
Quantifies user’s intuition about relationship between files smaller  closer in relation Infers relationship static (done by an external investigator), e.g., observes directory structure/membership observes naming convention #include in a program dynamic watches user’s behavior What is semantic distance : quantify user’s intuition about relationship between files

47 Lifetime Semantic Distance
Looks at file open/close (not file content !!) Lifetime semantic distance: The lifetime semantic distance between an open of file A and an open of file B is defined as 0 if A has not been closed before B is opened and the number of intervening file opens (including the open of B) otherwise End up with multiple lifetime semantic distances between two events of two files needs distance between two files, not events uses geometric mean to convert to a single distance A B C D Time Sample file access sequence Semantic distance - AB , AC is 0 - AD is 3

48 Basic Idea of SEER: Clustering Algorithm
Based on algorithm by Jarvis and Patrick Allows overlapping clusters Steps calculates n nearest neighbors for each file Phase 1: if two points (files here) have at least kn overlapping neighbors, combine their clusters into one Phase 2: if two points have more than kf but less than kn overlapping neighbors, overlap the clusters i.e. add each to the other cluster Relation Action kn ≤x kf≤x<kn x<kf Combine clusters Overlapping clusters No action Summary of clustering algorithm

49 Number of shared neighbors
Example Seven files , A-G {A} {B} {C} {D} {E} {F} {G} Phase 1: {A, B}  {A, B, C} {D, E} {F, G}  {D,E,F, G} Phase 2: two pairs {A, C} {C, D} {A, C} : same cluster already {C, D}  overlap clusters Final result {A, B, C, D} {C,D, E, F,G} From To A B C D E F G A B C D E F G kn kf kn kf Number of shared neighbors

50 Using Both Lifetime Semantic Distance and the Input of External Investigator
Essentially gives application specific info Example large directory distance => looser relationship subtract directory distance from shared neighbor count

51 Real World Anomalies: Special Cases
Many special cases authors use a heuristic to solve each Shared libraries e.g. : library X might cause unwanted clustering Heuristic: files which represent more than a certain percentage of all references marked as “frequently-referenced” (1%) eliminate from calculation Number of special cases, and they use a heuristic for each. I’ll just take a couple

52 More Special Cases … Simultaneous access
Critical files (e.g. : startup files) rarely accessed but important use heuristic and hoard special control file that specifies such files detect by names e.g. .login etc Temporary files (e.g. : in /tmp) transient and don’t depict correct relationship might displace other important files from n closest heuristic: ignore files in /tmp etc. completely Simultaneous access e.g. : read mail & compile code independent streams are intermixed ! maintain reference-history on a per-process basis

53 Scheduling of Multimedia Applications
Earliest deadline first (EDF) scheduling - allocate cycle budget per job - execute job with earliest deadline and positive budget - charge budget by number of cycles consumed - preempt if budget is exhausted

54 Bayou: automatic conflict update

55 Bayou: Managing Update Conflicts
Basic idea: application specific conflict detection and update Two mechanisms for automatic conflict detection and resolution dependency check merge procedure

56 Bayou Write Operation: An Example

57 Mobile file systems: dealing with low bandwidth: LBFS: efficient file comparison and merging

58 Motivation The CODA system assumes that modifications are kept as logs (CML) a user sends the logs to the servers to update If the storage of a client is limited, it may not be able to save logs then upon reconnection, the cache manager needs to find the difference between the stored file and its local cached copy same problem exists for the rsync tool ! Question: how to efficiently compare the differences of two remote files (when the network connection is slow)?

59 LBFS: Low-Bandwidth File System
Break Files into chunks and transfer only modified chunks Fixed chunk size does not work well why?

60 Flexible Chunk Size Compute hash value of every 48 byte block
if the hash value equals to a magic value, it is a chunk boundary


Download ppt "Mobile Systems Richard Yang."

Similar presentations


Ads by Google