ilovepdf_merged (6)
ilovepdf_merged (6)
6
Embedded System Design Concepts MODULE-2(BEC601)
SPECIFIC
2) Water pump: The water pump circulates water through the washing machine. It works in two
directions, re-circulating the water during wash cycle and draining the water during the spin
cycle
7
Embedded System Design Concepts MODULE-2(BEC601)
3) Tub: There are two types of tubs in the washing machine: inner and outer. The clothes are
loaded in the inner tub, where the clothes are washed, rinsed and dried. The inner tub has small
holes for draining the water. The external tub covers the inner tub and supports it during various
cycles of clothes washing.
8
Embedded System Design Concepts MODULE-2(BEC601)
Describes the system behavior with ‘States’, ‘Events’, ‘Actions’ and ‘Transitions’
An event is an input to the state. The event acts as stimuli for state transition.
A Finite State Machine (FSM) Model is one in which the number of states are
finite. In other words the system is described using a finite number of possible
states
Most of the time State Machine model translates the requirements into sequence
driven program
HCFSM uses state charts for capturing the states, transitions, events and actions.
The Harel State chart, UML State diagram etc are examples for popular state charts
used for the HCFSM modeling of embedded systems.
16
Embedded System Design Concepts MODULE-2(BEC601)
Requirement:
When the vehicle ignition is turned on and the seat belt is not fastened within 10
seconds of ignition ON, the system generates an alarm signal for 5 seconds. The
Alarm is turned off when the alarm time (5 seconds) expires or if the
driver/passenger fastens the belt or if the ignition switch is turned off, which ever
happens first.
The program instructions are iterated and executed conditionally and the data gets
transformed through a series of operations
Flow Charts is another important tool used for modeling sequential program
The FSM approach represents the states, events, transitions and actions, whereas the
Flow Chart models the execution flow
17
Embedded System Design Concepts MODULE-2(BEC601)
Requirement:
When the vehicle ignition is turned on and the seat belt is not fastened within 10
seconds of ignition ON, the system generates an alarm signal for 5 seconds.
The Alarm is turned off when the alarm time (5 seconds) expires or if the
driver/passenger fastens the belt or if the ignition switch is turned off, whichever
happens first.
18
Embedded System Design Concepts MODULE-2(BEC601)
Advantages:
Reduced Development time: Developer requires less or little
Knowledge on internal hardware details and architecture of the target processor/Controller.
Developer independency: The syntax used by most of the high level languages
are universal and a program written high level can easily understand by a second
person knowing the syntax of the language
Portability: An Application written in high level language for particular target
processor /controller can be easily be converted to another target
processor/controller specific application with little or less effort
Drawbacks:
• The cross compilers may not be efficient in generating the optimized target
processor specific instructions.
• Target images created by such compilers may be messy and non- optimized in
terms of performance as well as code size.
• The investment required for high level language based development tools (IDE) is
high compared to Assembly Language based firmware development tools.
25
Embedded System Design Concepts MODULE-2(BEC601)
26
Operating System Basics
• The operating system acts as a bridge between the user applications/tasks and the
underlying system resources
• The OS acts as a resource manager
• The primary functions of an operating system are:
• Make the system convenient to use
• Resource Management
The Kernel
The kernel is the core of the operating system and is responsible for managing the
system resources and the communication among the hardware and other system
services.
Kernel acts as the abstraction layer between system resources and user applications.
Kernel contains a set of system libraries and services.
For a general purpose OS, the kernel contains different services for handling the following:
• Process Management
• Primary Memory Management
• File System Management
• I/O System (Device) Management
• Secondary Storage Management
• Protection Systems
• Interrupt Handler
Process Management:
• Process management deals with managing the processes/tasks.
• Process management includes
• Setting up the memory space for the process
• Loading the process's code into the memory space
• Allocating system resources
• Scheduling and managing the execution of the process
• Setting up and managing the Process Control Block (PCB)
• Inter Process Communication and synchronisation
• Process termination/deletion, etc.
Task/Process Scheduling
Deals with sharing the CPU among various tasks/processes.
A kernel application called 'Scheduler' handles the task scheduling.
Scheduler is nothing but an algorithm implementation, which performs the efficient and
optimum scheduling of tasks to provide a deterministic behaviour.
Task/Process Synchronisation
Deals with synchronising the concurrent access of a resource, which is shared across
multiple tasks and the communication between various tasks.
Error/Exception Handling
Deals with registering and handling the errors occurred/exceptions raised during the
execution of tasks.
Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by zero,
unknown instruction execution, etc. are examples of errors/exceptions.
Errors/Exceptions can happen at the kernel level services or at task level.
Deadlock is an example for kernel level exception, whereas timeout is an example for
a task level exception.
The OS kernel gives the information about the error in the form of a system call (API).
Watchdog timer is a mechanism for handling the timeouts for tasks.
Memory Management
RTOS makes use of 'block' based memory allocation technique, instead of the usual
dynamic memory allocation techniques used by the GPOS.
RTOS kernel uses blocks of fixed size of dynamic memory and the block is allocated
for a task on a need basis.
The blocks are stored in a 'Free Buffer Queue’.
To achieve predictable timing and avoid the timing overheads, most of the RTOS
kernels allow tasks to access any of the memory blocks without any memory protection.
RTOS kernels assume that the whole design is proven correct and protection is
unnecessary.
Some commercial RTOS kernels allow memory protection as optional.
Interrupt Handling
Deals with the handling of various types of interrupts.
Interrupts provide Real-Time behaviour to systems.
Interrupts inform the processor that an external device or an associated task requires
immediate attention of the CPU.
Interrupts can be either Synchronous or Asynchronous.
Synchronous interrupts:
Occur in sync with the currently executing task.
Usually the software interrupts fall under this category.
Divide by zero, memory segmentation error, etc. are examples of synchronous
interrupts. For synchronous interrupts, the interrupt handler runs in the same context of
the interrupting task.
Memory Mapped Objects
• Memory mapped object is a shared memory technique adopted by certain Real-Time
Operating Systems for allocating a shared block of memory which can be accessed by
multiple process simultaneously.
• In this approach, a mapping object is created and physical storage for it is reserved and
committed.
• A process can map the entire committed physical area or a block of it to its virtual
address space.
• All read and write operation to this virtual address space by a process is directed to its
committed physical area.
• Any process which wants to share data with other processes can map the physical
memory area of the mapped object to its virtual memory space and use it for sharing
the data.
2. Message Passing
• Message passing is an (a)synchronous information exchange mechanism used for Inter
Process/Thread Communication.
• The major difference between shared memory and message passing technique is that,
through shared memory lots of data can be shared whereas only limited amount of
information/data is passed through message passing.
• Also, message passing is relatively fast and free from the synchronisation overheads
compared to shared memory.
• Based on the message passing operation between the processes, message passing is
classified into:
• Message Queue
• Mailbox
• Signalling
Message Queue
• 'Message queue’ is a First-In-First-Out (FIFO) queue which stores the messages
temporarily in a system defined memory object to pass it to the desired process.
• Usually the process which wants to talk to another process posts the message to a
message queue.
• Messages are sent and received through send and receive methods.
• send (Name of the process to which the message is to be sent, message)
• receive (Name of the process from which the message is to be received, message)
• The implementation of the message queue, send and receive methods are OS kernel
dependent.
Mailbox
• Mailbox is an alternate form of ‘Message queue’ and it is used in RTOS for IPC usually
for one way messaging.
• The task/thread which wants to send a message to other tasks/threads creates a mailbox
for posting the messages.
• The threads which are interested in receiving the messages posted to the mailbox by the
mailbox creator thread can subscribe to the mailbox.
• The thread which creates the mailbox is known as 'mailbox server' and the threads
which subscribe to the mailbox are known as 'mailbox clients’.
• The mailbox server posts messages to the mailbox and notifies it to the clients which
are subscribed to the mailbox.
• The clients read the message from the mailbox on receiving the notification.
Signalling
• Signalling is a primitive way of communication between processes/threads.
• Signals are used for asynchronous notifications where one process/thread fires a
signal, indicating the occurrence of a scenario which the other process(es)/thread(s) is
waiting.
• Signals are not queued and they do not carry any data.
• E.g. Communication mechanisms used in RTX51 Tiny OS, inter process
communication in VxWorks OS Kernel are examples for signalling.
3. Remote Procedure Call (RPC) and Sockets
• Remote Procedure Call (RPC) is the Inter Process Communication (IPC) mechanism
used by a process to call a procedure of another process running on the same CPU or
on a different CPU which is interconnected in a network.
• In the object oriented language terminology, RPC is also known as Remote Invocation
or Remote Method Invocation (RMI).
• RPC is mainly used for distributed applications like client-server applications.
• With RPC it is possible to communicate over a heterogeneous network (i.e.
Network where Client and server applications are running on different operating
systems). The CPU/process containing the procedure which needs to be invoked
remotely is known as server.
• The CPU/process which initiates an RPC request is known as client.
EMBEDDED SYSTEM HARDWARE:
Embedded systems can control many different devices, from small sensors found on a production
line, to the real-time control systems used on a NASA space probe. All these devices use a
combination of software and hardware components.
The following Figure shows a typical embedded device based on an ARM core. Each box
represents a feature or function. The lines connecting the boxes are the buses carrying data.
page: 7
Figure: ARM Core dataflow Model
The arrows represent the flow of data, the lines represent the buses, and the boxes represent
either an operation unit or a storage area.
page: 16
REGISTERS:
General-purpose registers hold either data or an address. They are identified
with the letter r prefixed to the register number. For example, register 4 is
given the label r4. The Figure shows the active registers available in user
mode. (A protected mode is normally used when executing applications).
The processor can operate in seven different modes.
All the registers shown are 32 bits in size.
There are up to 18 active registers:
o 16 data registers and 2 processor status registers.
o The data registers visible to the programmer are r0 to r15.
The ARM processor has three registers assigned to a particular task or special function:
r13, r14,and r15. They are given with different labels to differentiate them from the
other registers.
o Register r13 is traditionally used as the stack pointer (sp) and stores the head of
the stack in the current processor mode.
o Register r14 is called the link register (lr) and is where the core puts the return
addresswhenever it calls a subroutine.
o Register r15 is the program counter (pc) and contains the address of the next
instructionto be fetched by the processor.
In ARM state the registers r0 to r13 are orthogonal—any instruction that you can apply
to r0 youcan equally well apply to any of the other registers.
In addition to the 16 data registers, there are two program status registers: cpsr (current
programstatus register) and spsr (saved program status register)
CURRENT PROGRAM STATUS REGISTER:
The ARM core uses the cpsr to monitor and control internal operations. The cpsr is a dedicated 32-bit
register and resides in the register file. The following Figure shows the basic layout of a generic program
status register. Note that the shaded parts are reserved for future expansion.
page: 17