Scheduler Configuration The Scheduler

84 Chapter 5 • The Kernel Option Name Scheduler Timeslicing CDL Name CYGSEM_KERNEL_SCHED_TIMESLICE Description Enables timeslicing mode for the multilevel queue scheduler. The scheduler checks to determine if another thread at the same priority level is ready to run. If so, a context switch will take place after the timeslice period, selectable as a suboption in clock ticks between timeslices, expires. This option is enabled by default for the multilevel queue scheduler. Another suboption allows timeslicing to be dynamically enabled or disabled on a per-thread basis. Option Name Enable ASR Support CDL Name CYGSEM_KERNEL_SCHED_ASR_SUPPORT Description Controls Asynchronous Service Routine ASR support, which is a function called from the scheduler when it has exited the scheduler lock. This is typically used by compatibility layer packages, such as POSIX.

5.2 Summary

In this chapter, we looked at the functionality provided by the core of eCos, the kernel. We examined the kernel startup procedure. We also looked at the two scheduling algorithms available for the eCos kernel: bitmap and multilevel queue. 85 C H A P T E R 6 Threads and Synchronization Mechanisms he previous chapter on the eCos kernel provided us with an understanding of how the differ- ent schedulers handle threads and their associated priority levels. In this chapter, we start by covering threads; specifically, how we configure the operation of threads, and how we create and use threads in an application. Building on this, we then cover different mechanisms available for communication between threads and other elements of a typical embedded system. These synchronization mech- anisms provide standard tools for developing robust applications.

6.1 Threads

A thread is a single flow of execution through a program. Multiple threads can exist in a pro- gram, allowing an individual thread to perform its own operations on the system. Each thread defined in the eCos system contains its own context or workspace to perform its operations and a priority level to execute. It is the job of the scheduler to determine which thread is enti- tled to run at any given time. The kernel contains API functions for controlling threads within an application. eCos offers configuration options that control the behavior of threads in the system, as well as providing additional features to support various thread operations. Item List 6.1 details the thread configuration options available. These are located under the Thread-Related Options component within the eCos Kernel package. T