¼ÓÈëÊÕ²Ø | ÉèΪÊ×Ò³ | »áÔ±ÖÐÐÄ | ÎÒҪͶ¸å ÔƼÆËãÍø_ËÞǨվ³¤Íø £¨https://www.0527zz.com/£©- ¿Æ¼¼¡¢½¨Õ¾¡¢¾­Ñé¡¢ÔƼÆËã¡¢5G¡¢´óÊý¾Ý,Õ¾³¤Íø!
µ±Ç°Î»Ö㺠Ê×Ò³ > ·þÎñÆ÷ > ´î½¨»·¾³ > Linux > ÕýÎÄ

dz̸ӲʵʱLinux(RT-Preempt Patch)ÔÚPCÉϵıàÒ롢ʹÓúͲâÊÔ

·¢²¼Ê±¼ä£º2016-01-26 17:21:35 ËùÊôÀ¸Ä¿£ºLinux À´Ô´£ºÍøÂçÕûÀí
µ¼¶Á£ºVanilla kernelµÄÎÊÌâ Linux kernelÔÚspinlock¡¢irqÉÏÏÂÎÄ·½ÃæÎÞ·¨ÇÀÕ¼£¬Òò´Ë¸ßÓÅÏȼ¶ÈÎÎñ±»»½Ðѵ½µÃÒÔÖ´ÐеÄʱ¼ä²¢²»ÄÜÍêÈ«È·¶¨¡£Í¬Ê±£¬Linux kernel±¾ÉíÒ²²»

Vanilla kernelµÄÎÊÌâ

Linux  kernelÔÚspinlock¡¢irqÉÏÏÂÎÄ·½ÃæÎÞ·¨ÇÀÕ¼£¬Òò´Ë¸ßÓÅÏȼ¶ÈÎÎñ±»»½Ðѵ½µÃÒÔÖ´ÐеÄʱ¼ä²¢²»ÄÜÍêÈ«È·¶¨¡£Í¬Ê±£¬Linux  kernel±¾ÉíÒ²²»´¦ÀíÓÅÏȼ¶·´×ª¡£RT-Preempt  PatchÊÇÔÚLinuxÉçÇøkernelµÄ»ù´¡ÉÏ£¬¼ÓÉÏÏà¹ØµÄ²¹¶¡£¬ÒÔʹµÃLinuxÂú×ãӲʵʱµÄÐèÇó¡£±¾ÎÄÃèÊöÁ˸ÃpatchÔÚPCÉϵÄʵ¼ù¡£ÎÒÃÇµÄ ²âÊÔ»·¾³ÎªUbuntu 10.10£¬Ä¬ÈÏÇé¿öÏÂʹÓÃUbuntu 10.10×Ô´øµÄkernel£º

barry@barry-VirtualBox:/lib/modules$ uname -a
2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:35:26 UTC 2012 i686 GNU/Linux

ÔÚUbuntu 10.10£¬apt-get install  rt-tests°²×°rt²âÊÔ¹¤¾ß¼¯£¬ÔËÐÐÆäÖеÄcyclictest²âÊÔ¹¤¾ß£¬Ä¬ÈÏ´´½¨5¸öSCHED_FIFO²ßÂÔµÄrealtimeỊ̈߳¬ÓÅÏȼ¶ 76-80£¬ÔËÐÐÖÜÆÚÊÇ1000,1500,2000,2500,3000΢Ã룺

barry@barry-VirtualBox:~/development/panda/android$ sudo cyclictest -p 80 -t5 -n 
[sudo] password for barry: 
policy: fifo: loadavg: 9.22 8.57 6.75 11/374 21385          
 
T: 0 (20606) P:80 I:1000 C:  18973 Min:     26 Act:   76 Avg:  428 Max:   12637
T: 1 (20607) P:79 I:1500 C:  12648 Min:     31 Act:   68 Avg:  447 Max:   10320
T: 2 (20608) P:78 I:2000 C:   9494 Min:     28 Act:  151 Avg:  383 Max:    9481
T: 3 (20609) P:77 I:2500 C:   7589 Min:     29 Act:  889 Avg:  393 Max:   12670
T: 4 (20610) P:76 I:3000 C:   6325 Min:     37 Act:  167 Avg:  553 Max:   13673

Óɴ˿ɼûÔÚ±ê×¼LinuxÄÚ£¬rtÏß³ÌͶÈëÔËÐеÄjitter·Ç³£²»Îȶ¨£¬×îСֵÔÚ26-37΢Ã룬ƽ¾ùֵΪ68-889΢Ã룬¶ø×î´óÖµÔò·Ö²¼ÔÚ9481-13673΢ÃëÖ®¼ä¡£

ÎÒÃÇ»¹ÊÇÔËÐÐÕâ¸ö²âÊÔ£¬µ«ÊÇÔÚÔËÐÐÕâ¸ö²âÊԵĹý³ÌÖÐÒýÈë¸ü¶à¸ÉÈÅ£¬Èçmount /dev/sdb1 ~/development£¬Ôò½á¹û±äΪ£º

barry@barry-VirtualBox:~$ sudo cyclictest -p 80 -t5 -n 
policy: fifo: loadavg: 0.14 0.29 0.13 2/308 1908          
 
T: 0 ( 1874) P:80 I:1000 C:  28521 Min:      0 Act:  440 Avg: 2095 Max:  331482
T: 1 ( 1875) P:79 I:1500 C:  19014 Min:      2 Act:  988 Avg: 2099 Max:  330503
T: 2 ( 1876) P:78 I:2000 C:  14261 Min:      7 Act:  534 Avg: 2096 Max:  329989
T: 3 ( 1877) P:77 I:2500 C:  11409 Min:      4 Act:  554 Avg: 2073 Max:  328490
T: 4 ( 1878) P:76 I:3000 C:   9507 Min:     12 Act:  100 Avg: 2081 Max:  328991

mount¹ý³ÌÖÐÒýÈëµÄirq¡¢softirqºÍspinlockµ¼ÖÂ×î´ójitterÃ÷ÏԵؼӴóÉõÖÁ´ïµ½ÁË331482us£¬³ä·ÖÏÔʾ³öÁ˱ê×¼LinuxÄÚºËÖÐRTÏß³ÌͶÈëÔËÐÐʱ¼äµÄ²»¿ÉÔ¤ÆÚÐÔ(ӲʵʱҪÇóÒâζ×Å¿ÉÔ¤ÆÚ)¡£

Èç¹ûÎÒÃDZàÒëÒ»·Ýkernel£¬Ñ¡ÔñµÄÊÇ“Voluntary Kernel Preemption (Desktop)“£¬ÕâÀàËÆÓÚ2.4²»Ö§³ÖkernelÇÀÕ¼µÄÇé¿ö£¬ÎÒÃÇÔËÐÐͬÑùµÄcase£¬Ê±¼äµÄ²»È·¶¨ÐÔ´óµØ¼¸ºõÈÃÎÒÃÇÎÞ·¨½ÓÊÜ£º

barry@barry-VirtualBox:~$ sudo /usr/local/bin/cyclictest -p 80 -t5 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 0.23 0.30 0.15 3/247 5086           
 
T: 0 ( 5082) P:80 I:1000 C:   5637 Min:     60 Act:15108679 Avg:11195196 Max:15108679
T: 1 ( 5083) P:80 I:1500 C:   5723 Min:     48 Act:12364955 Avg:6389691 Max:12364955
T: 2 ( 5084) P:80 I:2000 C:   4821 Min:     32 Act:11119979 Avg:8061814 Max:11661123
T: 3 ( 5085) P:80 I:2500 C:   3909 Min:     27 Act:11176854 Avg:4563549 Max:11176854
T: 4 ( 5086) P:80 I:3000 C:   3598 Min:     37 Act:9951432 Avg:8761137 Max:116026155

RT-Preempt PatchʹÄÜ

RT-Preempt Patch¶ÔLinux kernelµÄÖ÷Òª¸ÄÔì°üÀ¨£º

Making in-kernel locking-primitives (using spinlocks) preemptible though reimplementation with rtmutexes:

Critical  sections protected by i.e. spinlock_t and rwlock_t are now preemptible.  The creation of non-preemptible sections (in kernel) is still possible  with raw_spinlock_t (same APIs like spinlock_t)

Implementing  priority inheritance for in-kernel spinlocks and semaphores. For more  information on priority inversion and priority inheritance please  consultIntroduction to Priority Inversion

Converting  interrupt handlers into preemptible kernel threads: The RT-Preempt  patch treats soft interrupt handlers in kernel thread context, which is  represented by a task_struct like a common userspace process. However it  is also possible to register an IRQ in kernel context.

Converting  the old Linux timer API into separate infrastructures for high  resolution kernel timers plus one for timeouts, leading to userspace  POSIX timers with high resolution.

ÔÚ±¾ÊÔÑéÖУ¬ÎÒÃÇÈ¡µÄ´øRT- Preempt PatchµÄkernel  treeÊÇgit://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-  rt.git£¬Ê¹ÓÃÆäv3.4-rt-rebase branch£¬±àÒëkernelʱѡÖÐÁË"Fully Preemptible  Kernel"ÇÀռģÐÍ:

©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤ Preemption Model ©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©´

©¦ ©¦          ( ) No Forced Preemption (Server)                  
©¦ ©¦          ( ) Voluntary Kernel Preemption (Desktop)        
©¦ ©¦          ( ) Preemptible Kernel (Low-Latency Desktop)    
©¦ ©¦          ( ) Preemptible Kernel (Basic RT)                
©¦ ©¦          (X) Fully Preemptible Kernel (RT)      

ÁíÍ⣬kernelÖÐÐèÖ§³ÖticklessºÍ¸ß¾«¶Ètimer£º

£¨±à¼­£ºÔƼÆËãÍø_ËÞǨվ³¤Íø£©

¡¾ÉùÃ÷¡¿±¾Õ¾ÄÚÈݾùÀ´×ÔÍøÂ磬ÆäÏà¹ØÑÔÂÛ½ö´ú±í×÷Õ߸öÈ˹۵㣬²»´ú±í±¾Õ¾Á¢³¡¡£ÈôÎÞÒâÇÖ·¸µ½ÄúµÄȨÀû£¬Ç뼰ʱÓëÁªÏµÕ¾³¤É¾³ýÏà¹ØÄÚÈÝ!