0
Introduction to Real-Time Operating Systems
Objectives <ul><li>Understanding Real-Time Operating Systems </li></ul><ul><ul><li>Types of Real-Time Operating System </l...
Objectives <ul><li>Conversion Linux kernel to support Real-Time operations </li></ul><ul><ul><li>Patching the linux kernel...
Introduction <ul><li>Operating System (OS) </li></ul><ul><ul><li>Abstraction layer over the raw hardware </li></ul></ul><u...
Types of RTOS <ul><li>Hard RTOS </li></ul><ul><ul><li>Strict timing requirements </li></ul></ul><ul><ul><li>Optimized w.r....
Types of RTOS <ul><li>Soft RTOS </li></ul><ul><ul><li>Relative tolerable timing deadlines </li></ul></ul><ul><ul><li>Toler...
GPOS and RTOS comparison <ul><li>Scheduling </li></ul><ul><li>Locking mechanism  </li></ul><ul><li>Hardware and software s...
Scheduling <ul><li>Makes multitasking feasible </li></ul><ul><li>Shares resources between tasks </li></ul><ul><li>Follows ...
Scheduling <ul><li>Preemption </li></ul><ul><ul><li>Shift of resource control from low to high priority task  </li></ul></...
Scheduling Preemption process
Scheduling <ul><li>Yielding </li></ul><ul><ul><li>Process itself give up the resources </li></ul></ul><ul><ul><li>Responsi...
Kernel Locks <ul><li>Locks  </li></ul><ul><ul><li>Avoid a critical code section to be accessed by two active threads simul...
Summary of comparison RTOS <ul><li>Unfair scheduling </li></ul><ul><ul><li>Scheduling based on priority </li></ul></ul><ul...
Limitations for RT applications <ul><li>System management interrupts </li></ul><ul><li>DMA bus mastering </li></ul><ul><li...
Limitations for RT applications <ul><li>System Management Mode (SMM) </li></ul><ul><ul><li>SMI cause system to enter in SM...
Limitations for RT applications <ul><li>System Management Mode (SMM) </li></ul><ul><ul><li>OS has no control to preempt SM...
Limitations for RT applications <ul><li>On-demand CPU frequency scaling </li></ul><ul><ul><li>CPU is put in low power stat...
Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Occurs when requested data is not available or i...
Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Minor page faults </li></ul></ul><ul><ul><ul><li...
Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Tips to avoid page faults </li></ul></ul><ul><ul...
Limitations for RT applications <ul><li>Context switching </li></ul><ul><ul><li>Flushed pipeline and branch prediction cou...
Conversion of GPOS to RTOS <ul><li>RT support in stock Linux kernel </li></ul><ul><ul><li>Stock Linux kernel supports soft...
Conversion of GPOS to RTOS <ul><li>RT support in stock Linux kernel </li></ul><ul><ul><li>Scheduling policies definition i...
Conversion of GPOS to RTOS <ul><li>SCHED_FIFO </li></ul><ul><ul><li>First-in-first-out scheduling policy </li></ul></ul><u...
Conversion of GPOS to RTOS <ul><li>SCHED_RR </li></ul><ul><ul><li>Same as SCHED_FIFO but involves time slots </li></ul></u...
Conversion of GPOS to RTOS <ul><li>RT patch for stock Linux kernel </li></ul><ul><ul><li>CONFIG_PREEMPT_RT </li></ul></ul>...
Conversion of GPOS to RTOS <ul><li>Applying the patch  </li></ul><ul><ul><li>Download the real-time patch </li></ul></ul><...
Conversion of GPOS to RTOS <ul><li>Applying the patch  </li></ul><ul><ul><li>Place both kernel and patch in same directory...
Conversion of GPOS to RTOS <ul><li>Applying the patch  </li></ul><ul><ul><li>Dry-run the patch </li></ul></ul><ul><ul><li>...
Conversion of GPOS to RTOS <ul><li>Applying the patch </li></ul><ul><ul><li>In case of some error check the versions of do...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Open configuration dialog </li></ul...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Activate High Resolution Timer </li...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Enable Complete Preemption (Real-Ti...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Power management configuration </li...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><ul><li>Disable CPU frequency scaling  ...
Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><ul><li>Disable TCO timers   (Device Dr...
Conversion of GPOS to RTOS <ul><li>Building the Linux kernel </li></ul><ul><ul><li>Make the kernel </li></ul></ul><ul><ul>...
Real-Time patch effect on kernel <ul><li>Locking mechanism </li></ul><ul><li>Priority inheritance </li></ul><ul><li>Interr...
Locking mechanism <ul><li>Locks  </li></ul><ul><ul><li>Prevent the shared resources to be accessed by two active processes...
Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Waiting threads keep on trying until the lock is acquired </li><...
Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Acquiring a spinlock raw_spin_lock() (/include/linux/spinlock_ap...
Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Advantages of spinlocks </li></ul></ul><ul><ul><ul><li>Low locki...
Locking mechanism <ul><li>Semaphores </li></ul><ul><ul><li>Sleeping locks </li></ul></ul><ul><ul><li>Waiting threads sleep...
Locking mechanism <ul><li>Semaphores </li></ul><ul><ul><li>Sleeping locks </li></ul></ul><ul><ul><li>Waiting threads sleep...
Locking mechanism <ul><li>Spinlock for RT application – A potential problem </li></ul><ul><ul><li>Unpredictable in nature ...
Locking mechanism <ul><li>Solution for RT behavior </li></ul><ul><ul><li>Replace spinlock with mutex if possible </li></ul...
Locking mechanism <ul><li>Spinlocks are unavoidable at low level </li></ul><ul><ul><li>Example: Implementation of mutex </...
Locking mechanism <ul><li>Real-Time implementation of spinlocks </li></ul><ul><ul><li>rt_spin_lock() </li></ul></ul><ul><u...
Locking mechanism <ul><li>Real-Time implementation of spinlocks </li></ul><ul><ul><li>rt_spin_unlock() </li></ul></ul><ul>...
Priority inheritance  <ul><li>Priority inversion </li></ul><ul><li>L and H require same lock but M requires another lock <...
Priority inheritance  <ul><li>Priority inversion </li></ul><ul><ul><li>Priority inversion may not be noticeable in GPOS </...
Priority inversion <ul><li>Solution of priority inversion </li></ul><ul><ul><li>Priority inheritance (PI)  </li></ul></ul>...
Priority inversion <ul><li>Priority inversion non-mutual exclusion Locks </li></ul><ul><ul><li>PI works fine for mutual ex...
Priority inversion <ul><li>Read-copy-update </li></ul><ul><ul><li>Technique to share read/write resources </li></ul></ul><...
Threaded interrupt handler <ul><li>Interrupt handler </li></ul><ul><ul><li>Function that runs whenever a particular interr...
Threaded interrupt handler <ul><li>Top half </li></ul><ul><ul><li>Performs essential services to hardware </li></ul></ul><...
Threaded interrupt handler <ul><li>Interrupt handler in GOPS </li></ul>
Threaded interrupt handler <ul><li>Interrupt handler in GOPS </li></ul><ul><ul><li>Kernel identifies the interrupt </li></...
Threaded interrupt handler <ul><li>Interrupt handler in RTOS </li></ul><ul><ul><li>Interrupt handler runs as kernel thread...
Threaded interrupt handler <ul><li>Interrupt handler in RTOS </li></ul><ul><ul><li>Top half identifies the interrupt </li>...
Threaded interrupt handler <ul><li>Advantages of conversion of handler to kernel thread </li></ul><ul><ul><li>Preemptable ...
Threaded interrupt handler <ul><li>Kernel code snippet </li></ul><ul><ul><li>request_threaded_irq() is to register threade...
Threaded interrupt handler <ul><li>request_threaded_irq() code snippet </li></ul><ul><ul><li>Initializes pointers and call...
Threaded interrupt handler <ul><li>__setup_irq() code snippet </li></ul><ul><li>preempt_hardirq_setup() code snippet </li>...
Threaded interrupt handler <ul><li>irq_default_primary_handler() code snippet </li></ul><ul><ul><li>This function raise th...
High resolution timers <ul><li>Timer triggers an event at a specified time </li></ul><ul><li>Shorter the tick of timer clo...
High resolution timers <ul><li>Improving the timer resolution </li></ul><ul><ul><li>Shift ticking source from jiffy to har...
High resolution timers <ul><li>Timer wheel </li></ul><ul><ul><li>Timer as wheel and delays as bucket in the wheel </li></u...
High resolution timers <ul><li>Issues with timer wheel implementation in RTOS </li></ul><ul><ul><li>Unpredictable behavior...
High resolution timers <ul><li>High resolution(HR) timers for real-time kernel </li></ul><ul><ul><li>Introduced by Thomas ...
High resolution timers <ul><li>Action timers in timer wheel </li></ul><ul><ul><li>Rehashing is required for each event ent...
High resolution timers <ul><li>Timeout timers in wheel </li></ul><ul><ul><li>Does not require rehashing  </li></ul></ul><u...
High resolution timers <ul><li>HR timers </li></ul><ul><ul><li>Implements timer in red/black trees </li></ul></ul><ul><ul>...
Examples of RT application  <ul><li>Time bound is the basic characteristic for RT application </li></ul><ul><li>Example  <...
Audio feedback cancellation <ul><li>Output signal is fed back to input and amplified again </li></ul><ul><li>Amplified sig...
Audio feedback cancellation <ul><li>Audio feedback block diagram representation </li></ul><ul><li>Condition for audio feed...
Audio feedback cancellation <ul><li>Factors effecting feedback </li></ul><ul><ul><li>Distance </li></ul></ul><ul><ul><li>A...
Audio feedback cancellation <ul><li>Audio feedback cause the system to oscillate at single frequency </li></ul><ul><li>Fee...
Audio feedback cancellation Frequency spectrum for a voice sample
Audio feedback cancellation Frequency spectrum for a voice sample with feedback
Audio feedback cancellation <ul><li>Methods of audio feedback cancellation </li></ul><ul><ul><li>Two major categories </li...
Audio feedback cancellation <ul><li>Manual feedback cancellation </li></ul><ul><ul><li>Move the position of microphone </l...
Audio feedback cancellation <ul><li>Automatic feedback cancellation </li></ul><ul><ul><li>Two major categories for automat...
Audio feedback cancellation <ul><li>Automatic equalization </li></ul><ul><ul><li>Signal spectrum is observed all the time ...
Audio feedback cancellation <ul><li>Frequency shifting  </li></ul><ul><ul><li>Shifts the input signal by a small frequency...
Audio feedback cancellation <ul><li>Frequency shifting </li></ul>http://www.alango.com/contents/products/technologies/afr/...
Audio feedback cancellation <ul><li>Implemented feedback removal technique </li></ul><ul><ul><li>Human voice is highly unc...
Audio feedback cancellation <ul><li>Implemented feedback removal technique </li></ul><ul><ul><li>In case of feedback, remo...
Audio feedback cancellation <ul><li>Removing the feedback frequency </li></ul><ul><ul><li>Adaptive filters are used for re...
Audio feedback cancellation <ul><li>Filter implementation </li></ul><ul><ul><li>Implementation of such a filter is very di...
Audio feedback cancellation <ul><li>Block diagram for frequency domain filter </li></ul><ul><li>Removing frequency compone...
Audio feedback cancellation <ul><li>Filter implementation </li></ul><ul><ul><li>Initially signal is converted to frequency...
Audio feedback cancellation <ul><li>Results of frequency domain filtering </li></ul><ul><li>MATLAB plots for testing audio...
Audio feedback cancellation <ul><li>Parallelization of filter </li></ul><ul><ul><li>Major workload in filter is FFT and IF...
Audio feedback cancellation <ul><li>Result of parallelization (  Data is gathered using intel Xeon 2 GHz, Quad core based ...
Labs <ul><li>Conversion of stock kernel to real time kernel </li></ul><ul><ul><li>Procedure to patch the kernel and to ins...
Upcoming SlideShare
Loading in...5
×

Introduction to Real-Time Operating Systems

7,521

Published on

shared by Mansoor Mirza
Understanding Real-Time Operating Systems
Types of Real-Time Operating System
Requirements for Real-Time Operating System
Difference between General Purpose Operating System (GPOS) and Real-Time Operating System (RTOS)

Conversion Linux kernel to support Real-Time operations
Patching the linux kernel
Major changes in patched kernel
Hands-on labs
Conversion of Linux kernel to support real time
Code a real time application (Audio Feedback removal)

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,521
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
414
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to Real-Time Operating Systems"

  1. 1. Introduction to Real-Time Operating Systems
  2. 2. Objectives <ul><li>Understanding Real-Time Operating Systems </li></ul><ul><ul><li>Types of Real-Time Operating System </li></ul></ul><ul><ul><li>Requirements for Real-Time Operating System </li></ul></ul><ul><ul><li>Difference between General Purpose Operating System (GPOS) and Real-Time Operating System (RTOS) </li></ul></ul>
  3. 3. Objectives <ul><li>Conversion Linux kernel to support Real-Time operations </li></ul><ul><ul><li>Patching the linux kernel </li></ul></ul><ul><ul><li>Major changes in patched kernel </li></ul></ul><ul><li>Hands-on labs </li></ul><ul><ul><li>Conversion of Linux kernel to support real time </li></ul></ul><ul><ul><li>Code a real time application (Audio Feedback removal) </li></ul></ul>
  4. 4. Introduction <ul><li>Operating System (OS) </li></ul><ul><ul><li>Abstraction layer over the raw hardware </li></ul></ul><ul><ul><li>Manages the hardware </li></ul></ul><ul><ul><li>Multiplexes the resources using scheduling policies </li></ul></ul><ul><li>Types of operating systems </li></ul><ul><ul><li>General purpose OS(GPOS) </li></ul></ul><ul><ul><ul><li>Optimized for throughput and fairness </li></ul></ul></ul><ul><ul><li>Real-Time OS (RTOS) </li></ul></ul><ul><ul><ul><li>Optimized for handling tasks within timing limits </li></ul></ul></ul>
  5. 5. Types of RTOS <ul><li>Hard RTOS </li></ul><ul><ul><li>Strict timing requirements </li></ul></ul><ul><ul><li>Optimized w.r.t. predictability and timing limits </li></ul></ul><ul><ul><li>Does not share critical resources such as CPU </li></ul></ul><ul><ul><li>Missing a single deadline cause system failure </li></ul></ul><ul><ul><li>Examples of application under hard real time </li></ul></ul><ul><ul><ul><li>Defense applications </li></ul></ul></ul><ul><ul><ul><li>Fuel ignition controller for automobile engine </li></ul></ul></ul><ul><ul><ul><li>Life supporting medical equipment </li></ul></ul></ul><ul><ul><ul><li>Industrial control system </li></ul></ul></ul>
  6. 6. Types of RTOS <ul><li>Soft RTOS </li></ul><ul><ul><li>Relative tolerable timing deadlines </li></ul></ul><ul><ul><li>Tolerance is defined as a part of policy </li></ul></ul><ul><ul><li>Occasional deadline missing may not cause system failure </li></ul></ul><ul><ul><li>Examples </li></ul></ul><ul><ul><ul><li>Audio processing </li></ul></ul></ul><ul><ul><ul><li>Real-time video processing </li></ul></ul></ul><ul><ul><ul><li>Network interface subsystem </li></ul></ul></ul>
  7. 7. GPOS and RTOS comparison <ul><li>Scheduling </li></ul><ul><li>Locking mechanism </li></ul><ul><li>Hardware and software support </li></ul>
  8. 8. Scheduling <ul><li>Makes multitasking feasible </li></ul><ul><li>Shares resources between tasks </li></ul><ul><li>Follows a scheduling policy </li></ul><ul><li>Task priority </li></ul><ul><ul><li>A number assigned to task according to its importance </li></ul></ul><ul><li>A higher priority task is preferred over a low priority task </li></ul>
  9. 9. Scheduling <ul><li>Preemption </li></ul><ul><ul><li>Shift of resource control from low to high priority task </li></ul></ul><ul><ul><li>Responsibility of kernel </li></ul></ul><ul><ul><li>Preemption limitations </li></ul></ul><ul><ul><ul><li>A code segment can not be preempted when it has acquire some lock which is acquired disabling interrupts </li></ul></ul></ul><ul><ul><ul><li>A process can only be preempted after a specified task expiration. </li></ul></ul></ul><ul><ul><ul><ul><li>Tradeoffs between coarse and fine grained timer </li></ul></ul></ul></ul>
  10. 10. Scheduling Preemption process
  11. 11. Scheduling <ul><li>Yielding </li></ul><ul><ul><li>Process itself give up the resources </li></ul></ul><ul><ul><li>Responsibility of process </li></ul></ul><ul><ul><li>Program designer has to take care of yielding </li></ul></ul><ul><ul><li>Disadvantages </li></ul></ul><ul><ul><ul><li>Unable to use available resources efficiently </li></ul></ul></ul><ul><ul><ul><li>Real-time systems can not rely on voluntary giving up of the CPU </li></ul></ul></ul><ul><li>Priority inversion </li></ul><ul><ul><li>A low priority task might cause high priority task to wait for execution </li></ul></ul>
  12. 12. Kernel Locks <ul><li>Locks </li></ul><ul><ul><li>Avoid a critical code section to be accessed by two active threads simultaneously </li></ul></ul><ul><ul><li>Especially important in multicore machines </li></ul></ul><ul><li>Effect of locks on real-time response </li></ul><ul><ul><li>Unpredictable delays for waiting threads </li></ul></ul><ul><ul><li>Might cause priority inversion </li></ul></ul><ul><ul><li>Some types of lock disables code preemptions </li></ul></ul>
  13. 13. Summary of comparison RTOS <ul><li>Unfair scheduling </li></ul><ul><ul><li>Scheduling based on priority </li></ul></ul><ul><li>Kernel is preemptive either completely or up to maximum degree </li></ul><ul><li>Priority inversion is a major issue </li></ul><ul><li>Predictable behavior </li></ul>GPOS <ul><li>Fair scheduling </li></ul><ul><ul><li>Scheduling can be adjusted dynamically for optimized throughput </li></ul></ul><ul><li>Kernel is non-preemptive or have long non-preemptive code sections </li></ul><ul><li>Priority inversion usually remain unnoticed </li></ul><ul><li>No predictability guarantees </li></ul>
  14. 14. Limitations for RT applications <ul><li>System management interrupts </li></ul><ul><li>DMA bus mastering </li></ul><ul><li>On-demand CPU frequency scaling </li></ul><ul><li>VGA text console </li></ul><ul><li>Page faults </li></ul><ul><li>Context switching </li></ul>
  15. 15. Limitations for RT applications <ul><li>System Management Mode (SMM) </li></ul><ul><ul><li>SMI cause system to enter in SMM </li></ul></ul><ul><ul><li>Debugs the hardware </li></ul></ul><ul><ul><li>Protects system </li></ul></ul><ul><ul><ul><li>Shutting down the system if CPU temperature exceeds </li></ul></ul></ul><ul><ul><li>Emulates hardware </li></ul></ul><ul><ul><ul><li>Emulates USB keyboard/mouse to ps2 keyboard/mouse </li></ul></ul></ul><ul><ul><li>CPU jumps to hardwired memory location to service SMI </li></ul></ul><ul><ul><li>SMI has highest priority </li></ul></ul>
  16. 16. Limitations for RT applications <ul><li>System Management Mode (SMM) </li></ul><ul><ul><li>OS has no control to preempt SMI handler </li></ul></ul><ul><ul><li>Causes unacceptable delay for RT applications </li></ul></ul><ul><ul><ul><li>Delay ranges from tens to hundreds of microseconds </li></ul></ul></ul><ul><li>DMA bus mastering </li></ul><ul><ul><li>Caused by devices using DMA </li></ul></ul><ul><ul><ul><li>SATA/PATA/SCSI devices, network adapters, video cards etc. </li></ul></ul></ul><ul><ul><li>Device drivers can increase latency </li></ul></ul><ul><ul><li>Common issue for all RTOS </li></ul></ul>
  17. 17. Limitations for RT applications <ul><li>On-demand CPU frequency scaling </li></ul><ul><ul><li>CPU is put in low power state after a period of inactivity </li></ul></ul><ul><ul><li>Can cause unpredictable or longer delays </li></ul></ul>
  18. 18. Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Occurs when requested data is not available or its reference is absent from a TLB </li></ul></ul><ul><ul><li>Types of page faults </li></ul></ul><ul><ul><ul><li>Major/Hard page faults </li></ul></ul></ul><ul><ul><ul><li>Minor/Soft page faults </li></ul></ul></ul><ul><ul><li>Major page faults </li></ul></ul><ul><ul><ul><li>Occurs when requested data has to be fetched from disk </li></ul></ul></ul><ul><ul><ul><li>Can cause very large latencies </li></ul></ul></ul><ul><ul><ul><li>RT application should be written to minimize Major page faults </li></ul></ul></ul>
  19. 19. Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Minor page faults </li></ul></ul><ul><ul><ul><li>Occurs when requested data resides in the main memory but missing from TLB </li></ul></ul></ul><ul><ul><ul><li>It does not involve IO operation to fetch data from disk </li></ul></ul></ul><ul><ul><ul><li>Has negligible impact in RT performance </li></ul></ul></ul><ul><ul><li>Tips to avoid page faults </li></ul></ul><ul><ul><ul><li>Use mlockall() to load all the address space of the program and then lock it such that it cannot be swapped out </li></ul></ul></ul>
  20. 20. Limitations for RT applications <ul><li>Page faults </li></ul><ul><ul><li>Tips to avoid page faults </li></ul></ul><ul><ul><ul><li>Create all threads at startup time of the application because run time thread creation can cause latencies </li></ul></ul></ul><ul><ul><ul><li>Avoid dynamic allocation and freeing of memory </li></ul></ul></ul><ul><ul><ul><li>Minimize the use system calls that are known to generate page faults </li></ul></ul></ul>
  21. 21. Limitations for RT applications <ul><li>Context switching </li></ul><ul><ul><li>Flushed pipeline and branch prediction counters </li></ul></ul><ul><ul><li>Can cause invalidation of cashes </li></ul></ul><ul><ul><li>Changes the entries in Instruction and data TLBs </li></ul></ul><ul><ul><li>Hence context switching might cause unacceptable behavior for some real-time application </li></ul></ul>
  22. 22. Conversion of GPOS to RTOS <ul><li>RT support in stock Linux kernel </li></ul><ul><ul><li>Stock Linux kernel supports soft RT response </li></ul></ul><ul><ul><li>Two RT scheduling policies in stock Linux kernel </li></ul></ul><ul><ul><ul><li>SCHED_FIFO </li></ul></ul></ul><ul><ul><ul><li>SCHED_RR </li></ul></ul></ul><ul><ul><li>Non-RT scheduling policy </li></ul></ul><ul><ul><ul><li>SCHED_NORMAL </li></ul></ul></ul><ul><ul><li>Static priority is implemented in RT scheduling </li></ul></ul><ul><ul><li>sched_setschedular() can be used to manage scheduling policies </li></ul></ul>
  23. 23. Conversion of GPOS to RTOS <ul><li>RT support in stock Linux kernel </li></ul><ul><ul><li>Scheduling policies definition in /include/linux/sched.h </li></ul></ul>
  24. 24. Conversion of GPOS to RTOS <ul><li>SCHED_FIFO </li></ul><ul><ul><li>First-in-first-out scheduling policy </li></ul></ul><ul><ul><li>Preempts all SCHED_NORMAL tasks </li></ul></ul><ul><ul><li>Tasks under SCHED_FIFO cannot be preempted </li></ul></ul><ul><ul><li>Task itself can yield the resources </li></ul></ul><ul><ul><li>Scheduling is not based on time slots </li></ul></ul><ul><ul><li>Two SCHED_FIFO process are scheduled as ‘first come first served’ fashion </li></ul></ul>
  25. 25. Conversion of GPOS to RTOS <ul><li>SCHED_RR </li></ul><ul><ul><li>Same as SCHED_FIFO but involves time slots </li></ul></ul><ul><ul><li>Process are scheduled in round-robin fashion </li></ul></ul><ul><ul><li>Share resources in allocated time slots </li></ul></ul><ul><ul><ul><li>Lower priority task cannot preempt higher priority task </li></ul></ul></ul><ul><ul><li>SCHED_RR process preempts SCHED_FIFO process </li></ul></ul>
  26. 26. Conversion of GPOS to RTOS <ul><li>RT patch for stock Linux kernel </li></ul><ul><ul><li>CONFIG_PREEMPT_RT </li></ul></ul><ul><ul><li>Adds support of hard RT in kernel </li></ul></ul><ul><ul><li>Managed by Ingo Molnar </li></ul></ul><ul><ul><li>Constantly developing patch </li></ul></ul><ul><ul><li>A suitable patch is required to be selected corresponding to chosen kernel depending on the kernel version </li></ul></ul>
  27. 27. Conversion of GPOS to RTOS <ul><li>Applying the patch </li></ul><ul><ul><li>Download the real-time patch </li></ul></ul><ul><ul><li>Download the kernel </li></ul></ul><ul><ul><li>Kernel and patch should be of same version </li></ul></ul><ul><ul><li>Commands in these slides are for version 2.6.33.7 </li></ul></ul>
  28. 28. Conversion of GPOS to RTOS <ul><li>Applying the patch </li></ul><ul><ul><li>Place both kernel and patch in same directory </li></ul></ul><ul><ul><li>Unpack the kernel </li></ul></ul><ul><ul><li>Change the directory </li></ul></ul>
  29. 29. Conversion of GPOS to RTOS <ul><li>Applying the patch </li></ul><ul><ul><li>Dry-run the patch </li></ul></ul><ul><ul><li>For correct patch output should be like this </li></ul></ul>
  30. 30. Conversion of GPOS to RTOS <ul><li>Applying the patch </li></ul><ul><ul><li>In case of some error check the versions of downloaded kernel and patch </li></ul></ul><ul><ul><li>Apply the patch if dry-run is succeeded </li></ul></ul><ul><ul><li>For uncompressed patch following set of commands can be used from uncompressed kernel directory </li></ul></ul>
  31. 31. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Open configuration dialog </li></ul></ul><ul><ul><li>xconfig or gconfig options can also be used </li></ul></ul><ul><ul><li>Apply following changes </li></ul></ul><ul><ul><ul><li>Activate High Resolution Timer </li></ul></ul></ul><ul><ul><ul><li>Enable Complete Preemption (Real-Time) </li></ul></ul></ul><ul><ul><ul><li>Apply power management settings according to the hardware </li></ul></ul></ul>
  32. 32. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Activate High Resolution Timer </li></ul></ul>
  33. 33. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Enable Complete Preemption (Real-Time) </li></ul></ul>
  34. 34. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><li>Power management configuration </li></ul></ul><ul><ul><ul><li>Some power management options can raise SMI </li></ul></ul></ul><ul><ul><ul><li>Disabling some options can cause system damage </li></ul></ul></ul><ul><ul><ul><li>Read every option carefully </li></ul></ul></ul><ul><ul><ul><li>Disable optional or unnecessary options </li></ul></ul></ul><ul><ul><ul><li>Disable CPU frequency scaling </li></ul></ul></ul><ul><ul><ul><li>Disable USB mouse/keyboard from BIOS </li></ul></ul></ul><ul><ul><ul><li>Use ps/2 keyboard/mouse </li></ul></ul></ul><ul><ul><ul><li>Disable TCO timers </li></ul></ul></ul>
  35. 35. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><ul><li>Disable CPU frequency scaling (Power Management and ACPI Options ->CPU Frequency scaling) </li></ul></ul></ul>
  36. 36. Conversion of GPOS to RTOS <ul><li>Configuration of Linux kernel </li></ul><ul><ul><ul><li>Disable TCO timers (Device Drivers---> watchdog timer support) </li></ul></ul></ul>
  37. 37. Conversion of GPOS to RTOS <ul><li>Building the Linux kernel </li></ul><ul><ul><li>Make the kernel </li></ul></ul><ul><ul><li>Make the modules </li></ul></ul><ul><ul><li>Install the modules </li></ul></ul><ul><ul><li>Install the kernel </li></ul></ul>
  38. 38. Real-Time patch effect on kernel <ul><li>Locking mechanism </li></ul><ul><li>Priority inheritance </li></ul><ul><li>Interrupt handler replaced with kernel threads </li></ul><ul><li>High resolution timers </li></ul>
  39. 39. Locking mechanism <ul><li>Locks </li></ul><ul><ul><li>Prevent the shared resources to be accessed by two active processes simultaneously. </li></ul></ul><ul><ul><li>Simultaneous access to unprotected shared resources will cause races and Heisen bugs </li></ul></ul><ul><li>Types of locks </li></ul><ul><ul><li>Spin locks </li></ul></ul><ul><ul><li>Semaphores </li></ul></ul><ul><ul><li>Readers/writer locks </li></ul></ul>
  40. 40. Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Waiting threads keep on trying until the lock is acquired </li></ul></ul><ul><ul><li>Waiting threads does not sleep </li></ul></ul><ul><ul><li>Local interrupts are disabled when spinlock is acquired to avoid deadlocks </li></ul></ul><ul><ul><li>Used in interrupt handlers </li></ul></ul><ul><ul><li>Lock should be acquired for short period of time </li></ul></ul><ul><ul><ul><li>Interrupts are disabled </li></ul></ul></ul><ul><ul><ul><li>Waiting threads do not sleep and utilize CPU resources </li></ul></ul></ul>
  41. 41. Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Acquiring a spinlock raw_spin_lock() (/include/linux/spinlock_api_smp.h) </li></ul></ul><ul><ul><li>Releasing spinlock raw_spin_unlock() (/include/linux/spinlock_api_smp.h) </li></ul></ul>
  42. 42. Locking mechanism <ul><li>Spinlocks </li></ul><ul><ul><li>Advantages of spinlocks </li></ul></ul><ul><ul><ul><li>Low locking overhead </li></ul></ul></ul><ul><ul><ul><li>Does not require time to sleep and awake the waiting threads </li></ul></ul></ul><ul><ul><li>Disadvantages of spinlocks </li></ul></ul><ul><ul><ul><li>Interrupts are disables </li></ul></ul></ul><ul><ul><ul><li>Waiting threads utilize the CPU </li></ul></ul></ul><ul><ul><ul><li>Lock have to released as early as possible </li></ul></ul></ul><ul><ul><ul><li>Thread acquiring spinlock cannot sleep </li></ul></ul></ul>
  43. 43. Locking mechanism <ul><li>Semaphores </li></ul><ul><ul><li>Sleeping locks </li></ul></ul><ul><ul><li>Waiting threads sleep and wait in wait queue </li></ul></ul><ul><ul><li>Waiting task has to be awaken before acquiring the lock </li></ul></ul><ul><ul><li>Advantages </li></ul></ul><ul><ul><ul><li>Waiting task frees the CPU for other workload </li></ul></ul></ul><ul><ul><ul><li>Lock can be acquired for long time </li></ul></ul></ul><ul><ul><li>Disadvantages </li></ul></ul><ul><ul><ul><li>Sleeping and awakening overhead </li></ul></ul></ul><ul><ul><ul><li>Spinlock acquired thread cannot acquire semaphore </li></ul></ul></ul>
  44. 44. Locking mechanism <ul><li>Semaphores </li></ul><ul><ul><li>Sleeping locks </li></ul></ul><ul><ul><li>Waiting threads sleep and wait in wait queue </li></ul></ul><ul><ul><li>Waiting task has to be awaken before acquiring the lock </li></ul></ul><ul><ul><li>Advantages </li></ul></ul><ul><ul><ul><li>Waiting task frees the CPU for other workload </li></ul></ul></ul><ul><ul><ul><li>Lock can be acquired for long time </li></ul></ul></ul><ul><ul><li>Disadvantages </li></ul></ul><ul><ul><ul><li>Sleeping and awakening overhead </li></ul></ul></ul><ul><ul><ul><li>Spinlock acquired thread cannot acquire semaphore </li></ul></ul></ul>
  45. 45. Locking mechanism <ul><li>Spinlock for RT application – A potential problem </li></ul><ul><ul><li>Unpredictable in nature </li></ul></ul><ul><ul><ul><li>Time to acquire lock for waiting thread is dependent on the thread that currently holds the lock </li></ul></ul></ul><ul><ul><li>OS cannot force the lock holder thread to release the lock </li></ul></ul><ul><ul><li>Non-preemptive sections of Linux kernel </li></ul></ul><ul><ul><li>Spinlocks disables local interrupts </li></ul></ul>
  46. 46. Locking mechanism <ul><li>Solution for RT behavior </li></ul><ul><ul><li>Replace spinlock with mutex if possible </li></ul></ul><ul><li>Advantages </li></ul><ul><ul><li>Mutex is a binary semaphore </li></ul></ul><ul><ul><li>Deterministic in nature </li></ul></ul><ul><ul><li>Can be preempted by high priority task </li></ul></ul>
  47. 47. Locking mechanism <ul><li>Spinlocks are unavoidable at low level </li></ul><ul><ul><li>Example: Implementation of mutex </li></ul></ul><ul><li>Spinlock usage in RT kernel is just a fraction to that of stock kernel </li></ul><ul><li>Reduction in usage reduces probability to contend the same spinlock by two different threads </li></ul>
  48. 48. Locking mechanism <ul><li>Real-Time implementation of spinlocks </li></ul><ul><ul><li>rt_spin_lock() </li></ul></ul><ul><ul><li>rt_spin_lock_fastlock() </li></ul></ul>
  49. 49. Locking mechanism <ul><li>Real-Time implementation of spinlocks </li></ul><ul><ul><li>rt_spin_unlock() </li></ul></ul><ul><ul><li>rt_spin_lock_fastlock() </li></ul></ul>
  50. 50. Priority inheritance <ul><li>Priority inversion </li></ul><ul><li>L and H require same lock but M requires another lock </li></ul>http://book.opensourceproject.org.cn/embedded/oreillyembed/opensource/0596009836/id-i_0596009836_chp_10_sect_4.html
  51. 51. Priority inheritance <ul><li>Priority inversion </li></ul><ul><ul><li>Priority inversion may not be noticeable in GPOS </li></ul></ul><ul><ul><li>High priority tasks may get starved of resources in GPOS due to priority inversion </li></ul></ul><ul><ul><li>High priority task should be executed as early as possible </li></ul></ul>
  52. 52. Priority inversion <ul><li>Solution of priority inversion </li></ul><ul><ul><li>Priority inheritance (PI) </li></ul></ul><ul><li>Priority inversion Priority Inheritance </li></ul>http://www.linuxjournal.com/article/9361?page=0,3
  53. 53. Priority inversion <ul><li>Priority inversion non-mutual exclusion Locks </li></ul><ul><ul><li>PI works fine for mutual exclusion locks </li></ul></ul><ul><ul><li>Problematic in case of other types of locks </li></ul></ul><ul><ul><ul><li>Example readers/writer locks </li></ul></ul></ul><ul><ul><li>PI can cause unacceptable response </li></ul></ul><ul><li>Solution </li></ul><ul><ul><li>Only one task at a time can read </li></ul></ul><ul><ul><li>Use read-copy-update if necessary </li></ul></ul>
  54. 54. Priority inversion <ul><li>Read-copy-update </li></ul><ul><ul><li>Technique to share read/write resources </li></ul></ul><ul><ul><li>Low cost reading </li></ul></ul><ul><ul><ul><li>Reading is carried out from local copy of data </li></ul></ul></ul><ul><ul><ul><li>Does not involve conventional locking for reading </li></ul></ul></ul><ul><ul><li>High cost writing </li></ul></ul><ul><ul><ul><li>Updates a global pointer to new data </li></ul></ul></ul><ul><ul><ul><li>Maintains copy of old data until all reading processes are finished </li></ul></ul></ul><ul><ul><li>Suitable for situation where there are fewer writes and many read operations </li></ul></ul>
  55. 55. Threaded interrupt handler <ul><li>Interrupt handler </li></ul><ul><ul><li>Function that runs whenever a particular interrupt occurs </li></ul></ul><ul><li>Two parts </li></ul><ul><ul><li>Top half </li></ul></ul><ul><ul><li>Bottom half </li></ul></ul><ul><li>Divided into two parts to reduce interrupt disabled time </li></ul>
  56. 56. Threaded interrupt handler <ul><li>Top half </li></ul><ul><ul><li>Performs essential services to hardware </li></ul></ul><ul><ul><li>Works with interrupts disabled </li></ul></ul><ul><ul><li>Gathers raw data </li></ul></ul><ul><ul><li>Performs critical time sensitive work </li></ul></ul><ul><li>Bottom half </li></ul><ul><ul><li>Performs time consuming tasks </li></ul></ul><ul><ul><li>Processes raw data </li></ul></ul>
  57. 57. Threaded interrupt handler <ul><li>Interrupt handler in GOPS </li></ul>
  58. 58. Threaded interrupt handler <ul><li>Interrupt handler in GOPS </li></ul><ul><ul><li>Kernel identifies the interrupt </li></ul></ul><ul><ul><li>Calls interrupt handler </li></ul></ul><ul><ul><li>CPU jumps to a particular location </li></ul></ul><ul><ul><li>Executes top half </li></ul></ul><ul><ul><li>Raise softirq and returns to pre-interrupt position </li></ul></ul><ul><li>This behavior is not acceptable in RTOS </li></ul><ul><ul><li>Cause unpredictability and long latencies </li></ul></ul><ul><ul><li>Local interrupts are disabled for longer time </li></ul></ul>
  59. 59. Threaded interrupt handler <ul><li>Interrupt handler in RTOS </li></ul><ul><ul><li>Interrupt handler runs as kernel thread </li></ul></ul>Building Embedded Linux Systems ISBN-10 = 0596529686, chapter 14,section: Interrupts as threads
  60. 60. Threaded interrupt handler <ul><li>Interrupt handler in RTOS </li></ul><ul><ul><li>Top half identifies the interrupt </li></ul></ul><ul><ul><li>Sends acknowledgement </li></ul></ul><ul><ul><li>Initializes kernel thread </li></ul></ul><ul><ul><li>Rest of task is performed as kernel thread </li></ul></ul><ul><li>A few interrupts are still handled conventionally </li></ul><ul><li>Threaded interrupt handler are also available in stock Linux kernel </li></ul>
  61. 61. Threaded interrupt handler <ul><li>Advantages of conversion of handler to kernel thread </li></ul><ul><ul><li>Preemptable interrupt handler </li></ul></ul><ul><ul><li>Reduces interrupt blocked time </li></ul></ul><ul><ul><li>Reduces probability of priority inversion </li></ul></ul><ul><ul><li>Handlers scheduling can be controlled by assigning a priority number to it </li></ul></ul><ul><ul><li>Reduces unpredictable latencies </li></ul></ul>
  62. 62. Threaded interrupt handler <ul><li>Kernel code snippet </li></ul><ul><ul><li>request_threaded_irq() is to register threaded interrupt handler </li></ul></ul>
  63. 63. Threaded interrupt handler <ul><li>request_threaded_irq() code snippet </li></ul><ul><ul><li>Initializes pointers and calls __setup_irq() </li></ul></ul>
  64. 64. Threaded interrupt handler <ul><li>__setup_irq() code snippet </li></ul><ul><li>preempt_hardirq_setup() code snippet </li></ul>
  65. 65. Threaded interrupt handler <ul><li>irq_default_primary_handler() code snippet </li></ul><ul><ul><li>This function raise the interrupt handler </li></ul></ul>
  66. 66. High resolution timers <ul><li>Timer triggers an event at a specified time </li></ul><ul><li>Shorter the tick of timer clock, higher the timer resolution </li></ul><ul><li>Jiffy: Software ticking unit </li></ul><ul><li>Granularity of time is reciprocal of jiffy </li></ul><ul><li>Increasing the jiffy value: </li></ul><ul><ul><li>improves the resolution </li></ul></ul><ul><ul><li>Increases the timer overhead </li></ul></ul><ul><ul><ul><li>Timer overhead is increased as jiffy is required to be updated more frequently </li></ul></ul></ul>
  67. 67. High resolution timers <ul><li>Improving the timer resolution </li></ul><ul><ul><li>Shift ticking source from jiffy to hardware clock </li></ul></ul><ul><li>Advantages </li></ul><ul><ul><li>Improves granularity of clock </li></ul></ul><ul><ul><li>Reduces timer overhead to update software entity </li></ul></ul><ul><ul><li>Frees resources that handle jiffy </li></ul></ul>
  68. 68. High resolution timers <ul><li>Timer wheel </li></ul><ul><ul><li>Timer as wheel and delays as bucket in the wheel </li></ul></ul><ul><ul><li>1 st set of buckets can provide 256 units delay </li></ul></ul><ul><ul><ul><li>If an event is to be triggered after 10 units it is placed in 10 th bucket </li></ul></ul></ul><ul><ul><li>Next level of buckets are used for delay greater than 256 units </li></ul></ul><ul><ul><li>Each bucket in 2 nd level represents 265 unit delay </li></ul></ul><ul><ul><li>An event is placed in next layer of buckets if delay is greater than 65536 (256 X 256) </li></ul></ul>
  69. 69. High resolution timers <ul><li>Issues with timer wheel implementation in RTOS </li></ul><ul><ul><li>Unpredictable behavior </li></ul></ul><ul><ul><li>Rehashing is required for each shift from 2 nd level to 1 st level </li></ul></ul><ul><ul><li>Rehashing is a function of no. of events in the wheel </li></ul></ul><ul><ul><ul><li>Delays increases as no of events increase (Rehashing takes O(n), where n is no. of events in the wheel) </li></ul></ul></ul>
  70. 70. High resolution timers <ul><li>High resolution(HR) timers for real-time kernel </li></ul><ul><ul><li>Introduced by Thomas Gleixner </li></ul></ul><ul><ul><li>Division of timers in two types </li></ul></ul><ul><ul><ul><li>Action timers </li></ul></ul></ul><ul><ul><ul><li>Timeout timers </li></ul></ul></ul><ul><ul><li>Action timers </li></ul></ul><ul><ul><ul><li>Measures elapsed time using timestamps </li></ul></ul></ul><ul><ul><li>Timeout timers </li></ul></ul><ul><ul><ul><li>Trigger an event after a specific time </li></ul></ul></ul>
  71. 71. High resolution timers <ul><li>Action timers in timer wheel </li></ul><ul><ul><li>Rehashing is required for each event entered in wheel </li></ul></ul><ul><ul><li>Rehashing takes time order O(n) </li></ul></ul><ul><ul><li>Entering or removal of an entry is of order O(1) </li></ul></ul><ul><ul><li>Rehashing delay is not constant and hence not predictable and might cause high latency </li></ul></ul>
  72. 72. High resolution timers <ul><li>Timeout timers in wheel </li></ul><ul><ul><li>Does not require rehashing </li></ul></ul><ul><ul><li>Operating is of order O(1) </li></ul></ul><ul><ul><li>Efficient and predictable </li></ul></ul><ul><li>HR timers majorly solves action timer problems </li></ul>
  73. 73. High resolution timers <ul><li>HR timers </li></ul><ul><ul><li>Implements timer in red/black trees </li></ul></ul><ul><ul><li>Does not involve hash data structure </li></ul></ul><ul><li>Advantages </li></ul><ul><ul><li>Add or removes the node in order O(logn) </li></ul></ul><ul><ul><li>Nodes in trees are already sorted </li></ul></ul><ul><ul><li>performance improves form O(n) to O(logn) where n is usually a large value </li></ul></ul>
  74. 74. Examples of RT application <ul><li>Time bound is the basic characteristic for RT application </li></ul><ul><li>Example </li></ul><ul><ul><li>Control systems in industry </li></ul></ul><ul><ul><li>Position and speed control system for synthetic aperture radars (SARs) </li></ul></ul><ul><ul><li>Operating system for ebook reader e.g. Kindle </li></ul></ul><ul><li>Audio feedback cancellation is selected for detailed discussion </li></ul>
  75. 75. Audio feedback cancellation <ul><li>Output signal is fed back to input and amplified again </li></ul><ul><li>Amplified signal includes both input and feedback resulting in noise and suppressing the original signal </li></ul><ul><li>Usually undesirable and required to eliminate as feedback development is in process </li></ul>
  76. 76. Audio feedback cancellation <ul><li>Audio feedback block diagram representation </li></ul><ul><li>Condition for audio feedback </li></ul><ul><ul><li>|H(f)H f (f)| < 1 </li></ul></ul><ul><ul><li>phase( H(f)H f (f)) = n360 o where n is integer </li></ul></ul>
  77. 77. Audio feedback cancellation <ul><li>Factors effecting feedback </li></ul><ul><ul><li>Distance </li></ul></ul><ul><ul><li>Amplification </li></ul></ul><ul><ul><li>Non constant gain of amplifier </li></ul></ul><ul><ul><li>Feed-forward path </li></ul></ul><ul><ul><li>Feed-back path </li></ul></ul><ul><ul><li>Transfer function of surrounding environment </li></ul></ul>
  78. 78. Audio feedback cancellation <ul><li>Audio feedback cause the system to oscillate at single frequency </li></ul><ul><li>Feedback starts with a number of frequencies </li></ul><ul><li>Frequency with higher magnitude grow faster </li></ul><ul><li>This frequency consumes greater power </li></ul><ul><li>Causes the die out of other feedback frequencies </li></ul>
  79. 79. Audio feedback cancellation Frequency spectrum for a voice sample
  80. 80. Audio feedback cancellation Frequency spectrum for a voice sample with feedback
  81. 81. Audio feedback cancellation <ul><li>Methods of audio feedback cancellation </li></ul><ul><ul><li>Two major categories </li></ul></ul><ul><ul><ul><li>Manual feedback cancellation </li></ul></ul></ul><ul><ul><ul><li>Automatic feedback cancellation </li></ul></ul></ul><ul><li>Manual feedback methods are useful in static environment </li></ul><ul><li>In dynamic environments automatic feedback cancellation methods are preffered </li></ul>
  82. 82. Audio feedback cancellation <ul><li>Manual feedback cancellation </li></ul><ul><ul><li>Move the position of microphone </li></ul></ul><ul><ul><ul><li>Changes phase of the signal fed back to input </li></ul></ul></ul><ul><ul><ul><li>Reduces magnitude of signal if mic is moved away </li></ul></ul></ul><ul><ul><li>Tuning the sound source (musical instruments) according to environment </li></ul></ul><ul><ul><li>Feedback frequencies attenuators can be sued if feedback frequencies are known </li></ul></ul>
  83. 83. Audio feedback cancellation <ul><li>Automatic feedback cancellation </li></ul><ul><ul><li>Two major categories for automatic feedback cancellation </li></ul></ul><ul><ul><ul><li>Automatic equalization </li></ul></ul></ul><ul><ul><ul><li>Frequency shifting </li></ul></ul></ul>
  84. 84. Audio feedback cancellation <ul><li>Automatic equalization </li></ul><ul><ul><li>Signal spectrum is observed all the time </li></ul></ul><ul><ul><li>Adaptive filters are used to suppress the frequency buildup </li></ul></ul><ul><ul><li>If feedback causes a particular frequency to increase, adaptive filters adopt themselves to suppress that typical frequency </li></ul></ul><ul><ul><li>Filter response is critical </li></ul></ul>
  85. 85. Audio feedback cancellation <ul><li>Frequency shifting </li></ul><ul><ul><li>Shifts the input signal by a small frequency </li></ul></ul><ul><ul><li>Breaks feedback path for a particular frequency </li></ul></ul><ul><ul><li>Very effective method to remove feedback </li></ul></ul><ul><ul><li>Disturbs the harmonic relationship between the signal components </li></ul></ul><ul><ul><li>Frequency shift should be selected with care </li></ul></ul>
  86. 86. Audio feedback cancellation <ul><li>Frequency shifting </li></ul>http://www.alango.com/contents/products/technologies/afr/papers/alango_afc.pdf
  87. 87. Audio feedback cancellation <ul><li>Implemented feedback removal technique </li></ul><ul><ul><li>Human voice is highly uncorrelated when sampled after reasonable time interval </li></ul></ul><ul><ul><li>Feedback signal is a single tone present in the voice signal </li></ul></ul><ul><ul><li>High value of correlation of two non-overlapping signals taken from voice sample indicates presence of feedback </li></ul></ul>
  88. 88. Audio feedback cancellation <ul><li>Implemented feedback removal technique </li></ul><ul><ul><li>In case of feedback, remove problematic frequency component form the signal </li></ul></ul><ul><li>Block diagram for feedback cancellation algorithm </li></ul>
  89. 89. Audio feedback cancellation <ul><li>Removing the feedback frequency </li></ul><ul><ul><li>Adaptive filters are used for removing the feedback </li></ul></ul><ul><li>Filter properties </li></ul><ul><ul><li>Adaptive </li></ul></ul><ul><ul><li>Quick to adopt to new frequency </li></ul></ul><ul><ul><li>Very high Q as to remove a single frequency </li></ul></ul>
  90. 90. Audio feedback cancellation <ul><li>Filter implementation </li></ul><ul><ul><li>Implementation of such a filter is very difficult </li></ul></ul><ul><ul><ul><li>Very large number of taps to get required response </li></ul></ul></ul><ul><ul><li>Low Q filter completely distort the signal </li></ul></ul><ul><ul><li>Frequency domain filter </li></ul></ul><ul><li>Procedure for frequency rectification </li></ul><ul><ul><li>Convert the signal to frequency domain </li></ul></ul><ul><ul><li>Detect the frequency that is to be removed </li></ul></ul><ul><ul><li>Remove that frequency </li></ul></ul><ul><ul><li>Convert the signal back to time domain </li></ul></ul>
  91. 91. Audio feedback cancellation <ul><li>Block diagram for frequency domain filter </li></ul><ul><li>Removing frequency component can be seen as multiplying the signal with a specific vector </li></ul>
  92. 92. Audio feedback cancellation <ul><li>Filter implementation </li></ul><ul><ul><li>Initially signal is converted to frequency domain using FFT </li></ul></ul><ul><ul><li>Required frequency is removed by zeroing the appropriate elements of FFT output </li></ul></ul><ul><ul><li>Signal is converted back to time domain using IFFT </li></ul></ul>
  93. 93. Audio feedback cancellation <ul><li>Results of frequency domain filtering </li></ul><ul><li>MATLAB plots for testing audio signal </li></ul>
  94. 94. Audio feedback cancellation <ul><li>Parallelization of filter </li></ul><ul><ul><li>Major workload in filter is FFT and IFFT </li></ul></ul><ul><ul><li>Parallelization of filter means to implement the FFT and IFFT in parallel </li></ul></ul><ul><ul><ul><li>In the sample code FFT and IFFT is carried out using FFTW library which is open source library that supports parallel implementation of FFT and IFFT. </li></ul></ul></ul><ul><ul><li>Parallelization improves the throughput of the system </li></ul></ul>
  95. 95. Audio feedback cancellation <ul><li>Result of parallelization ( Data is gathered using intel Xeon 2 GHz, Quad core based system ) </li></ul><ul><li>Increase in number of threads my lower the throughput due to synchronization overhead of threads and it might be overcome by increasing the amount of workload. </li></ul>*Throughput is for 100 second workload Threads Execution Time* (ms) 1 1294.873 2 836.96 3 645.57 4 578.07 5 510.23 6 487.7 7 462.05 8 682.008
  96. 96. Labs <ul><li>Conversion of stock kernel to real time kernel </li></ul><ul><ul><li>Procedure to patch the kernel and to install it </li></ul></ul><ul><li>Audio feedback cancellation </li></ul><ul><ul><li>Algorithm and C implementation of removal of audio feedback </li></ul></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×