Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: Get an Exemption from Preemption with RTOSs running on ARM Processors - ARM Community

Jump to content

Get an Exemption from Preemption with RTOSs running on ARM Processors

Most real-time operating systems (RTOS) that support ARM processors use preemptive scheduling for real-time response. This is due to the fact that ARM processors are commonly used in consumer electronics, medical devices, and industrial control, all of which require at least some degree of real-time performance. But while preemption delivers responsiveness by enabling high-priority tasks/threads to use the CPU immediately as soon as they need it, in many cases this can add unnecessary overhead and actually reduce system throughput. Recent Computer Science research (see below) has shown that “Preemption-Threshold Scheduling” (PTS), introduced by Express Logic in 1997 in our ThreadX RTOS, can reduce context switch overhead, while still meeting all real-time schedulability deadlines.

Attached Image
In this excerpt from Jejurikar and Gupta’s 2004 study, we can see that PTS reduces context switches by 70% - 90%.

What’s interesting about PTS is that it eliminates context switching in many cases, while still enabling the system to meet real-time deadlines 100% of the time. But, embedded real-time systems that use ARM processors also demand massive throughput. For example, mobile devices handling streaming video are extremely dependent on high throughput, without which they could never provide the rich entertainment we have come to expect from our smartphones and tablets.

But, context switches use valuable CPU cycles, and this can prevent the system from meeting its throughput requirements, even with a powerful ARM9 or Cortex CPU. In fact, context switches on ARM processors tend to be faster (require fewer cycles) than on other processor architectures, because ARM processors use a relatively small register set, enable the loading/storing of multiple registers (including PC/SPSR) at a time. ThreadX further optimizes context switching on ARM by not saving/restoring the context when no thread is running (and therefore there is no preemption). And, Cortex-M parts are further optimized to save compiler scratch registers as part of the interrupt fetch on the interrupted thread's stack, making it unnecessary for the RTOS to do so.

Given the cycle cost of context switches, and the fact that context switches are an inevitable consequence of preemption, how does the developer support preemption and still achieve high throughput? With PTS, only the context switches that are essential to meeting deadlines are performed, while others are denied, even if it means letting a low priority thread continue to run while a higher priority thread is waiting. This reduces system overhead by completely eliminating many costly context switches, while preserving the system’s ability to meet real-time scheduling requirements. No matter how fast a context switch is performed, skipping it entirely is even faster!

For those looking for the full story, several articles and white papers are available on this topic:

"Lower the Overhead in RTOS Scheduling"
Professor Alexander Dean, Ph.D., Embedded Systems Design Magazine, March, 2011

“Scheduling Fixed-Priority Tasks with Preemption Threshold”
Wang, Concordia University, and Saksena, University of Pittsburgh

“Preemption threshold scheduling: Stack optimality, enhancements and analysis”
R. Ghattas and A. G. Dean, RTAS ’07: Proc. of the 13th IEEE Real Time and Embedded Technology and Applications Symposium, 2007

“Reducing Stack with Intra-Task Threshold Priorities in Real-Time Systems”
G. Yao and G. Buttazzo, Proceedings. of the 10th Int. Conf. on Embedded Software, 2010

So, developers - How do you balance the tradeoff between real-time responsiveness and maximum throughput in your ARM-based design? Would PTS possibly offer an attractive means of achieving the balance you desire? Please let us know your thoughts!

Attached Image
John A. Carbone, Vice President of Marketing for Express Logic, has 35 years experience in real-time computer systems and software, ranging from embedded system developer and FAE to vice president of sales and marketing. Mr. Carbone’s experience includes embedded computers, array processors, attached processors, development tools, and both commercial and proprietary real-time operating systems. Mr. Carbone has a BA degree in mathematics from Boston College.

ARM welcomes its wealth of Partners in the ARM Connected Community (CC) to submit guest blogs to be published on our multiple community blogs. If interested in participating please submit email inquiries to Tell.Us@arm.com.

The ARM Connected Community (CC) is an extensive ecosystem covering all aspects of ARM processor-based design, from chip implementation through to system and device design. The CC provides a platform for collaborative innovation, with multiple types of forums for members to work with one another, and with customers, to solve industry challenges, all with the purpose of enabling designers to focus on differentiating features and an accelerated time-to-market for ARM powered solutions.
All company and product names appearing in the ARM Blogs are trademarks and/or registered trademarks of ARM Limited per ARM’s official trademark list. All other product or service names mentioned herein are the trademarks of their respective owners.

0 Comments On This Entry

Please log in above to add a comment or register for an account