Embedded Systems Design Europe - May 2008 - (Page 17) cover feature Listing 5 How Protothreads are initially set up. static static static int { int counter; struct pt example_pt; struct pt another_one_pt; main(void) counter = 0; PT_INIT(&example_pt); PT_INIT(&another_one_pt); while(1) { example(&example_pt); another_one(&another_one_pt); counter++ } } Listing 6 A complete blending of an application using Protothreads and cooperative scheduler. #include “ppt.h” #include static extern extern extern struct pt int task1 int task2 int task3 pt1, pt2, pt3; (struct pt *pt); (struct pt *pt); (struct pt *pt); sume CPU time. If the only interrupt running on the system is the operating system’s tick, task execution can be pretty deterministic. If many interrupts are firing, timing of the operating system’s tick may start to drift. If too many interrupt handlers are being executed, there may not be enough CPU time to process the tasks in a timely manner. For an operating system such as this, it has been suggested that only the operating system’s tick interrupt should be allowed and the other interrupt sources should be polled. Not all situations require this interrupt moratorium, but keep it in mind. For example, predictable interrupts such as those generated by a T1 framer would probably not cause a problem. (Random interrupts may be another story.) Concern #3: Data storage in the threads. In none of the three IOSes is “true” context switching taking place. Each time a task “yields,” it’s actually returning to the scheduler. Data stored in local variables will be lost. This can be rectified by creating a storage object for the tasks local data. You could even add a pointer to this storage object in the Protothreads context. For example, note the myData pointer: struct pt { lc_t lc; void *myData; }; main () { int handle; ppt_tasksConstructor (); PT_INIT (&pt1); handle = ppt_createTask (task1, &pt1, 10, 500); printf(“First task created %d \n”, handle); PT_INIT (&pt2); handle = ppt_createTask (task2, &pt2, 1000, 5000); printf(“Second task created %d \n”, handle); PT_INIT (&pt3); handle = ppt_createTask (task3, &pt3, 100, 10); printf(“Third task created %d \n”, handle); while (1) { usleep (100); ppt_processTick (); ppt_processTasks (); } } All of this sounds great, but a few things must be kept in mind: Concern #1: Processing time. For cooperative scheduler based operating systems, it’s possible that tasks are scheduled too closely together or attempt to do too many things. If a task 0doesn’t complete or yield the CPU in a timely manner, the system will become indeterministic and possibly unstable. This can be rectified by splitting large tasks into smaller and smaller pieces. A developer must always be aware of how much CPU timer is being used and may have to be creative to properly split the tasks. If this becomes too much of a challenge, a traditional context switching operating system may be the proper answer. Concern #2: Interrupts also con- Beyond being very useful and powerful when used alone in a variety of tasks, I believe the blending of Protothreads and cooperative scheduling provide the combination of virtual concurrency and task scheduling an IOS environment needs to provide developers with a simple and quick way to get multitasking going on a new target. Michael Dorin (mdorin@gr-303.com) is an independent embedded software developer and is working toward a masters in computer science at Metro State University in St. Paul, Minnesota. 17 www.embedded.com/europe | embedded systems design europe | MAY 2008 http://www.embedded.com/europe
Table of Contents Feed for the Digital Edition of Embedded Systems Design Europe - May 2008 Embedded Systems Design Europe - May 2008 Contents Microsoft Provides Embedded Roadmap Enea Buys Developers Irish Start-Up Raises Funds for Telecom FPGAs Kontron Promotes COM Express Nano Mentor Nucleus Platform Provides UI for Atmel Small Form Factor Boards Head for the SUMIT Proffibus Advances IO-Link Integration Embedded Developers Cautious on Multicore Auto Cooperation Improves Test Altera Launches DO-254 Partner Network Building an ‘Instant-Up’ Real-Time Operating Systems An Architecture for Reusable Embedded Systems Software Free up Bandwidth in PCI Express Evaluating Software in Medical Devices Circuit Sensitivity in Analog Circuits Choosing Flash Memory New Products Advertising Contacts Embedded Systems Design Europe - May 2008 Embedded Systems Design Europe - May 2008 - Embedded Systems Design Europe - May 2008 (Page 1) Embedded Systems Design Europe - May 2008 - Embedded Systems Design Europe - May 2008 (Page 2) Embedded Systems Design Europe - May 2008 - Contents (Page 3) Embedded Systems Design Europe - May 2008 - Contents (Page 4) Embedded Systems Design Europe - May 2008 - Contents (Page 5) Embedded Systems Design Europe - May 2008 - Microsoft Provides Embedded Roadmap (Page 6) Embedded Systems Design Europe - May 2008 - Microsoft Provides Embedded Roadmap (Page 7) Embedded Systems Design Europe - May 2008 - Irish Start-Up Raises Funds for Telecom FPGAs (Page 8) Embedded Systems Design Europe - May 2008 - Irish Start-Up Raises Funds for Telecom FPGAs (Page 9) Embedded Systems Design Europe - May 2008 - Mentor Nucleus Platform Provides UI for Atmel (Page 10) Embedded Systems Design Europe - May 2008 - Mentor Nucleus Platform Provides UI for Atmel (Page 11) Embedded Systems Design Europe - May 2008 - Proffibus Advances IO-Link Integration (Page 12) Embedded Systems Design Europe - May 2008 - Altera Launches DO-254 Partner Network (Page 13) Embedded Systems Design Europe - May 2008 - Building an ‘Instant-Up’ Real-Time Operating Systems (Page 14) Embedded Systems Design Europe - May 2008 - Building an ‘Instant-Up’ Real-Time Operating Systems (Page 15) Embedded Systems Design Europe - May 2008 - Building an ‘Instant-Up’ Real-Time Operating Systems (Page 16) Embedded Systems Design Europe - May 2008 - Building an ‘Instant-Up’ Real-Time Operating Systems (Page 17) Embedded Systems Design Europe - May 2008 - An Architecture for Reusable Embedded Systems Software (Page 18) Embedded Systems Design Europe - May 2008 - An Architecture for Reusable Embedded Systems Software (Page 19) Embedded Systems Design Europe - May 2008 - An Architecture for Reusable Embedded Systems Software (Page 20) Embedded Systems Design Europe - May 2008 - An Architecture for Reusable Embedded Systems Software (Page 21) Embedded Systems Design Europe - May 2008 - Free up Bandwidth in PCI Express (Page 22) Embedded Systems Design Europe - May 2008 - Free up Bandwidth in PCI Express (Page 23) Embedded Systems Design Europe - May 2008 - Free up Bandwidth in PCI Express (Page 24) Embedded Systems Design Europe - May 2008 - Free up Bandwidth in PCI Express (Page 25) Embedded Systems Design Europe - May 2008 - Evaluating Software in Medical Devices (Page 26) Embedded Systems Design Europe - May 2008 - Evaluating Software in Medical Devices (Page 27) Embedded Systems Design Europe - May 2008 - Evaluating Software in Medical Devices (Page 28) Embedded Systems Design Europe - May 2008 - Evaluating Software in Medical Devices (Page 29) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 30) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 31) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 32) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 33) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 34) Embedded Systems Design Europe - May 2008 - Circuit Sensitivity in Analog Circuits (Page 35) Embedded Systems Design Europe - May 2008 - Choosing Flash Memory (Page 36) Embedded Systems Design Europe - May 2008 - Choosing Flash Memory (Page 37) Embedded Systems Design Europe - May 2008 - Choosing Flash Memory (Page 38) Embedded Systems Design Europe - May 2008 - Choosing Flash Memory (Page 39) Embedded Systems Design Europe - May 2008 - New Products (Page 40) Embedded Systems Design Europe - May 2008 - New Products (Page 41) Embedded Systems Design Europe - May 2008 - New Products (Page 42) Embedded Systems Design Europe - May 2008 - Advertising Contacts (Page 43) Embedded Systems Design Europe - May 2008 - Advertising Contacts (Page 44)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.