Symmetric Multi-Processing Support Prentice.Hall – Embedded.Software.Development.with.eCos

Additional Features 183 The startup sequence is different on SMP systems. A single CPU, called the primary, han- dles the startup initialization sequence, while the other CPUs, called secondary, are either placed in a suspended state or put into an idle loop by the HAL. After the application calls cyg_scheduler_start, the secondary CPUs are initialized. One major issue in an SMP system is the ability for the kernel to protect its data structures from concurrent accesses. This is easily accomplished in a single-processor system by disabling interrupts. However, in a system with multiple CPUs, disabling interrupts on one CPU does not block another CPU from accessing the data structures. When the kernel is operating in a single-processor system, accesses to the kernel data structures are blocked using the scheduler lock. The scheduler lock is implemented as a simple counter that is atomically incremented to acquire the lock and decremented to release the lock. When the value of the lock counter is zero, the scheduler is allowed to selected a different thread to run. Since ISRs can be serviced while the scheduler is locked, certain kernel functions can only be called from certain operating contexts. Additional information about the scheduler for single-processor systems can be found in The Scheduler section of Chapter 5, The Kernel. For SMP systems, a kernel-locking mechanism is needed that does not rely on interrupt manipulation. This special synchronization mechanism is called a spinlock. Spinlocks are pro- vided for SMP systems, although the other synchronization mechanisms work in SMP systems as well. Spinlocks are covered in Chapter 6, Threads and Synchronization Mechanisms. In addition, functions have been added for interrupt processing in SMP systems. One of these functions allows routing of interrupts to a specific CPU in the system. The other function enables you to find out which interrupts in the system are handled by which CPUs. Detailed information about these, and other interrupt function calls can be found in Chapter 3, Exceptions and Interrupts .

8.10 Additional Features

Now that we have covered some of the major additional functionality available for use in the eCos system, let’s take a quick look at some other additional features support by eCos. This sec- tion is intended to make you aware of some of the other features supported by eCos; however, the details of operation for these packages are omitted. The dynamic loader allows Executable and Linking Format ELF file images to be loaded onto a target during run time. After the new ELF image is loaded, the running application can call functions located in the new image. The dynamic loader package CYGPKG_LOADER is located in the services\loader directory. The zlib package is a general-purpose compressiondecompression library widely known in the software community. It provides in-memory compression and decompression functions that are thread safe and include integrity checks of the uncompressed data. Reading and writing of files in gzip format, with interface functions similar to stdio, is also supported by the zlib library. The zlib package CYGPKG_COMPRESS_ZLIB contains a port of zlib to eCos and is contained in the services\compress\zlib directory. Additional information about the zlib library can be found online at: 184 Chapter 8 • Additional Functionality and Third-Party Contributions www.gzip.orgzlib eCos provides support for the Microwindows Graphical User Interface GUI. Microwin- dows is an open-source project focused on allowing the features of modern graphical windowing interfaces to be run on smaller devices. The Microwindows package CYGPKG_MICROWINDOWS is located under the services\gfx\mw directory. Additional information about Microwin- dows is provided under the doc directory within the package as well as online at: www.microwindows.org A generic power management package is also provided by eCos. This package provides a framework that allows the incorporation of additional power management facilities in an embedded system. The power management package CYGPKG_POWER is located in the services\power directory. Additional information about the power management package is contained in the doc directory within the package.

8.11 Summary

In this chapter, we took a brief look at some of the additional features provided in the eCos sys- tem and by third-party contributors that can be included within an application. These additional features extend eCos’ core functionality, allowing eCos to meet the requirements of a wider range of embedded systems. Now that you are aware of these features, with some additional investigation they can quickly be incorporated into your system. References Sakamura, Ken. µITRON 3.0, An Open and Portable Real-Time Operating System for Embedded Systems. IEEE Computer Society Press, 1997. Stevens, W. Richard. TCPIP Illustrated, Volume 1: The Protocols. Addison-Wesley, 1994. McKusick, Marshall Kirk, and Keith Bostic. The Design and Implementation of the 4.4BSD Operating System. Addison-Wesley Longman, Inc., 1996.