Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CHAPTE R 3

RTOS Concepts and Definitions

3.1 Introduction
The purpose of this chapter is to review some of the essential concepts and definitions
used in embedded systems. You have already encountered several of these terms in
previous chapters,
Buy this file and you will read about several new concepts here.
from http://www.download-it.org/learning-resources.php?promoCode=&partnerID=&content=story&storyID=1296

3.2 Priorities
Most embedded real-time systems use a priority system as a means of establishing the
relative importance of threads in the system. There are two classes of priorities: static and
dynamic. A static priority is one that is assigned when a thread is created and remains
constant throughout execution. A dynamic priority is one that is assigned when a thread
is created, but can be changed at any time during execution. Furthermore, there is no limit
on the number of priority changes that can occur.
ThreadX provides a flexible method of dynamic priority assignment. Although each
thread must have a priority, ThreadX places no restrictions on how priorities may be
used. As an extreme case, all threads could be assigned the same priority that would
never change. However, in most cases, priority values are carefully assigned and modified
only to reflect the change of importance in the processing of threads. As illustrated by
Figure 3.1, ThreadX provides priority values from 0 to 31, inclusive, where the value 0
represents the highest priority and the value 31 represents the lowest priority.1

1
The default priority range for ThreadX is 0 through 31, but up to 1024 priority levels can be used.

w w w.ne w nespress.com

Buy this file from http://www.download-it.org/learning-resources.php?promoCode=&partnerID=&content=story&storyID=1296


22 Chapter 3

Priority
Meaning
value

Highest
0
priority

Lowest
31
priority

Figure 3.1: Priority values

3.3 Ready Threads and Suspended Threads


ThreadX maintains several internal data structures to manage threads in their various
states offile
Buy this execution. Among these data structures are the Suspended Thread List and the
from http://www.download-it.org/learning-resources.php?promoCode=&partnerID=&content=story&storyID=1296
Ready Thread List. As implied by the nomenclature, threads on the Suspended Thread
List have been suspended—temporarily stopped executing—for some reason. Threads on
the Ready Thread List are not currently executing but are ready to run.
When a thread is placed in the Suspended Thread List, it is because of some event or
circumstance, such as being forced to wait for an unavailable resource. Such a thread
remains in that list until that event or circumstance has been resolved. When a thread is
removed from the Suspended Thread List, one of two possible actions occurs: it is placed
on the Ready Thread List, or it is terminated.
When a thread is ready for execution, it is placed on the Ready Thread List. When
ThreadX schedules a thread for execution, it selects and removes the thread in that list
that has the highest priority. If all the threads on the list have equal priority, ThreadX
selects the thread that has been waiting the longest.2 Figure 3.2 contains an illustration of
how the Ready Thread List appears.
If for any reason a thread is not ready for execution, it is placed in the Suspended Thread
List. For example, if a thread is waiting for a resource, if it is in “sleep” mode, if it was

2
This latter selection algorithm is commonly known as First In First Out, or FIFO.

w ww. n e w n e s p r e s s .c o m

Buy this file from http://www.download-it.org/learning-resources.php?promoCode=&partnerID=&content=story&storyID=1296


Chapter extract

To buy the full chapter, and for copyright


information, click here
http://www.download-it.org/learning-resources.php?promoCode=&partnerID=&content=story&storyID=1296

The publisher detailed in the title page holds the copyright for this document

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted,
in any form or by any means, electronic, mechanical, photocopying, recorded or otherwise, without the written
permission of Spenford IT Ltd who are licensed to reproduce this document by the
publisher

All requests should by sent in the first instance to

rights@download-it.org

Please ensure you have book-marked our website.

www.download-it.org

You might also like