You are on page 1of 23

MODULE 5

LINUX
Features of Linux
Linux is a free and open-source operating system that has been in use since the early 1990s. It is
known for its stability, security, and flexibility, which have made it the preferred choice for
servers, supercomputers, and other computing systems. The following are some of the key
features that make Linux a popular choice:
1. Open Source: Linux is an open-source operating system, which means that its source
code is available for free and can be modified and redistributed by anyone. This has led
to a large community of developers who work together to improve and enhance the
software.

2. Customizability: One of the key features of Linux is its customizability. Users can
modify the operating system to suit their specific needs and preferences. This can be done
by changing the kernel, installing different desktop environments, or using a different
package manager.

3. Stability: Linux is known for its stability and reliability. It has a reputation for being able
to run for long periods of time without crashing or needing to be rebooted. This is due to
the fact that the operating system is designed to be robust and able to handle a wide range
of workloads.

4. Security: Linux is known for its security features. It is less susceptible to viruses and
malware than other operating systems due to its design and the fact that it is open source.
Security updates are released frequently, and users can configure the system to be as
secure as they need it to be.

5. Compatibility: Linux is compatible with a wide range of hardware and software. It


supports a wide range of file formats, and users can easily access and use files from other
operating systems.

6. Multitasking: Linux is designed to support multitasking, which means that it can run
multiple programs simultaneously without affecting performance. This is essential for
servers and other high-performance computing systems.

7. Command Line Interface: Linux has a powerful command line interface that allows users
to perform a wide range of tasks quickly and efficiently. This is essential for system
administrators and developers who need to automate tasks or perform complex
operations.

8. Package Management: Linux has a package management system that makes it easy to
install, update, and remove software. Users can choose from a wide range of software
packages that are available in online repositories.
9. Community Support: Linux has a large and active community of developers and users
who provide support and assistance to new users. This community is an invaluable
resource for anyone who is new to Linux or needs help with a particular issue.

Linux has several features in its scheduling system that allow it to efficiently allocate CPU
resources among competing processes. Here are some of the key features of Linux in scheduling:

1. Completely Fair Scheduler (CFS): The CFS is the default scheduling algorithm in Linux,
and it provides fair allocation of CPU time among all running processes. The CFS uses a
virtual runtime mechanism to ensure that each process gets its fair share of CPU time.

2. Real-time scheduling: Linux also supports real-time scheduling for processes that require
deterministic timing behavior. The real-time scheduler provides high-priority processes
with guaranteed access to the CPU, even when other processes are running.

3. Process priorities: Linux assigns each process a priority value that determines how much
CPU time it receives. The priority value ranges from -20 to 19, with -20 being the highest
priority and 19 being the lowest.

4. Control groups (cgroups): Linux cgroups allow administrators to group processes


together and set resource limits for each group. This makes it possible to prioritize certain
groups of processes and ensure that they get the resources they need.

5. Kernel preemption: Linux has a preemptive kernel that can preempt running processes in
favor of higher-priority processes. This ensures that critical processes get the CPU time
they need.

6. Load balancing: Linux uses load balancing algorithms to distribute processes across CPU
cores, ensuring that each core is utilized efficiently.

Overall, Linux’s scheduling features make it a powerful operating system for multi-tasking and
real-time applications.
FREERTOS
Features Of FreeRTOS
1. Highly configurable kernel.
2. Easy to use APIs for creating, configuring, and scheduling tasks.
3. Mutex and Semaphore for synchronization.
4. Support for thread-safe message queues.
5. Software timers.
6. Event groups to notify the occurrence of an event.
7. Memory management to maintain heap memory.
8. Designed to be small, simple and easy to use.
The Architecture of FreeRTOS.
 FreeRTOS is an open source real-time operating system (RTOS) for embedded
systems. FreeRTOS supports many different architectures and compiler toolchains, and is
designed to be "small, simple, and easy to use".
 Like all operating systems, FreeRTOS's main job is to run tasks. Most of FreeRTOS's
code involves prioritizing, scheduling, and running user-defined tasks. Unlike all
operating systems, FreeRTOS is a real-time operating system which runs on embedded
systems .
 FreeRTOS is a relatively small application. The minimum core of FreeRTOS is only
three source (.c) files and a handful of header files, totalling just under 9000 lines of
code, including comments and blank lines. A typical binary code image is less than
10KB.
 FreeRTOS's code breaks down into three main areas: tasks, communication, and
hardware interfacing.
 Tasks: Almost half of FreeRTOS's core code deals with the central concern in many
operating systems: tasks. A task is a user-defined C function with a given
priority. tasks.c and task.h do all the heavy lifting for creating, scheduling, and
maintaining tasks.
 Communication: Tasks are good, but tasks that can communicate with each other are
even better! Which brings us to the second FreeRTOS job: communication. About 40%
of FreeRTOS's core code deals with communication. queue.c and queue.h handle
FreeRTOS communication. Tasks and interrupts use queues to send data to each other
and to signal the use of critical resources using semaphores and mutexes.
 The Hardware Whisperer: The approximately 9000 lines of code that make up the base
of FreeRTOS are hardware-independent; the same code runs whether FreeRTOS is
running on the humble 8051 or the newest, shiniest ARM core. About 6% of FreeRTOS's
core code acts a shim between the hardware-independent FreeRTOS core and the
hardware-dependent code.
PSOS

• pSOS (Portable Software On Silicon) is a real-time operating system (RTOS), created in

about 1982 by Alfred Chao, and developed/marketed for the first part of its life by his

company Software Components Group (SCG)

• In the 1980s pSOS rapidly became the RTOS of choice for all embedded systems based

on the Motorola 68000 family architecture, because it was written in 68000 assembler

and was highly optimised from the start

• It was also modularised, with early support for OS-aware debugging, plug-in device

drivers, TCP/IP stacks, language libraries and disk subsystems. Later came source-

level debugging, multi-processor support and further networking extensions.

• Since it was establish for use in small to middle sized embedded applications, PSOS Does

not support virtual memory but supports digressive memory superintendence instead

• Hence it defines a memory region as a physically bordering memory block that is designed

by the operating system as a recognition to the applications call

• A programmer can efficiently designate a task to the memory region.

• PSOS is widely used in embedded applications and is a host target type of RTOS

• It isused in numerous commercial embedded products like cell phone system base

stations
• PSOS supports 32 priority levels that are assigned to tasks

• . It supports priority ceiling protocols and inheritance for sharing critical resources

among its real-time tasks.

• PSOS BASED DEVELOPMENT OF EMBEDDED SOFTWARE

• FEATURES
• Preemptive multitasking:pSOS supports preemptive multitasking, which means that the
operating system can switch between different tasks without the need for explicit
cooperation from the tasks themselves. This allows for more efficient use of system
resources and can help ensure that critical tasks are completed on time.
• Memory management:pSOS provides memory management features that allow tasks to
allocate and free memory dynamically. This helps to prevent memory fragmentation and
can improve the reliability and stability of the system.
• Task synchronization:pSOS provides several mechanisms for tasks to synchronize with
each other, such as semaphores, message queues, and event flags. These mechanisms
help to prevent race conditions and ensure that tasks can cooperate effectively.
• Interrupt handling:pSOS provides a flexible interrupt handling mechanism that allows
interrupt service routines (ISRs) to be written in C or assembly language. This allows
developers to write efficient ISRs that can respond quickly to system events.
• Low overhead:pSOS has a small memory footprint and low overhead, making it suitable
for use in resource-constrained embedded systems.

• ARCHITECTURE
• PSOS+ Real-time Multitasking Kernel: A multitasking kernel that provides a
responsive, efficient mechanism for coordinating the activities of your real-time system.
• PSOS+ Multiprocessor Multitasking Kernel: to operate seamlessly across multiple,
tightly-coupled or distributed processors.
• PNA+ TCP/IP Network Manager: A complete TCP/IP implementation including
gateway routing.
• PRPC+ Remote Procedure Call Library:pRPC+ is a high-performance, open-source
remote procedure call (RPC) library. It is designed to enable efficient communication
between distributed systems, providing low latency and high throughput.
• PHILE+ File System Manager: Gives efficient access to mass storage devices, both
local and on a network.
• PREPC+ ANSI C Standard Library: Provides familiar ANSI C (standardized version of
the c programming language) runtime functions such as printf(), scanf(), and so in the
target environment.
• pROBE+ : It is a powerful RTOS debugging tool that can help developers identify and
resolve issues in their embedded software quickly and efficiently.



APPLICATION

• As an application example, let's take the pSOS+m operating system-the name denotes

this is the multiprocessing version of the RTOS-running on a Trimedia VLIW media

processor.

• This VLIW processor targets high-performance multimedia applications ranging from

videophones, video editing system s, digital TV, security systems and set-top boxes to

reprogrammable, multipurpose plug-in cards for PCs.


• It implements such standards as MPEG-1 and MPEG-2, and its DSP-based CPU

implements a variety of multimedia algorithms.

• The VLIW processor is a fluid computer system controlled by the real-time kernel of the

small-footprint pSOS+m operating system.

• Aside from the DSP CPU core, the VLIW processor includes a high-bandwidth internal

bus and internal bus-mastering DMA peripherals.

• The pSOS+m kernel views applications as a collection of tasks, I/O device drivers

and interrupt service routines (ISRs).

• It consists of various system calls that can be used by an embedded application.

• These system calls provide functionality for task management, semaphores, message

queues, dynamic memory allocation, time management, I/O functions, event macros,

asynchronous signals and fatal-error handling.

• Services provided by pSOS form the basis of the Trimedia Software Streaming

Architecture.

• The kernel provides the syst em designer with concurrent and independent task execution

by switching between tasks on queues generated by system calls made to the kernel.

• Industrial automation:pSOS is used in industrial automation systems to control and


monitor manufacturing processes.
• Aerospace and defense:pSOSis used in avionics and defense systems where reliability
and real-time performance are critical.
• Medical devices:pSOS is used in medical devices such as patient monitoring systems and
diagnostic equipment.
• Automotive systems:pSOS is used in automotive systems such as engine control units and
navigation systems.
• Consumer electronics:pSOS is used in various consumer electronics devices such as
digital cameras and smart home devices.
• Overall, pSOS is a versatile RTOS that is used in a wide range of embedded systems
applications where real-time performance and reliability are critical.
VRTX (Versatile Real-Time Executive)
VRTX, short for Versatile Real-Time Executive, is an operating system developed by Honeywell
Information Systems. It was designed to provide real-time control for industrial processes, as
well as for scientific and engineering applications.
VRTX is characterized by its ability to perform a variety of tasks simultaneously, while
providing fast response times to real-time events.
• VRTX is an OS that is compliant with POSIX-RT and is certified by the US Federal
Aviation Agency for use in life- and mission-critical applications like avionics
• It is offered as two multitasking kernels,VRTXmc and VRTXsa
• VRTXsa supports virtual memory and is used for medium- and large-sized applications
• Its library is POSIX compliant and it supports priority inheritance.
• VRTXmc is optimized for ROM and RAM sizes and power consumption.
• It features a small footprint and it requires 1 KB of RAM and 4 to 8 KB of ROM
• It does not support virtual memory because it is designed for embedded applications like
cell phones and computer-based toys among other small hand devices.
Some of its notable features and applications include:
1. Real-time capabilities: VRTX is designed to provide real-time response to events, which
makes it suitable for applications where timing is critical, such as in industrial control
systems, robotics, and medical equipment.
2. Multi-tasking: VRTX allows multiple tasks to run simultaneously, making it suitable for
applications that require multitasking capabilities, such as data acquisition and
processing.
3. Memory protection: VRTX provides memory protection, which prevents one task from
interfering with the memory used by another task, ensuring system stability and
reliability.
4. Pre-emptive scheduling: VRTX uses pre-emptive scheduling, which means that the
operating system can interrupt a task to execute another task that has higher priority.
5. Device drivers: VRTX includes device drivers that allow the operating system to
communicate with various hardware components, including input/output (I/O) devices,
such as sensors and actuators.
6. Portability: VRTX is portable and can be run on various hardware platforms, including
embedded systems, microcontrollers, and personal computers.
7. Applications: VRTX is used in a variety of applications, including aerospace and
defence, industrial automation, medical equipment, and telecommunications.
8. Scalable OS
9. Preemptive or time slicing scheduling used
10. RTOS hierarchy
11. Schedules ISR seperately and has special functions for interrupt handling
12. System level functions
13. Task service functions
14. Task delay and delay cum suspending function
15. Shared memory allocation functions
16. Uses semaphores
17. Provides IPC through pipe,queue etc
18. Scheduler design features are compatible with POSIX

Overall, VRTX is a reliable and efficient real-time operating system that provides a range of
features and capabilities for real-time applications. Its ability to multitask, provide memory
protection, and support various hardware platforms makes it a popular choice in many industries.
ARCHITECTURE OF THE VERSATILE REAL-TIME EXECUTIVE
The architecture of the Versatile Real-Time Executive (VRTX) can be divided into two main
components: the kernel and the optional modules.
The VRTX kernel provides the basic services required by real-time applications, including task
scheduling, inter-task communication, synchronization, and interrupt handling. The kernel is
responsible for managing the execution of tasks and ensuring that they have access to the system
resources they need. It does this by maintaining a list of all tasks that are currently active and
scheduling them based on their priority levels.
VRTX also includes a set of device drivers that allow it to interact with external devices such as
disk drives, printers, and displays. These drivers provide an interface between the VRTX kernel
and the hardware, allowing tasks to access external resources as needed.
In addition to the kernel and device drivers, VRTX includes a number of optional modules that
can be added as needed to provide additional functionality. These modules include a file system,
a network stack, a graphics library, and a user interface toolkit.
The file system module provides a way for tasks to access and manipulate files stored on disk or
other storage media. The network stack module provides support for network communication,
allowing tasks to communicate with other devices over a network. The graphics library and user
interface toolkit modules provide tools for creating graphical user interfaces (GUIs) that can be
used to interact with the system.
Overall, the architecture of VRTX is highly modular and flexible, allowing it to be customized to
meet the specific needs of a wide range of real-time applications. Its kernel-based design
provides a high degree of control over system resources and task scheduling, making it well-
suited for applications that require precise timing and responsiveness.
RTLinux

• Here RTLinux is a Hard Real-Time Operating System Microkernel that runs the

entire Linux operating system as a fully preemptive process

• Even with a similar name, it is not relevant to the Real-Time Linux.

• It is operating on a Linux System

 The Real-Time Kernel set the Linux is working on a Linux system. RTLinux is hard
real-time RTOS a microkernel that runs the entire Linux operating system as a fully
preemptive process.
 It was developed by Victor Yodaiken, Free version Michael Barabanov and others at the
New Mexico Institute of Mining and Technology and then as a commercial product at
FSMLabs.
 FSMLabs has two editions of RTLinux.
 RTLinux pro and RTLinux free. RTLinux pro is the priced edition and RTLinux is the
open source release.
 RTLinux support hard real time applications, the Linux kernel has been modified by
adding a layer of software between the hardware and the Linux kernel. This additional
layer is called "virtual machine".
 A foot print of 4MB is required RTLinux.
 The new layer, RTLinux layer has a separate task scheduler. This task scheduler assigns
lowest priority to the standard Linux kernel. Any task that has to met real-time
constraints will run under RTLinux.
 Interrupts from Linux are disabled to achieve real-time performance.
DIFFERENCE BETWEEN LINUX AND RT LINUX
Linux RTLinux

 Linux is not a hard real time  RTLinux supports hard it.Coreal-


system/ide time applications.

 The tasks, which do not have any  Any task that has real-time
time constraints. constraints will run under RTLinux.

In RTLinux location of the various files are:


 RTLinux will be installed in the directory /usr/rtlinux-xxx, where xxx is the version
name.
 /usr/rtlinux/include contains all the include files necessary for development project.
 /usr/doc/rtlinux/man contains the manual pages for the RTLinux.
 /usr/rtlinux/modules contains the core RTLinux modules

The two important aspects while doing programming in RTLinux are:


 By default, the RTLinux tasks do not have access to the computer's floating points unit.
Hence need to explicitly set the permissions for every RTLinux task.
 Cannot pass arguments from the command prompt.

RTLINUX MODULES

 RTLinux programs are not created as stand-alone units, they are created as modules,
which are loaded into the Linux kernel space.
 The C source files are compiled into objects files using the gcc command with the
argument -c flag. In the C file, the main() function gets replaced with the following lines:
 Int init_module()
 Void cleanup_module();
 Init_module is called when the module is first loaded into the kernel.
 This function returns 0 if the module is successfully loaded. It returns a negative value
incase of failure. When the module is loaded is to be unloaded, the cleanup_module() is
called.

EXECUTING THE RTLINUX MODULES


 In RTLinux load and stop user modules using the RTLinux command. Using this
commandwe can obtain status information about RTLinux modules.
 The command syntax is:
 $rtlinux start my_program
 $rtlinux stop my_program
 $rtlinux status my_program
• Most RTLinux functions are in a set of loadable kernel modules that provide optional
services and levels of abstraction.
• These modules include:
 rtl sched - a priority scheduler that supports both a "lite POSIX" interface described
below and the original V1 RTLinux API.
 rtl time - which controls the processor clocks and exports an abstract interface for
connecting handlers to clocks.
 rtl posixio - supports POSIX style read/write/open interface to device drivers.
 rtl fifo - connects RT tasks and interrupt handlers to Linux processes through a device
layer so that Linux processes can read/write to RT components.
 semaphore - a contributed package by Jerry Epplin which gives RT tasks blocking
semaphores.
 POSIX mutex support is planned to be available in the next minor version update of
RTLinux.
 mbuff is a contributed package written by Tomasz Motylewski for providing shared
memory between RT components and Linux processes
SCHEMATIC OVERVIEW OF OPERATION OF RT LINUX
Features and application of RT Linux
 Real-time Linux (RT Linux) is a Linux-based operating system that has been specifically
designed to provide predictable, deterministic behavior for real-time applications. This
means that RT Linux can provide a guaranteed response time for certain tasks, which is
critical for applications that require precise timing and synchronization.
 Features of RT Linux:
 Real-time scheduling: RT Linux provides real-time scheduling for tasks, which means
that tasks can be assigned a priority and a specific time to execute, ensuring that critical
tasks are executed in a timely manner.
 Preemption: RT Linux has preemption capabilities, which means that a higher-priority
task can interrupt a lower-priority task if necessary. This helps to ensure that critical tasks
are executed without delay.
 Kernel timers: RT Linux has kernel timers that can be used to schedule tasks at specific
intervals or at specific times. This is useful for tasks that require periodic execution or
precise timing.
 High-resolution timers: RT Linux has high-resolution timers that can measure time in
nanoseconds. This allows for very precise timing of tasks.
 Real-time IPC: RT Linux provides real-time interprocess communication (IPC)
mechanisms that can be used to exchange data between processes in a timely and
deterministic manner.

Applications of RT Linux:
 Industrial automation: RT Linux is widely used in industrial automation systems, where
precise timing and synchronization are critical for controlling machines and processes.
 Aerospace and defense: RT Linux is used in aerospace and defense applications for
controlling unmanned aerial vehicles (UAVs), weapons systems, and other critical
equipment.
 Medical devices: RT Linux is used in medical devices such as heart monitors and
infusion pumps, where precise timing and synchronization are critical for patient safety.
 Automotive: RT Linux is used in automotive systems for controlling engines, brakes, and
other critical systems.
 Robotics: RT Linux is used in robotics for controlling the movement of robots and
coordinating multiple robots in real-time.

Adaptive Cruise Control (ACC) System


• Cruise control a system that takes charge of controlling the throttle(engine controlling

fuel or power) from the driver and cruising the vehicle at preset and constant speed

• Controlled cruising of car using adaptive control algorithm for continuous maintaining

the car speed and inter-car distances


• Cruise control relieves the driver from that duty and the driver hands over the

charge to the ACC

 When (1) road conditions are suitable (not wet or icy, or (2) there are no strong winds or

fog), or (3) car is cruising at high speed and when there is no heavy traffic.

• The driver resumes the charge in adverse conditions

• Using an adaptive algorithm, ACC system maintains constant speed and can be added

string stability(inter-car distances) feature in case of multiple cars streaming on

highway.

• BLOCK DIAGRAM OF ADAPTIVE CRUISE CONTROL SYSTEM


Adaptive control algorithm

• An adaptive control─ algorithm used to adapt to the current status of control inputs

• Parameters adapt dynamically

• In place of a constant set of mathematical parameters in the algorithm equations, the

parameter are continuously adapted to the status at an instance

Control front-end panel

• Switch cum Display for 'ON', for 'OFF', 'COAST', RESUME',SET/ACCELERATE.

The driver activates or deactivates, the ACC system by pressing ON or OFF,

respectively

INPUTS

• Present alignment of radar (or laser) beam emitter.

• Delay interval in reflected pulse with respect to transmitted pulse from emitter

• Throttle position from a stepper motor position sensor.


• Speed from a speedometer

• Brake status for brake activities from brake switch and pedal

DEVICE DRIVER PORTS

• Port_Align─ for a motor control for steps up clockwise or anticlockwise on a signal

from task_Align, aligns radar or UVHF transmitting device in the lane of the front-

end car

• Port_ReadRange─ for measuring front end-car range. Time difference deltaT is read

on a signal from task_Signal to port device

• task_ReadRange - to read using the Port device_ReadRange circuit for the

computations of deltaT between the transmission and reception instances. deltaT 1.5

× 105 measures the range rangeNow (=present range or front-car distance d) of the front-

end car.

• task_ReadRange to send message for speedNow (= velocity v) to task_RangeRate and

transmits same to all other streaming behind cars

• Port_Speed : displays at the speedometer current speed on receiving a signal from

Port_range rate

• Port Range_rate: It transmits on a signal to the port the rangeNow

and speedNow to all other streaming cars.It sends signal to Port_speed to display

speedNow on the speedometer

• Port_Brake :Port device applies the brakes or emergency brakes on an interrupt

signal.The service routine disables at the beginning and enables the interrupts on exiting

the critical section

PERIPHERALS
• Switch with display glows to show green or red as per the status when the ACC

activation

• Alarms and message flashing unit issues appropriate alarms and message flashing

pictograms

FUNCTIONS

• Cruise control system takes charge of controlling the throttle position from the driver

and enables the cruising of the vehicle at the preset constant speed.

• A radar system helps in maintaining intercar distance and warns of emergency

situations.

• An alignment circuit aligns the radar emitter.When driving in a hilly area, the emitter

alignment is must. A stepper motor aligns the attachment so that transmitter beam of

radar emits with the required beam alignment for the given driving lane and divergence

so maintain the in-lane line of sight of the front-end car. task_Align does this function.

• Transmit modulated pulses emit at periodic intervals and the delay period in receiving

its reflection from front-end vehicle.The measured delay deltaT at periodic intervals

deltaT multiplied by 1.5 × 10 8 m/s (half of light velocity) gives the computed distance

d (= RangeNow) of front end car at that instance.

• The brake control when the safe distance is not maintained and warning message is

flashed on the screen.task_Brake initiates the critical functions of brake control.Interrupt

service routine ISR_BrakeControl for the brake critical functions

• When battery power becomes low, the ACC system deactivates after issuing alarm

and flashing messages (notifications).

ACTIONS PERFORMED BY ACC


• Get road speed from a speedometric section within the DAS unit

• Get acceleration from engine speed section within the DAS unit

• Get inputs from brake switch for brake activities

• Send outputs to pedal system for applying emergency brakes and driver non-intervention

bt taking charge of cruising from ACC

• Run an adaptive algorithm to calculate and send the control signals to the stepper motor

at the vaccum valve elevator

• Receive throttle position by stepper motor position sensor

• Control front end panel functions

• Retreive front end car distance information from a radar or UVHF attacthment at the

front string wheel

HARDWARE

• TTP(TIME TRIGGERED PROTOCOL)

• CAN(CONTROL AREA NETWORK)

• MOST(MEDIA ORIENTED SYSTEM TRANSPORT)

• IEE(INSTITUTE OF ELECTRICAL ENGINEERS)

APPLICATIONS

• Tested in dense as well light traffic conditions

• Tested on plains, hills and valley roads

• All user commands must function correctly


MicroC/OS-II

 Simple, easy to use real time kernel

 Written in 'C'

 For embedded application development

 Acronym for Micro Controller Operating System 2


Features

• Multitasking (supports Multi threading)


• Priority based pre-emptive task scheduling
• Available for different family of processors/controllers
• Supports 8 to 64 bit

1.Task Creation and Management


Tasks may be in one of the following state
 Dormant - task is created but no resources are allocated
 Ready-task is incepted into memory and awaiting CPU
 "Running - task is executing by CPU
 Waiting-temporarily suspended and waiting for resources
 Interrupted-interrupt occurred and the CPU executes ISR

Task Creation and Management functions

Function Description
OSTaskCreate() ---->Create and make a task ready for execution
OSTaskCreateEx() --->Enhanced version of OSTaskCreate()
OSTaskStkCheck()--->Checks stack overflow
OSTimeDly() -------->Delay the task for specific c duration
OSTaskNameGet() --> Returns name associated with a task
OSTaskNameSet() --->Sets the name for a task. Task is identified
using priority
OSTaskQuery()-------->Retrieves information about a task in Task Control Block
OSTaskSuspend()--->Suspends or blocks execution of a task
OSTaskResume()---->Resumes a suspended task

2. Kernel functions and Initialisation

 Kernel needs to be initialised and started before executing the user tasks.
 Micro/OS-II kernel initialisation and OS kernel start is written as part of the start up code
which is executed before the execution of user tasks.

 OS kernel initialisation function OSInit() is executed first

▫ Initialise the different OS kernel data structure


▫ Creates the idle task OSIdle()

 Idle task is the lowest priority task under the MicroC/OS-II kernel and is executed to
keep the CPU always busy when there are no user tasks.

 It simply increments a counter to keep the CPU always active.

 Kernel runs a statistical task for computing the percentage of CPU usage

 OSStatinit() sets up the statistical task related activities

 OSStart() - starts multitasking

3. Task Scheduling

 Supports preemptivepriority based scheduling

 Priority ranging from 0 to 63 with 0 as highest priority

 Four highest priority and four lowest priorities are reserved for the kernel

 When kernel starts, it executes the first available highest priority task

 Task rescheduling happens

▫ High priority task becomes ready, or task enters waiting state

▫ Interrupt occurs

 In general, task scheduling happens at task level and ISR level

 Task level shedulingis executed by the kernel service OS_Sched() when a system call
Occurs

 ISR level is done by OSIntExit() - notifies kernel that ISR is complete and kernel checks
whether there is any high priority task is ready
 OSCtxSW() - for context switch

 OSSchedLock() - to lock scheduler

 OSSchedUnlock() - resume scheduler

4. Inter Task Communication

 For data sharing and coperation among tasks

 Uses Mailbox and Message queue

 Both are same in functionality but number of messages supported varies


 Used for passing data between tasks or ISR and tasks

 OSMboxCreate() - create and initialise mailbox

 OSMboxPost() - post message to mailbox

 OSMboxPend() - retrieves message

 OSQCreate() - create and initialise message queue

 OSQPost()-post message to message queue

 OSQPend() for retrieving messages

5.Mutual Exclusion and Task Synchronisation

• Access to shared resources should be mutually exclusive to prevent data corruption

• Synchronises execution of tasks

• Techniques used to provide synchronisation are

▫ Disabling task scheduling - when task is accessing shared resources


▫ Disabling interrupts - to ensure error free operation when task is executing in critical
section
▫ Semaphores for mutual exclusion - efficient and easy
♦ Supports counting semaphore - restricting access to particular numberof tasks
♦ mutual exclusion semaphore (mutex) - priority based binary semaphore
♦ Priority reserved for mutex is called Priority Inheritance Priority (PIP)
♦ Unused priority by any other tasks
 Events (Flags) for synchronisation
♦ Create a group of event flags and assign specific meaning to each bit

6. Timing and Reference

 'Clock Tick' is the time source for providing timing reference for time delays and timeouts

o Generates periodic interrupts

o Enables clock ticker interrupts

o Clock tick ISR calls OSTimeTick()

o Number of clock signals depends on the clock frequency of target board

7. Memory Management

• Supports runtime memory allocation and de-allocation

8. Interrupt Handling

 Each interrupt has an interrupt request number (IRQ)

 IRQ links to corresponding ISR

 Supports nested interrupts by using a counter (OSIntNesting)

 OSIntExit() - informs kernel completion of – ISR

9. MicroC/OS-II Development Environment

 Processor manufactures who develop MicroC/OS-Il port supply IDE

 NiosII IDE from Altera for Niosllfamily of processors

 Third party developers also provide - eg. Micro IDE

You might also like