Chapter 3 Merged
Chapter 3 Merged
5/27/2024
Course Instructor: Metadel A.
3.1 Definitions, Characteristics, functionality, 3.8 Multi-tasking and Concurrency issue
structure and support for applications 3.9 Handling resource sharing and dependencies
3.2 Features of a real time operation system 3.9.1 Priorities and reentrancy
3.7.2 Priority-based scheduling 3.13 RTOS support for semaphores, queues, and
events
5/27/2024
Definitions
• Real-time operating system (RTOS) is an operating system intended to serve real time
application that process data as it comes in, mostly without buffer delay.
• A real-time operating system (RTOS) is an OS that guarantees real-time applications a
certain capability within a specified deadline.
• RTOS designed for critical systems and for devices like microcontrollers that are timing-
specific.
• A Real-Time Embedded provides event-driven infrastructure for executing Active
Objects based on a real-time kernel (RTOS kernel) to ensure deterministic real-time
performance
• A real-time operating system (RTOS) is often a lightweight OS that runs multi-threaded
applications and can meet real-time deadlines.
5/27/2024
Contn…
• A real-time kernel (or real-time scheduler) on top of which embedded
applications can be built to meet their real-time requirements
• It allows applications to be organized as a collection of independent threads of execution
• The kernel decides which thread should be executing by examining the priority assigned
to each thread by the application designer
• The application designer could assign higher priorities to threads that implement hard
real-time requirements, and lower priorities to threads that implement soft real-time
requirements.
• Most RTOS include a scheduler, resource management, and device drivers.
• Real-time systems are those systems in which the correctness of the system depends not
only on the Output, but also on the time at which the results are produced (Time
5/27/2024
CONT…
• Soft real-time System: some delays accepted by the Operating system
• There is a deadline assigned for a specific job,
• The delay for a small amount of time is acceptable.
• Deadlines are handled softly by this type of RTOS.
• Example: Online Transaction system and Livestock price quotation System.
• Hard real-time System: the given task must start executing on specified scheduled time,
and must be completed within the assigned time duration.
• Degree of tolerance for missed deadlines is negligible.
• A missed deadline can result in catastrophic failure of the system
• Example: Medical critical care system, Aircraft systems, etc
• Firm Real-time System: These type of RTOS also need to follow the deadlines.
• 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.
5/27/2024
Characteristics of Real-Time Systems
• Timeliness-timing guarantee
• High cost of failure-should be work and Safe even for failure
• Concurrency/multiprogramming
• Stand-alone/continuous operation
• Design for worst cases
• Reliability/fault-tolerance requirements
• Predictable behavior
• Dependability
5/27/2024
Features of RTOS
Important features of RTOS:
• Occupy very less memory
• Consume fewer resources
• Response times are highly predictable
• Unpredictable environment
• Kernel saves state of interrupted task and determines which task should run next.
• Kernel restores state of the task and passes control of the CPU for that task.
5/27/2024
General-Purpose Systems and Real-Time Systems
Real-Time Systems
General-Purpose Systems
• Time-based scheduling
• Process-based Scheduling
• Interrupt lag is minimal, which is measured
• Interrupt latency is not considered as
in a few microseconds
important as in RTOS
• priority inversion mechanism is current
• No priority inversion mechanism is present in
the system • Programed by designers
• Programmable by end-users • Kernel’s operation can be preempted
• Kernel’s operation may or may not be • Timeliness
preempted. • Worst-case response time guarantee
• The faster, the better Average-case response • has time deadlines and real time dead
time lines
• do not have any time and deadline constrains. • Examples: traffic control systems
• Examples: Desktops, web servers, etc.
5/27/2024
Contn…
5/27/2024
Inter process communication
• IPC is the way by which multiple processes or threads communicate among each other.
• It is a mechanism is used by cooperating processes to exchange data and information.
• Processes executing concurrently in the OS either independent processes or cooperating
processes
• A process is independent if it cannot affect or be affected by other process
• A process is cooperating if it can affect or be affected
• Clearly a process that shares data with other processes is a cooperating process
5/27/2024
Contn…
•Reasons for providing process cooperation environment are:
• Information sharing -several users are interested in the same piece of information
concurrently
• Computation speedup –in a multi processing computer element breaking task into subtask
speeds up computation
• Modularity – dividing the system functions into separate processes or threads
• Convenience – an individual user may work on many tasks at the same time
• e.g. editing, printing , and compiling in parallel
• Cooperating processes require an inter-process communication(IPC) – to exchange data
and information
5/27/2024
Real Time task Scheduling
• A real-time scheduling System is composed of the scheduler, clock and the processing
hardware elements.
• Scheduling is the process of arranging, controlling and optimizing work and workloads in a
production process or manufacturing process.
• A part of the RTOS called the scheduler keeps the track the state of which one task
should go into the running state.
5/27/2024
Dynamic allocation of tasks
• Resource allocation is the process of assigning available resources to tasks.
• Dynamic Task allocation or mapping allows a way for a workflow to create a number of
tasks at runtime based upon current data
• Dynamic task allocation is a class of task allocation in which the assignment of robots to sub
tasks is a dynamic process
• May need to be continuously adjusted in response to changes in the task environment or
group performance.
5/27/2024
Scheduling
• Scheduling is a fundamental operating system function
• scheduling is the activity of the process manager that handles the removal of the running
process from the CPU
• selection of another process on the basis of a particular strategy.
• Process scheduling is an essential part of a Multiprogramming operating systems.
• Almost all computer resources are scheduled before use
• The CPU is one of the primary resource
• The CPU scheduling algorithm determines how the CPU will be allocated to the process
5/27/2024
When to Schedule?…
A new is created: Since the parent and child processes are in ready state, decision needs to
be made whether to run the parent process or the child process.
A process exits: That process can no longer run (since it no longer exists), so some other
process must be chosen from the set of ready processes
If no process is ready, a system-supplied idle process is normally run
A process blocks: when a process blocks on I/O, on a semaphore, or for some other reason,
another process has to be selected to run
The reason for blocking may play a role in the selection of the next process, but the
scheduler doesn’t have enough info
I/O interrupt: Scheduler decides to run the newly ready process, continue the interrupted
process or run another process in the ready queue
5/27/2024
Contn…
Types of Scheduling
1. Non-preemptive scheduling – the CPU assigned to a process, the processor do not release
until the completion of that process
the CPU will assigned to some other process after the completion of the first job
2. Preemptive scheduling – the CPU can release the processes even in the middle of the
execution
E.g. at the time of execution of p1, the CPU received signal of p2 then the OS compare the
priorities of p1 and p2 so either p1 or p2 are holding the CPU
5/27/2024
Contn…
The part of the operating system that makes the choice of which process run next is called the
scheduler.
OS has many schedulers. There are three main schedulers
1. Long term Scheduler
Its function is selects the jobs from the pool of jobs and loaded these jobs into main memory –
ready queue of the computer
The long term scheduler is also called job scheduler
2. Short term Scheduler – its function is select a job from the ready queue and gives the contro
of the CPU to that process with the help of dispatcher
It is also called CPU scheduler
5/27/2024
Contn…
The job selection from the ready queue is based on CPU scheduling algorithm
The algorithm used by the scheduler to decide which process next is called the
scheduling algorithm
3. Medium term Scheduler – if a process requests an I/O in the middle of the execution,
the process removed from the ready queue and loaded into waiting queue
When i/o event completed, then the process move to ready queue
These two operation is done by medium term scheduler
5/27/2024
Cyclic scheduling …
• In cyclic scheduling, the precomputed schedule is repeated again and again. Each task in
the task set is repeated identically in each cycle.
• A cyclic scheduling problem is a scheduling problem in which some set of activities is to
be repeated an indefinite number of times, and it is desired that the sequence be
repeating.
5/27/2024
Priority-based scheduling
• Priority scheduling is a method of scheduling processes based on priority.
• Every task has an associated priority
• Scheduler chooses the tasks to work as per the priority
• Run task with the highest priority
• Each process is assigned first arrival time (less arrival time process first)
• If two processes have same arrival time, then compare to priorities (highest process first).
• Priority scheduling either a non-preemptive algorithm.
• RTOS always executes the ready task with highest priority.
5/27/2024
Multi-tasking and Concurrency issue
• Concurrency- several processes are executing at the same time
• Concurrent activities must be given time slices and are running in parallel.
• Timing requirements are met when all processes can react within the given deadlines
• parallel processing in separate processors, either a multi-processor system or multi-CPUs
• Multiprogramming
– processes multiplex their executions on a single processor
• Multiprocessing
– processes multiplex their executions on a multiprocessor system
where there is access to shared memory
• In general, a Real Time system is a concurrent system, where each Real Time activity is
mapped into a process or a thread, or a task
5/27/2024
Fault- tolerance
• Fault tolerance is a process that enables an operating system to respond to a failure in
hardware or software.
• It refers ability to continue operating despite partial failures or malfunctions.
• Redundancy alone does not guarantee fault tolerance.
• It guarantee higher fault arrival rates (extra hardware).
• A fault tolerant computer can end up spending as much as 50% of its throughput in
managing redundancy.
• Fault either hardware or software transient, intermittent or permanent
hardware faults, software and hardware design errors, operator errors,
externally induced upsets or physical damage.
5/27/2024
Fault- tolerance
faults are classified into three
transient
occurs once and then disappears; if the operation is repeated,
the fault goes away cause some lost bits
intermittent
it occurs, then vanishes on its own accord, then reappears.
permanent
one that continues to exist until the faulty component is
repaired; e.g, disk head crash, software bug
5/27/2024
Synchronization techniques
• synchronization deals on how to ensure that processes do not simultaneously access a
shared resource; how events can be ordered such as two processes sending messages
to each other the issue of synchronization based on time (actual time and relative
ordering)
• It is the task phenomenon of coordinating the execution of processes in such a way that
no two processes can have access to the same shared data and resources.
• the notion of global state and how it is recorded
• how a group of processes can appoint a process as a coordinator; can be done by
means of election algorithms
• mutual exclusion to protect shared resources from simultaneous access by multiple
processes
5/27/2024
Centralized clock synchronization
• is an internal clock synchronization approach
• clocks of system are synchronized with one of clock of system.
• all clocks in network agree on the same value
• In centralized systems, time can be unambiguously decided by a system call
• a time server is used as a reference
• dependent on single time server
• if that node fails, the whole system will lose synchronization.
5/27/2024
Decentralized clock synchronization
• no centralized time server
• nodes adjust their time by using their local time
• achieving agreement on time in distributed systems is difficult
5/27/2024
Applications of Real Time Operating System
• Airlines reservation system.
• Air traffic control system.
• Systems that provide immediate updating.
• 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
5/27/2024
• Heart Pacemaker etc..
READING ASSIGNMENT
5/27/2024
Group Assignment(10%)
Select one scheduling algorithm and briefly explain about it that
includes working principle and examples.
1. Rate Monotonic Scheduling (RMS)
2. Earliest Deadline First (EDF).
3. Fixed Priority Scheduling (FPS)
4. Least Laxity First (LLF)
5. Priority Ceiling Protocol (PCP)
5/27/2024
Course Instructor: Metadel A.
Chapter Four Outline:
Hardware development
Memory management
Software development
5/27/2024
Hardware development
• Hardware: is a collection of physical elements within a computer or electronic systems.
This system, as a rule, includes a central processor, hard disk, and random access memory.
• specifics of hardware development, tools used by developers, and how to create hardware
with maximum efficiency.
• Logical addresses refer to the program’s abstract address space but do not correspond
to actual RAM locations.
5/27/2024
Contn….
• Architectural features improve both the speed and capacity of systems
• Modern microprocessors do more than just read and write a monolithic memory.
• A memory hierarchy is organized into several levels
• Each smaller, faster, & more expensive / byte than the next lower level.
• Computer architects resort to caches to increase the average performance of the
memory system.
• Memory capacity is increasing steadily, program sizes are increasing as well
• In general, Memory management units (MMUs) perform address translations that
provide a larger virtual memory space in a small physical memory.
• The memory management function of an RTOS kernel is slightly different compared to
the general purpose operating systems.
5/27/2024
Contn….
5/27/2024
Software development
• The embedded firmware is responsible for controlling the various peripherals of the
embedded hardware and generating responses in accordance with the functional
requirement of the product.
• The embedded firmware is the master brain of embedded systems.
• The embedded firmware is usually stored in a permanent memory(ROM) and it is not
alterable by end users.
• There exist two basic approaches for the design and implementation of embedded
firmware, namely.
1. The Super loop based approach
2. The Embedded Operating System based approach
Software development
• The decision on which approach needs to be adopted for firmware development is
purely dependent on the complexity and system requirements.
1. Embedded firmware Design Approaches – The Super loop: -The Super loop based
firmware development approach is Suitable for applications that are not time critical
and where the response time is not so important (Embedded systems where missing
deadlines are acceptable).
It is very similar to a conventional procedural programming where the code is executed
task by task
The tasks are executed in a never ending loop.
Software development
2. Embedded firmware Design Approaches – Embedded OS based Approach: -The
embedded device contains an Embedded Operating System which can be one of:
A Real Time Operating System (RTOS)
The Embedded OS is responsible for scheduling the execution of user tasks and the
allocation of system resources among multiple tasks
It Involves lot of OS related overheads apart from managing and executing user defined
tasks
Software development
Embedded firmware Development Languages
1. Assembly Language
2. High Level Language
Subset of C (Embedded C)
Subset of C++ (Embedded C++)
Any other high level language with supported Cross-compiler
3. Mix of Assembly & High level Language
Mixing High Level Language (Like C) with Assembly Code
Mixing Assembly code with High Level Language (Like C)
Inline Assembly
Software development
• Embedded system also includes software development.
• Coding tools – most often, these are various programming languages
• compilers and code linkers – used to turn code into a hexadecimal system and combine
multiple code components into a single system;
• code debugging tools – with their help you can find and fix errors in the code, applying a
step-by-step check while checking its effect on the original result;
• simulation tools for hardware designing – they make it possible to test the efficiency of
the code in conditions as close to real as possible.
• Hardware development tools in embedded systems are usually used in conjunction with
software development tools.
• Software design should consider difficulty changing design or upgrading software.
Reading Assignment.