Home | | Embedded Systems | Embedded Operating System

Chapter: Embedded Systems

Embedded Operating System

Chapter Structure: Objectives 1. Introduction 2. Basics 2.1 Tasks 2.2 Task States 3. Scheduler 3.1 Scheduling Points 3.2 Ready List 3.3 Idle task 4. Context Switch 5. Task Synchronization 6. Real Time Characteristic 7. Selection Process

EMBEDDED OPERATING SYSTEM

 

Chapter Structure

 

Objectives

1. Introduction

2. Basics

2.1 Tasks

2.2 Task States

3. Scheduler

3.1 Scheduling Points

3.2 Ready List

3.3 Idle task

4. Context Switch

5. Task Synchronization

6. Real Time Characteristic

7. Selection Process

 

OBJECTIVES

After reading this chapter you will learn:

The basics of embedded Operating system with respect to

Tasks

Task States

Scheduler with respect to:

Scheduling Points

Ready List

Idle task

Concept of Context Switch and Task Synchronization

          Real Time Characteristic of embedded operating system.

1 INTRODUCTION

This chapter introduces the readers to the embedded operating system. Any operating system has a set of programs which are implemented through a set of tasks.

 

Every embedded system may not require an operating system. The requirement and complexity on an operating system depends on the functionality to be implemented by the embedded system.

 

2 BASICS

2.1 Tasks

 Task is a piece of code or program that is separate from another task and can be executed independently of the other tasks.

 

In embedded systems, the operating system has to deal with a limited number of tasks depending on the functionality to be implemented in the embedded system.

 

Multiple tasks are not executed at the same time instead they are executed in pseudo parallel i.e. the tasks execute in turns as the use the processor.

 

From a multitasking point of view, executing multiple tasks is like a single book being read by multiple people, at a time only one person can read it and then take turns to read it. Different bookmarks may be used to help a reader identify where to resume reading next time.

 

An Operating System decides which task to execute in case there are multiple tasks to be executed. The operating system maintains information about every task and information about the state of each task.

 

The information about a task is recorded in a data structure called the task context. When a task is executing, it uses the processor and the registers available for all sorts of processing. When a task leaves the processor for another task to execute before it has finished its own, it should resume at a later time from where it stopped and not from the first instruction. This requires the information about the task with respect to the registers of the processor to be stored somewhere. This information is recorded in the task context.

 

A C++ version of a Task that holds all information needed by operating system is as follows:

 

class Task

{

public:

Task(void (*function)(), Priority p, int stackSize);

 

TaskId id;

Context context;

TaskState state;

Priority priority;

int * pStack; Task * pNext;

 

void (*entryPoint)();

 

private:

static TaskId nextId;

};

 

2.2 Task States

In an operation system there are always multiple tasks. At a time only one task can be executed. This means that there are other tasks which are waiting their turn to be executed.

 

Depending upon execution or not a task may be classified into the following three states:

 

Running state - Only one task can actually be using the processor at a given time that task is said to be the “running” task and its state is “running state”. No other task can be in that same state at the same time

 

Ready state - Tasks that are are not currently using the processor but are ready to run are in the “ready” state. There may be a queue of tasks in the ready state.

 

Waiting state - Tasks that are neither in running nor ready state but that are waiting for some event external to themselves to occur before the can go for execution on are in the “waiting” state.

 


A transition of state between the ready and running state occurs whenever the operating system selects a new task to run.

 

The task that was previously in running state becomes ready and the new task is promoted to running state.

 

A task will leave running state only if it needs to wait for some event external to itself to occur before continuing.

 

A task's state can be defined as follows:

enum TaskState { Ready, Running, Waiting };

 

3 SCHEDULER

The heart and soul of any operating system is its scheduler.

 

This is the piece of the operating system that decides which of the ready tasks has the right to use the processor at a given time.

 

It simple checks to see if the running task is the highest priority ready task.

 

Some of the more common scheduling algorithms:

 

First-in-first-out

First-in-first-out (FIFO) scheduling describes an operating system which is not a multitasking operating system.

 

Each task runs until it is finished, and only after that is the next task started on a first come first served basis.

 

Shortest job first

 

Shortest job first scheduling uses algorithms that will select always select a task that will require the least amount of processor time to complete.

 

Round robin.

Round robin scheduling uses algorithms that allow every task to execute for a fixed amount to time.

 

A running task is interrupted an put to a waiting state if its execution time expires.

 

3.1 Scheduling Points

The scheduling points are the set of operating system events that result in an invocation of the scheduler.

 

There are three such events: task creation and task deletion. During each of these events a method is called to select the next task to be run.

 

A third scheduling point called the clock tick is a periodic event that is triggered by a timer interrupt. When a timer expires, all of the tasks that are waiting for it to complete are changed from the waiting state to the ready state.

 

3.2 Ready List

The scheduler uses a data structure called the ready list to track the tasks that are in the ready state.

 

The ready list is implemented as an ordinary linked list, ordered by priority.

 

So the head of this list is always the highest priority task that is ready to run.

 

3.3 Idle task

 

If there are no tasks in the ready state when the scheduler is called, the idle task will be executed.

 

The idle task looks the same in every operating system.

 

The idle task is always considered to be in the ready state.

 

4 CONTEXT SWITCH

 

The actual process of changing from one task to another is called Context Switch.

 

Since contexts are processor-specific, so is the code that implements the context switches, hence, it must always be written in assembly language.

 

 

5 TASK SYNCHRONIZATION

All the tasks in the multitasking operating systems work together to solve a larger problem and to synchronize their activities, they occasionally communicate with one another.

 

For example, in the printer sharing device the printer task doesn’t have any work to do until new data is supplied to it by one of the computer tasks.

 

So the printer and the computer tasks must communicate with one another to coordinate their access to common data buffers.

 

One way to do this is to use a data structure called a mutex.

 

Mutexes are mechanisms provided by many operating systems to assist with task synchronization.

 

A mutex is a multitasking-aware binary flag. It is because the processes of setting and clearing the binary flag are atomic (i.e. these operations cannot be interrupted).

 

When this binary flag is set, the shared data buffer is assumed to be in use by one of the tasks. All other tasks must wait until that flag is cleared before reading or writing any of the data within that buffer.

 

The atomicity of the mutex set and clear operations is enforced by the operating system, which disables interrupts before reading or modifying the state of the binary flag.

 

 

 

6 REAL TIME CHARACTERISTIC

 

An Operating system is called “Real-Time Operating System” (RTOS) only if it has following characteristics:

 

Deterministic

An OS is said to be deterministic if the worst case execution time of each of the system calls is calculable.

 

The data sheet of an OS should publish the real-time behavior of its RTOS provides average, minimum and maximum number of clock cycles required by each system call.

 

Interrupt Latency

 

Interrupt Latency is the total length of time from an interrupt signal’s arrival at the processor to the start of the associated interrupt service routine.

 

iii.Context Switch

 

Context Switch is important because it represents overhead across your entire system.

 

7 SELECTION PROCESS

 

The process of selecting the best commercial operating system that best fits the needs of one’s project depends on various factors.

 

Commercial operating systems form a continuum of functionality, performance and price.

Operating Systems that offer only a basic scheduler and a few other system calls are inexpensive and come with the source code that one can modify and do not require payment of royalties.

While on the other hand operating systems that include a lot of useful functionality beyond just the scheduler are quite expensive and royalties due on every copy shipped in ROM and they might also make a stronger guarantees about real-time performance.

 

Two important points to be considered while selecting an operating system :-

 

Put your processor, real time performance and budgetary requirements first.

 

Contact all of the vendors of the remaining operating systems for more detailed technical information.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Embedded Systems : Embedded Operating System |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.