Sunteți pe pagina 1din 7

Advanced Embedded System

Design
Project Report

Submitted to
Dr Awais M. Kamboh











Group members
Syed Akhlaq Hussain
Ayyaz Akhtar
1


1 Introduction to RTOS

Real time operating system is an operating system that processes the time critical tasks, manages
system resources and provide base for application development. As shown in figure 1, the real time
kernel sits between the hardware and the application program. There are several applications in
which time constraints are present and violation of these constraints results in severe
consequences. [1]

Figure 1 - RTOS interface with hardware and application
In real time embedded systems, performance of the system is not only dependent on the accurate
result of the computation but also the time instant on which that result was produced. RTOS
provides kernel mechanism to handle tasks with explicit time constraints. As the complexity of code
increases, the use of operating system becomes inevitable. Real time operating system allows
embedded software application to be designed, scaled, tested and debugged easily. In case of
application developed around RTOS, complex code is divided into simple modules/tasks with
independent stack resource. [2]
The basic services of RTOS include Task Management Services, Event Management Services,
Interrupt Management Services, Resource Management Services, Memory Management Services,
Inter Task communication and synchronization. RTOS can be characterized as soft RTOS and hard
RTOS. Soft RTOS usually meets its deadlines but time constraints are not very critical and reduction
in system quality is acceptable whereas hard RTOS can meet a deadline deterministically and
degree of tolerance for missed deadlines is extremely small or zero [2].
2 FreeRTOS:
FreeRTOS is a free and open source Real-Time Operating system written by Real Time Engineers
Ltd. It has been developed for small scale embedded systems and provides a very simple set of
functions.
FreeRTOS is a market leading real time operating system (RTOS) that supports about 34 different
architectures. In an year about 107000 downloads are registered. FreeRTOS is professionally
2

written, open source, with strictly quality controlled procedures, very robust and widely supported
RTOS.
3 Key features
FreeRTOS provides the following useful features:
Free RTOS kernel - preemptive, cooperative and hybrid configuration options.
The SafeRTOS derivative product provides a high level of confidence in the code integrity.
Includes a tickless mode for low power applications.
Tiny footprint.
Official support for >30 embedded system architectures (counting ARM7 and ARM Cortex-
M3 as one architecture each).
FreeRTOS-MPU supports the ARM Cortex-M3 Memory Protection Unit (MPU).
Designed to be small, simple and easy to use. Typically a RTOS kernel binary image will be in
the region of 4K to 9K bytes.
Very portable source code structure, predominantly written in C.
Supports both real time tasks and co-routines.
Queues, binary semaphores, counting semaphores, recursive semaphores and mutexes for
communication and synchronization between tasks, or between real time tasks and
interrupts.
Innovative event group (or event flag) implementation.
Mutexes with priority inheritance.
Efficient software timers.
Powerful execution trace functionality.
Stack overflow detection options.
Pre-configured RTOS demo applications for selected single board computers allowing 'out of
the box' operation and fast learning curve.
Free monitored forum support, or optional commercial support and licensing.
No software restriction on the number of real time tasks that can be created.
No software restriction on the number of task priorities that can be used.
No restrictions imposed on task priority assignment - more than one real time task can be
assigned the same priority.
Free development tools for many supported architectures.
Free embedded software source code.
Royalty free.
Cross development from a standard Windows host.



3

4 Porting

FreeRTOS is designed to be small and simple. The kernel itself consists of only three or four C files.
To make the code readable, easy to port, and maintainable, it is written mostly in C, but there are a
few assembly functions included where needed (mostly in architecture-specific scheduler routines).
FreeRTOS provides methods for multiple threads or tasks, mutexes, semaphores and software
timers. A tick-less mode is provided for low power applications. Thread priorities are supported. In
addition there are four schemes of memory allocation provided:
Allocate only.
Allocate and free with a very simple, fast, algorithm.
A more complex but fast allocate and free algorithm with memory coalescence.
C library allocate and free with some mutual exclusion protection.
There are none of the more advanced features typically found in operating
systems like Linux or Microsoft Windows, such as device drivers, advanced memory management,
user accounts, and networking. The emphasis is on compactness and speed of execution. freeRTOS
can be thought of as a 'thread library' rather than an 'operating system', although command line
interface and POSIX-like IO abstraction add-ons are available.
freeRTOS implements multiple threads by having the host program call a thread tick method at
regular short intervals. The thread tick method switches tasks depending on priority and a round-
robin scheduling scheme. The usual interval is 1/1000 of a second to 1/100 of a second, via an
interrupt from a hardware timer, but this interval is often changed to suit a particular application.
The download contains prepared configurations and demonstrations for every port and compiler,
allowing rapid application design. The FreeRTOS.org site also contains lots of documentation and
RTOS tutorials (additional manuals and tutorials available for a fee starting from USD25), details of
the RTOS design.

4


Figure 2 - RTOS Architecture

Figure 2 shows FreeRtoss architecture and its relationship with the hardware. The user is
responsible for providing the Application Software and the FreeRtos Configuration sections.
The user also needs to either obtain a copy of a port for the processor he intends to use or,
write one himself, if the desired processor port is not available. For PSOC 5 the port is
available.
Demo Application:

Figure 3 - Application Diagram



5

Explanation:
Task 1 and 2 both need to access UART and Task 3 and 4 need to use LCD. Priorities are assigned on
the basis of period of the task, as shown in table 1.

Task Name Assigned Priority
Task 1 2
Task 2 2
Task 3 1
Task 4 1

In order to achieve synchronization and protection the shared resources, i.e UART and LCD
semaphores are used.
We have used two semaphores that control access to the two physical resources i.e. the LCD and
the UART, the switching in between these tasks is based on the priority the two tasks that use the
LCD have the same priority while the two tasks that use the UART have the same priority.
Once the execution of all the tasks starts task 1 and task 2 compete to access some shared resource
one of these task gets a lock while the other one goes into a wait state. The LCD displays which task
has acquired the lock and which task has been denied the access to the shared resource.
The other two tasks are competing for the resource UART they both are connected to a pc via a
serial connection, the output on the pc is monitored to see the progress. Both of these tasks have
the same priority hence when the execution starts one of them gets access to the uart while the
other one waits till its execution is completed if semaphores are not used then in that case the
scheduler keeps shifting between the two tasks, which results in an ambiguous output at the UART.









6




References:

1. http://www.ti.com/lit/wp/spry238/spry238.pdf
2. http://www.freertos.org/about-RTOS.html
3. http://www.freertos.org/
4. http://en.wikipedia.org/wiki/FreeRTOS
5. http://aosabook.org/en/freertos.html
6. http://www.freertos.org/FreeRTOS-port-and-demo-for-Cypress-PSoC5-CY8C5588-Cortex-
M3.html

S-ar putea să vă placă și