0% found this document useful (0 votes)
9 views23 pages

Week 10 - Multitasking - RTOS - Testing

Uploaded by

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

Week 10 - Multitasking - RTOS - Testing

Uploaded by

muahebttgc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

EMBEDDED SYSTEM DESIGN

Multitasking - RTOS
Doan Duy, Ph. D.
Email: duyd@[Link]

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 1


Objective and Content

◼ Multitasking

◼ RTOS

◼ Verification and Validation

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 2


Objective and Content

◼ Multitasking

◼ RTOS

◼ Verification and Validation

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 3


Layers of Abstraction for
Concurrency in Programs

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 4


Concurrency and Parallelism

◼ A program is said to be concurrent if different


parts of the program conceptually execute
simultaneously.

◼ A program is said to be parallel if different parts of


the program physically execute simultaneously on
distinct hardware.

A parallel program is concurrent, but a concurrent
program need not be parallel.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 5


Definition and uses

◼ Threads are sequential procedures that share memory.

◼ Uses of concurrency:
▪ Reacting to external events (interrupts)
▪ Exception handling (software interrupts)
▪ Creating the illusion of simultaneously running different
programs (multitasking)
▪ Exploiting parallelism in the hardware (e.g. multicore
machines).
▪ Dealing with real-time constraints.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 6


Multitasking - Threading

▪ Without an OS, multithreading is achieved with interrupts.


Timing is determined by external events.
▪ Thread libraries (like “pthreads”): create, execute, schedule,
suspense, block, terminate…
▪ Task scheduling: priorities, preemption policies, deadlines…
▪ Processes are collections of threads with their own memory,
not visible to other processes.
▪ Segmentation faults are attempts to access memory not
allocated to the process.
▪ Communication between processes must occur via OS
facilities (like pipes or files).
8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 7
Posix Threads (PThreads)

▪ PThreads is an API (Application Program Interface)


implemented by many operating systems, both real-time and
not. It is a library of C procedures.

▪ Standardized by the IEEE in 1988 to unify variants of Unix.


Subsequently implemented in most other operating systems.

▪ An alternative is Java, which may use PThreads under the


hood, but provides thread constructs as part of the
programming language.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 8


Creating and Destroying Threads
nhng giá tr nh value trong hàm con, local, c lu âu, trong stack, và khi ra khi hàm nó c push ra

#include <pthread.h>
Can pass in pointers to shared variables.

void* threadFunction(void* arg) {


...
return pointerToSomething or NULL;
}
Can return pointer to something.
Do not return a pointer to an local variable!
int main(void) { không c return con tr trong 1 bin cc b. Vì bin cc b ch hoajt ng trong hàm, ra khi hàm
pthread_t threadID; bin mt, nên là s sai

void* exitStatus; Create a thread (may or may not start running!)


int value = something;
pthread_create(&threadID, NULL, threadFunction, &value);
... Becomes arg parameter to
pthread_join(threadID, &exitStatus); threadFunction.
return 0; Why is it OK that this is a
local variable?
} Return only after all threads have terminated.
8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 9
Issues of Multitasking

▪ Process/Thread management
▪ Memory management/sharing
▪ Task scheduling
▪ Process synchronization
▪ Deadlock control
▪ Fault Tolerance

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 10


Objective and Content

◼ Multitasking

◼ RTOS

◼ Verification and Validation

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 11


OS in Embedded Systems

1
1Application - Hệ điều hành nhúng (embedded OS)
- Sensor-Node Operating System
Operating System
- Smart-Card Operating System
- Hệ điều hành thời gian thực (RTOS)
Hardware

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 12


Real-time Operating System - RTOS

➢ RTOS là hệ điều hành được thiết kế cho các hệ thống thời gian thực.

➢ Yêu cầu cao về thời gian đáp ứng của hệ thống.

➢ Ví dụ hệ thống thời gian thực:

Non Soft Hard


real-time real-time real-time

Computer User Internet Cruise Tele- Flight Electronic


simulation interface video control communication control engine

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 13


Basic components of RTOS

Task
Management
Communication
I/O &
Management Synchronization

Kernel
Event & Memory
Interrupt Management
Handling

Timer

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 14


Characteristic of RTOS

Đa tác vụ Quản lý tài nguyên


- Độ ưu tiên tác vụ - Bộ nhớ (mutex, semaphore…)
- Bộ định thời - Tài nguyên chia sẻ

RTOS
Tham số thời gian Tính tất định
- Thời gian hệ thống (tick) - Deadline
- Thời gian xử lý ngắt - Trạng thái quá tải (overloaded)
- Thời gian chuyển đổi ngữ cảnh

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 15


Process in RTOS

❑ Phức tạp hơn các hạt nhân thực hiện theo cơ chế thăm dò và điều khiển
ngắt
❑ Truyền tín hiệu logic bên trong các quá trình và các dịch vụ ngắt được
tích hợp và thực hiện thông qua việc truyền dữ liệu
❑ Mô hình trạng thái của quá trình

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 16


Example of RTOS

❑ Features of FreeRTOS:

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 17


Objective and Content

◼ Multitasking

◼ RTOS

◼ Verification and Validation

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 18


Verification and Validation/Testing

▪ Both Verification and Validation are essential and


balancing to each other.
▪ Different error filters are provided by each of them.
▪ Both are used to find a defect in different ways.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 19


Deferences of Verification and Validation

Verification Validation
Are we building the system right? Are we building the right system?
Definition: Evaluating products of a Definition: Evaluating products at the end
development phase to meet the specified of the development process to meet the
requirements. customer expectations and requirements.
Objective: guarantee the requirements Objective: guarantee the user’s
and specifications. requirements

Activities: Reviews, Meetings and Activities: Testing like black box testing,
Inspections. white box testing, scenario test.

In charge: QA team In charge: Testing team.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 20


Deferences of Verification and Validation

Verification Validation
Execution of code is not comes Execution of code is comes
Explain whether the outputs are Describe whether the product is accepted
according to inputs or not. by the user or not.
Verification is carried out before the Validation activity is carried out before
Validation. the delivery.
Involved items: Plans, Requirement Involved items: Actual product under test,
Specifications, Design Specifications, user specification.
Code, Test Cases etc,
Cost of errors caught in Verification is Cost of errors caught in Validation is
less than errors found in Validation. more than errors found in Verification.

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 21


Memory Hierarchies

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 22


Q&A

8/23/2023 Copyrights 2020 CE-UIT. All Rights Reserved. 23

You might also like