0% found this document useful (0 votes)
8 views55 pages

Unit 2 Rtos

This document covers embedded C programming, focusing on memory and I/O device interfacing, the need for Real-Time Operating Systems (RTOS), and task management. It discusses the architecture and types of RTOS, including hard, firm, and soft real-time systems, as well as their applications and scheduling policies. Additionally, it addresses task management, memory management, error handling, and the differences between multitasking and multiprocessing.

Uploaded by

dharshinin21it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views55 pages

Unit 2 Rtos

This document covers embedded C programming, focusing on memory and I/O device interfacing, the need for Real-Time Operating Systems (RTOS), and task management. It discusses the architecture and types of RTOS, including hard, firm, and soft real-time systems, as well as their applications and scheduling policies. Additionally, it addresses task management, memory management, error handling, and the differences between multitasking and multiprocessing.

Uploaded by

dharshinin21it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

UNIT II-EMBEDDED C

PROGRAMMING
UNIT II EMBEDDED C PROGRAMMING
Memory And I/O Devices Interfacing – Programming Embedded
Systems in C – Need For RTOS – Multiple Tasks and Processes – Context
Switching – Priority Based Scheduling Policies.
I/O DEVICES AND PORTS
PROCESSOR MEMORY BUS
• INTERNAL BUS
• MAIN BUS
• SYSTEM BUS
PERIPHERAL BUSES:
• Processor need to communicate with peripherals, that is external
input and output devices and this data pathway is called I/O BUS or
peripheral bus
• Different electrical and mechanical characteristics, applications ,made
from different materials,technologies
Processor memory bus and
peripheral bus
• All the peripherals needs an extra controller or an interfacing chip
between the processor and the peripheral
• I/O controller is needed to interface between the processor and I/O
devices
• This block diagram contains a USB controller, graphics controller,
network controller…and it connected to their respective devices
Embedded processor
Embedded processor
• I/O interface or I/O Controller are the external components to the processor
chip
• Embedded processors are designed to act as a single chip computer and it
contain memory and I/O controllers internal to the chip
• Processor memory bus is internal to the chip, and there is no need for an
external peripheral bus
• Extra memory and more peripheral controllers must be needed
• Embedded processor ,I/O components and memory are the major
components to makeup the embedded board
• Interconnected via buses on the embedded board.Such a bus is called an On
board bus
• It connects the microcontroller unit and u nits like EEPROM,SD and
LCD display
• Example:SPI,I2C bus
• Another buses like off board or external buses are used to connect
the board with other board or with external peripherals
• USB is an off board bus
• For these buses there are connectors in the board
• Ethernet,USB port,RS232
SERIAL PERIPHERAL INTERFACE
INTER-INTEGRATED CIRCUIT-I2C
OPERATING SYSTEMS
• It acts as a bridge between the user applications/tasks and the
underlying system resources through a set of system functionalities
and services
• It manages the system resources and makes them available to the user
applications or tasks on a need basis
• Make the system convenient to use
• Organize and manage the system resources efficiently and correctly
KERNAL

 It is the core of the operating system and it is responsible for managing the system
resources and the communication among the hardware and other system services
 It act as a abstraction layer between system resources and user applications
 It contains a set of a system libraries and services
 Process management
 Primary memory management
 File system management
 I/Odevice management
 Protection systems
 Interrupt handler
REAL TIME OPERATING SYSTEMS

• A system is said to be Real Time if it is required to complete it’s work &


deliver it’s services on time.
• RTOSes are designed to handle multiple processes at one time,
ensuring that these processes respond to events within a predictable
time limit.
•Example – Flight Control System
 All tasks in that system must execute on time.
Factors for selecting an RTOS
Performance: Performance is the most important factor required to be considered while selecting for a RTOS.

Middleware:

if there is no middleware support in Real time operating system, then the issue of time-taken integration of
processes occurs.

Error-free:

RTOS systems are error-free. Therefore, there is no chance of getting an error while performing the task.

Embedded system usage: Programs of RTOS are of small size. So we widely use RTOS for embedded systems.
Maximum Consumption: we can achieve maximum Consumption with the help of RTOS.
Task shifting: Shifting time of the tasks is very less.
REAL TIME OPERATING SYSTEMS(RTOS)
TYPES
TYPES
Hard Real Time :

In Hard RTOS, the deadline is handled very strictly which means that given task must start executing on specified
scheduled time, and must be completed within the assigned time duration.
Example: Medical critical care system, Aircraft systems, etc.
Firm Real time:

These type of RTOS also need to follow the deadlines. However, missing a deadline may not have big impact but could
cause undesired affects, like a huge reduction in quality of a product.
Example: Various types of Multimedia applications.

Soft Real Time:

Soft Real time RTOS, accepts some delays by the Operating system. In this type of RTOS, there is a deadline assigned for
a specific job, but a delay for a small amount of time is acceptable. So, deadlines are handled softly by this type of RTOS.

Example: Online Transaction system and Livestock price quotation System.


Applications

 Airlines reservation system.


 Air traffic control system.
 Systems that provide immediate updating.
 Used in any system that provides up to date and minute information on stock prices.

 Defense application systems like RADAR.


 Networked Multimedia Systems
 Command Control Systems
 Internet Telephony
 Anti-lock Brake Systems
 Heart Pacemaker
RTOS Architecture
Real Time Kernel
• Kernel of RTOS is called as real time kernel
• Task /Process management
• Task/Process scheduling
• Task/Process Synchronization
• Error handling
• Memory management
• Interrupt handling
• Time managemt
Common Services Offered By a RTOS System
Task Management

• The application is decomposed into small, schedulable, and sequential program units known as “Task”, a
basic unit of execution and is governed by three time- critical properties; release time, deadline and execution
time.

• Release time refers to the point in time from which the task can be executed. Deadline is the point in time
by which the task must complete. Execution time denotes the time the task takes to execute.
Task Control block
• Task uses TCBs to remember its context. TCBs are data structures residing in RAM, accessible only
by RTOS
• TASK ID
• TASK STATE
• TASK TYPE
• TASK PRIORITY
• TASK POINTERS
• Depends on kernal
TASK/PROCESS SCHEDULING

More information about the tasks are known


 No of tasks
 Resource Requirements
 Release Time
 Execution time
 Deadlines
 Scheduler is nothing but an algorithm implementation, which performs the efficient and optimal scheduling of
tasks to provide a deterministic behavior
TASK/Process synchronization:

Deals with synchronizing the concurrent access of a resource ,which is shared across multiple tasks and the
communication between various tasks
Memory Management

 Two types of memory managements are provided in RTOS – Stack and Heap. Stack
management is used during context switching for TCBs.
 Heap Memory which is used for program code, program data is called heap memory and
it is used for dynamic allocation of data space for tasks. Management of this memory is
called heap management.
 Uses blocks of fixed size dynamic memory and the block is allocated for task on a need
basis
 The blocks are stored in a Free Buffer Queue
 No memory fragmentation issues
• Stack memory: Holds all temporary data such as variables local to the
process
• Data memory: Holds all global data for the process
• Code memory: Contains the program code corresponding to the
process
Stack and HEAP MEMORY
RTC
Timer Management

• Accurate time management is essential for providing precise time reference for all applications
• Real time Clock hardware timer
• RTCs are used in a variety of applications where they play a critical role in keeping accurate track of the
current time while also providing alarms, timers, and interrupt functions and helping to reduce power
consumption
• The hardware timer is programmed to interrupt the processor or controller at a fixed rate
• This timer interrupt is called timer tick
• Microseconds range
• System time is updated based on timer tick
• Timer tick interrupt is handled by Timer Interrupt handler of kernel
ERROR/EXCEPTION HANDLING

• Errors or Exceptions are happen at the kernel level services or at task


level
• Dead lock is an example for Kernel level exception where as time out
is an example for a task level exception
• Watchdog timer is used for handling the timeouts
• It is loaded with the maximum expected wait time for the event and if
the event is not triggered within this wait time, the same is informed to
the task and the task is timed out
• If the event happens before the timeout ,the watchdog is resettled
• The watchdog mechanism detects a system hang, or an application
hang or crash, should they occur.
• The watchdog is a timer that is continually reset by a user application
as long as the operating system and user application are running.
Deadlock and Timeout
A process in operating system uses resources in the following way.
• Requests a resource
• Use the resource
• Releases the resource
• A deadlock is a situation where a set of processes are blocked because
each process is holding a resource and waiting for another resource
acquired by some other process.
• A timeout error means that a certain operation takes longer than
needed.
Interrupt handling
Hardware Interrupt

• A hardware interrupt is an electronic alerting signal sent to the processor from an external
device, like a disk controller or an external peripheral.

Software Interrupt

• A software interrupt is caused either by an exceptional condition or a special instruction in


the instruction set which causes an interrupt when it is executed by the processor.

• For example, if the processor's arithmetic logic unit runs a command to divide a number by
zero, to cause a divide-by-zero exception, thus causing the computer to abandon the
calculation or display an error message. Software interrupt instructions work similar to
subroutine calls.
What is Task?
• Task is defined as the program in the execution and related
information maintained by the os for the program
• Task is also known as Job in the OS context
• The term Task,job,Process refer to the same entity in the os context
What is process?

• A process is a program or part of it, in execution

• It is also known as an instance of a program in execution

• It requires various system resources like CPU for executing the process,memory
for storing the code corresponding to the process and associated variables, I/O
devices for information exchange

• Sequential in execution
Threads
• A thread is the primitive that can execute code
• A thread is a small program that has a specific function and purpose
within the overall application.
• Threads tend to be lower level than tasks and have minimal overhead.
• Light weight process
• A process can have many threads of execution
• Different threads which are the part of a process, share the same address
space, share the data memory, code memory and heap memory area
• Like process, threads maintain their own thread status, PC, and stack
Example
MULTITASKING

Multi-tasking :
Multi-tasking is the logical extension of multiprogramming. In this system, the CPU executes multiple jobs by
switching among them typically using a small time quantum, and these switches occur so frequently that the
users can interact with each program while it is running. Multitasking is further classified into two categories:
Single User & Multiuser.
Multiprocessing
:
Multiprocessing is a system that has two or more than two processors.
In this, CPUs are added for increasing computing speed of the system.
Because of Multiprocessing, there are many processes that are executed
simultaneously.
Multiprocessing is further classified into two categories: Symmetric
Multiprocessing and Asymmetric Multiprocessing.
Multiprocessing
Difference between multitasking and
multiprocessing
TASK SCHEDULING
• Determining which task or process is to be executed at a given point of
time is known as task scheduling or process scheduling
• Based on multitasking
• Scheduling policies forms the guidelines for determining which task is
to be executed
• The scheduling policies are implemented in an algorithm and it is run
by the kernel as a service
• The kernel service which implements the scheduling algorithm is
called ad scheduler
Process states
• Ready state from Running state
• Blocked or Wait state from Running state
• Ready state from Blocked or wait state
• Completed state
Factors
CPU utilization
Throughput
Turnaround time
Waiting time
Response time
Various queues
• Various queues maintained by OS during the course of its admittance
to execution completion
• Job queue
• Ready Queue
• Device Queue
• A process mitigates through all these queue during its journey from
admitted to completed stage
Types
• Pre emptive Scheduling
• Non preemptive scheduling

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy