![Page 1: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/1.jpg)
TOSTHREAD: THREAD-SAFE AND NON-INVASIVE PREEMPTION IN TINYOS
Justin
![Page 2: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/2.jpg)
Outline Introduction The Challenge of Preemption
TOSThreads Architecture Implementation Evaluation
![Page 3: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/3.jpg)
Introduction Operating System for WSNs
Support multiple concurrent execution○ Network protocol, storage and data filter…etc
Event-driven execution○ TinyOS
DisadvantageDevelop higher-level services and application
○ Compression
![Page 4: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/4.jpg)
The Challenge of Preemption Challenge:
Ability to call kernel code (code interact with hardware)
Common techniquesCooperative threading – using yieldKernel locking – using mutexMessage passing
![Page 5: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/5.jpg)
TOSThreads Architecture TinyOS – two classes of execution
Synchronous (tasks)Asynchronous (interrupts)
TOSThreads – third classUser-level application threads
Goals Minimun TinyOS kernel modification
![Page 6: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/6.jpg)
TOSThreads Architecture
Original TinyOS
![Page 7: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/7.jpg)
Implementation Platform independent
Thread schedulerThread and system call structureDynamic linking and loading
Platform dependentContext switch (assembly language)Post-amble for interrupt handler
![Page 8: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/8.jpg)
Flexible User/Kernel Boundary Blocking system call API Dynamic Linker and Loader
System CallTask
Application-level thread 1,2,3…
Send RecvSense File
Kernel-level thread
TinyOS Original code
![Page 9: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/9.jpg)
Kernel-level thread
TinyOS Original code
App-level thread 1
App-level thread 2
App-level thread 3
Thread Scheduler
TinyOS Modification Boot sequence
HardwareInitialize
TaskScheduler
![Page 10: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/10.jpg)
Evaluation - Microbenchmark
Overhead can be tolerated
![Page 11: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/11.jpg)
Evaluation - Energy analysis SSF application (Sense, Store and Forward)
Sense and write to flash per 5 minsSend via radio per 12hours
![Page 12: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/12.jpg)
Evaluation - Tenet A linear dataflow programs consisting of a
sequence of tasklets.
Repeat(1000ms) > Sample(ADC1,T) > LEQ(A,T,50) > DeleteDataIf(A) > Send()
![Page 13: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/13.jpg)
Evaluation - Tenet Tenet – C
Implement in TOSThread and TinyLD
![Page 14: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/14.jpg)
Evaluation - Tenet Tenet – C
Implement in TOSThread and TinyLD
Repeat(100ms) > ReadBlock(A,1024) > Avg(B,A) > MeanDev(C,A) > Send()
Repeat(50ms) > TimeStamp(A) > Sample(ADC5,V) > Send()
TaskLong
TaskSample
![Page 15: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/15.jpg)
Evaluation - Tenet
![Page 16: Justin. Outline Introduction The Challenge of Preemption TOSThreads Architecture Implementation Evaluation](https://reader036.vdocuments.us/reader036/viewer/2022072005/56649f3d5503460f94c5dc9a/html5/thumbnails/16.jpg)
Conclusion TOSThread
Thread-safeNon-invasive
Overhead is less Dynamic linking and loading is less – 0.92%