Download presentation
Presentation is loading. Please wait.
1
The Implementation of Dynamic Priority Assignment on CVM Threading System Insik Shin Real-time Systems Group University of Pennsylvania
2
Dynamic Priority Assignment Dynamic Priority Assignment (DPA) –When a thread is ready for its execution, its priority is dynamically assigned. DPA Policy –Assign the highest priority to thread A s. t. threads of lower priorities than A have later deadlines than A
3
Agenda Demos on the priority scheduling on CVM Demos on the periodic thread executions on CVM Output of the DPA implementation on CVM How to implement the DPA on CVM
4
Demo1 : Realtime vs Non-realtime class Demo1 { NRT t1 = new NRT(“Non-realtime Thread ” );NRT RT t2 = new RT(“Realtime Thread”);RT t1.start(); for (int i=0; i<2000000; i++) ; /* busy waiting */ t2.start(); } class NRT extends Thread { void run() { for (int i=0;i<5;i++) { /* busy waiting */ for (int j=0; j<2000000; j++) ; println (i + “ – “ + name); } println (“DONE! – “ + name); } class RT extends RealtimeThread { void run() { for (int i=0;i<5;i++) { /* busy waiting */ for (int j=0; j<2000000; j++) ; println (i + “ – “ + name); } println (“DONE! – “ + name); }
5
Demo1 : Realtime vs Non-realtime OUTPUT [JVM] A new thread is created. 0 Non-realtime Thread - 323 1 Non-realtime Thread - 327 2 Non-realtime Thread - 324 [JVM] A new thread is created. 0 Realtime Thread - 163 1 Realtime Thread - 164 2 Realtime Thread - 163 3 Realtime Thread - 163 4 Realtime Thread - 163 DONE! - Realtime Thread 3 Non-realtime Thread - 1807 4 Non-realtime Thread - 166 DONE! - Non-realtime Thread [root@SWING bin]# class Demo1 { NRT t1 = new NRT(“ Non-realtime Thread” );NRT RT t2 = new RT(“ Realtime Thread ”);RT t1.start(); /* busy waiting */ for (int i=0; i<2000000; i++) ; t2.start(); }
6
Demo2 : Priority Scheduling class Demo2 { PriorityParameters p15 = new PriorityParameters(15); PriorityParameters p25 = new PriorityParameters(25); RT t1 = new RT(“Priority 15 ”, p15);RT RT t2 = new RT(“Priority 25 ”, p25);RT t1.start(); for (int i=0; i<2000000; i++) ; /* busy waiting */ t2.start(); }
7
Demo2 : Priority Scheduling OUTPUT [JVM] A new thread is created. 0 – Priority 15 – 163 1 – Priority 15 - 163 2 – Priority 15 - 163 3 – Priority 15 - 163 4 – Priority 15 - 163 DONE! – Priority 15 [JVM] A new thread is created. 0 – Priority 25 – 163 1 – Priority 25 – 163 2 – Priority 25 – 163 3 – Priority 25 – 163 4 – Priority 25 – 163 DONE! – Priority 25 class Demo2 { RT t1 = new RT(“P 15”, p15);RT RT t2 = new RT(“P 25”, p25”);RT t1.start(); /* busy waiting */ for (int i=0; i<2000000; i++) ; t2.start(); }
8
Demo3 : Periodic Thread class Demo3 { PriorityParameters p15 = new PriorityParameters(15); PeriodicParameters pp = new PeriodicParameters ( new RelativeTime (100, 0), // start time new RelativeTime (500, 0), // period new RelativeTime (200, 0), // cost new RelativeTime (500, 0), // deadline null, null); // handlers PRT t1 = new PRT(“Periodic”, p15, pp);PRT t1.start(); }
9
Demo3 : Periodic Thread OUTPUT [JVM] A new thread is created. [RT] wFNP 0 – Periodic – 672 [RT] wFNP 1– Periodic – 500 [RT] wFNP 2 – Periodic – 500 [RT] wFNP 3 – Periodic – 500 [RT] wFNP 4 – Periodic – 500 DONE! – Periodic class Demo3 { RT t1 = new PRT(“Periodic”, p15, pp);PRT t1.start(); } class PRT extends RealtimeThread { void run() { for (int i=0;i<5;i++) { waitForNextPeriod(); /* busy waiting */ for (int j=0; j<2000000; j++) ; println (i + “ – “ + name); } println (“DONE! – “ + name); }
10
Demo4 : Periodic Threads OUTPUT [JVM] A new thread is created. 0 – Priority 25 – 663 0 – Priority 15 – 836 1– Priority 25 – 500 1– Priority 15 – 500 2– Priority 25 – 500 2– Priority 15 – 500 3– Priority 25 – 500 3– Priority 15 – 500 4– Priority 25 – 500 DONE! – Priority 25 5– Priority 15 – 500 DONE! – Priority 15 class Demo4 { RT t1 = new PRT(“P 15”, p15, pp);PRT RT t2 = new PRT(“P 25”, p25, pp);PRT t1.start(); t2.start(); } class PRT extends RealtimeThread { void run() { for (int i=0;i<5;i++) { waitForNextPeriod(); /* busy waiting */ for (int j=0; j<2000000; j++) ; println (i + “ – “ + name); } println (“DONE! – “ + name); }
11
Test : Dynamic Priority Assignment class Test { PriorityParameters p15 = new PriorityParameters(15); PriorityParameters p25 = new PriorityParameters(25); PriorityParameters p50 = new PriorityParameters(50); PeriodicParameters pp1; // period = deadline = 1500 PeriodicParameters pp2; // period = deadline = 800 PeriodicParameters pp3; // period = deadline = 1000 PRT t1 = new PRT(“FIX : P15”, p15, pp1);PRT PRT t2 = new PRT(“FIX : P25”, p25, pp2);PRT PRT t3 = new PRT(“Dynamic”, p50, pp3);PRT t1.start(); t2.start(); t3.start(); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.