Real-Time Systems, 2009 Fall
Project 2: Energy-Efficient Scheduling For Android
Environment
Advised by Prof. Tei-Wei Kuo
TA: Po-Chun Huang (黃柏鈞)
Introduction
• From the previous assignment, we know how to control the
power modes of the backlight device on the Android
platform
• However, it is not trivial to simply turn off the backlight device
when we do not need it, for the considerable time and
energy overheads on power mode switching
• Don’t worry; in this assignment we will find a clever way to do
this (since it is required )
2
Some Quick Facts
• Power consumption of T-Mobile G1
Current: mA
600
500
!!
400
300
200
100
0
Screen off
Fly mode +
screen off
Screen on
Screen on + WiFi
GPS on
Reference: http://rockthearth.blogspot.com/2009/04/power-consumption-of-t-mobile-g1.html
Configurations of
Peripheral Devices
3
What Will Be Done in This Assignment? (1/2)
• We will be given a task set T of periodic tasks ti, for i=1, 2,…, N
– All tasks arrive at time point 0
– Tasks are sorted based on their periods (so pi <= pj iff i<j)
• Each task has a period pi, deadline di, and several operations xij (i=1…N; j=1…ni), each of which has the
following properties:
– Luminance uij: can be C, DL and DH, standing for Computation (no display required), Display in Low light
and Display in High light, respectively
– Length lij: lij=1, 2, …(setting the time unit to 3~4 seconds is a good choice)
• The requirements of a feasible schedule is those of a conventional hard real-time environment, plus
– The operations of the same task must be scheduled in the specified order
– During the scheduled time of each operation, the back light device must be adjusted to at least as bright as
that specified as required Luminance
4
What Will Be Done in This Assignment? (2/2)
• Energy issues
– During each time unit, the backlight device at none(C), low light display (DL), and
high light display (HL) consumes EC, EDL, and EDH of energy, respectively
• Of course we can assume that EDH>EDL>EC>=0
• For simplicity we assume that EC=0
– Additional energy ESW is consumed on power level switching
• For simplicity, we assume that switching from an arbitrary power level to another demands
the same quantity of energy
• For simplicity, we assume that power level switching happens immediately
• Our goal:
Compute the feasible schedule with minimal energy consumption!
5
A Sample Input
• The input will be given to you manually; you can hard-code
them in your sources (with clear mark so that I know it’s the
input )
• T = {t1, t2, t3}
–
–
–
–
t1 = (16(p1), 14(d1), ((1, 0(C))(x11), (1, 1(DL))(x12)))
t2 = (20(p2), 20(d2), ((1, 2(DH))(x21), (3, 1)(x22)))
t3 = (28(p3), 20(d3), ((1, 0)(x31), (1, 1)(x32), (1, 0)(x33)))
EC=0, EDL=1, EDH=5, ESW=12
6
Scoring
• Baseline: RM schedule (30%)
• Implement then write down your improvement over the RM
schedule in reports (70%)
– Must provide the intuition and sufficient examples to show why it is better
than original RM!
– Must output the detailed computed schedule with LogCat!
• Better if you can prove the bound of energy or time! (30% bonus)
• Even better if you can compose a demo of your algorithm on the
Android emulator! (30% bonus)
7
The LogCat Debugging Console
8
Open the LogCat Console View
• Add the LogCat view to menu shortcut: Window ->
Customize Perspective -> Shortcuts -> Submenus : Show
View -> Categories : Android -> LogCat
• Open the view: Window -> Show View -> LogCat
9
Print Customized Debugging Messages in LogCat
•
•
•
•
Import android.util.Log package in your project
Use the static variable Log to keep trace of your target: Log.d("DEBUG", "message");
Please use the message typed “DEBUG” to make them distinguished from system messages!
You must print at least the following messages to receive any score
– If the task set is un-schedulable, simply print “Unschedulable!”
– Else, during the time interval [0, LCM(p1, …, pN)), in each time unit, the light level and the IDs of
scheduled operation and its residing task should be printed as:
Time XX: Running task XX, operation XX, H(high light)/L(low light)/N(no light)
– If nothing is being executed during that time, print: Time XX: Idle, H/L/N
– By the end of program, print out a summary message about the total energy consumption statistics, and
the number of light level switching, using RM and your algorithms respectively:
Total high light time: XX
Total low light time: XX
Total no light time: XX
Total light switching: XX times
Total energy consumption of RM: XX
Total energy consumption of my algorithm: XX
Improvement by XX%
10
Sample Outputs 1
• ---- RM ----
– Unschedulable!
• ---- My program ---– Unschedulable!
• ---- Results ----
– Unschedulable!
11
Sample Outputs 2
• ---- RM ---–
–
–
–
–
–
–
–
–
Time 0: Running task 1, operation 1, H
Time 1: Running task 2, operation 1, L
……
Time 48: Running task 1, operation 1, N
Total high light time: 22
Total low light time: 15
Total no light time: 11
Total light switching: 16 times
Total energy consumption: 130
• ---- My program ---–
–
–
–
–
–
–
–
–
Time 0: Running task 1, operation 1, H
Time 1: Running task 1, operation 2, H
……
Time 48: Running task 2, operation 1, N
Total high light time: 17
Total low light time: 16
Total no light time: 15
Total light switching: 6 times
Total energy consumption: 108
• ---- Results ----
– Energy improved by 17%
12
Hint 1: Modify RM
• Modify RM to reduce power without sacrificing
schedulability
13
Hint 2: Idle Time…
• How about the light mode between scheduled task
operations?
N
N
N
• We know that
• How about…
H
???
H
H
???
L
L
???
H
14
Hint 3: Moving and Swapping
• Moving: Without violating the deadlines, move the
scheduled points of tasks left or right to reduce the idle time
• Swapping: Without violating the deadlines, swap the
scheduled points of tasks to reduce light level switching
L
L
H
L
L
H
H
H
15
Hint 4: Switching the Power Levels based on the
Schedule of Your Solution
• Thread.sleep lets a thread “sleep” for a specified time period
• Thread.run executes the thread’s method
• Thread.join waits for the created thread to finish for its
computation results
• No need to create a thread for each task…
16
Submission
• The deadline of this assignment is 1/7, 23:59
• Mail to [email protected] with
– Title: [RTS Project II] Your-Student-ID Your-Name
– Attached files:
• Project directory compressed into a single file: Your-Student-ID.zip/.tar/.tgz/.7z
• Report: Your-Student-ID.txt
– You will receive a confirmation about your submission in two
days; if not, please contact TA immediately
– Any questions are welcome through E-mail or face-to-face
discussion in R442!
17
Thank You!
Q&A?
18
© Copyright 2026 Paperzz