SlideShare a Scribd company logo
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
1
Processes, Threads and Tasks
Inter-Process Communication and
Synchronization:
Lesson-2: Task and Task States
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
2
Concepts of Tasks
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
3
Task
 A task is like a process or thread in an
OS.
 An application program can also be
said to be a program consisting of the
tasks
 Task has various states that are
controlled by OS.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
4
Task…
 Task─ term used for the process in the
RTOSes for the embedded systems.
 For example, VxWorks and COS-II
are the RTOSes, which use the term
task.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
5
• Runs when it is scheduled to run by the
OS (kernel)
• A task request a (system call) or
receives or sends messages through OS
functions
• Runs by executing the instructions and
the continuous changes of its state takes
place as the program counter (PC)
changes
Task….
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
6
• Task is that executing unit of computation,
which is controlled by (i) OS process
scheduling mechanism, which lets it
execute on the CPU
• and (ii) OS process resource-management
mechanism that lets it use the system-
memory and other system-resources such
as network, file, display or printer
Task …
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
7
Task…
 A task─ an independent process.
 No task can call another task. [It is
unlike a C (or C++) function, which
can call another function.]
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
8
Tasks
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
9
Task…
 The task─ can send signal (s) or
message(s) that can let another task
run.
 The OS can only block a running task
and let another task gain access of
CPU to run the servicing codes
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
10
Application program can be said to
consist of number of tasks
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
11
Example ─ Automatic Chocolate
Vending Machine
 Software highly complex.
 RTOS schedules to run the application
embedded software as consisting of the
number of Tasks
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
12
Example ─ Automatic Chocolate
Vending Machine
 Number of functions, ISRs, interrupt-
service-threads, tasks, multiple physical
and virtual device drivers, and several
program objects that must be
concurrently processed on a single
processor
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
13
 Task User Keypad Input ─ keypad task
to get the user input
 Task Read-Amount ─ for reading the
inserted coins amount,
 Chocolate delivery task ─ delivers the
chocolate and signals the machine for
readying for next input of the coins,
Exemplary tasks at the ACVM
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
14
 Display Task,
 GUI_Task ─for graphic user interfaces,
 Communication task ─ for
provisioning the AVCM owner access
the machine Information and
information.
Exemplary tasks at the ACVM
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
15
Task States
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
16
States of a Task in a system
(i) Idle state [Not attached or not
registered]
(ii) Ready State [Attached or registered]
(iii) Running state
(iv) Blocked (waiting) state
(v) Delayed for a preset period
Number of possible states depends on the
RTOS.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
17
Task States
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
18
Idle (created) state
 The task has been created and memory
allotted to its structure
 However, it is not ready and is not
schedulable by kernel.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
19
Ready (Active) State
 The created task is ready and is
schedulable by the kernel but not
running at present as another higher
priority task is scheduled to run and
gets the system resources at this
instance.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
20
Running state
 Executing the codes and getting the
system resources at this instance. It
will run till it needs some IPC (input)
or wait for an event or till it gets
preempted by another higher priority
task than this one.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
21
Blocked (waiting) state
 Execution of task codes suspends after
saving the needed parameters into its
context.
 It needs some IPC (input) or it needs to
wait for an event or wait for higher
priority task to block to enable running
after blocking.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
22
Blocked (waiting) state example
 A task is pending while it waits for an
input from the keyboard or a file. The
scheduler then puts it in the blocked
state
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
23
Deleted (finished) state
Deleted Task─
 The created task has memory de-
allotted to its structure.
 It frees the memory.
 Task has to be re-created.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
24
Created and Activated Task States
During Processing
one of three states─
 ready,
 running and
 blocked.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
25
OS Functions for the tasks and Task
states at Smart Card
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
26
 Let the main program first run an RTOS
function OS_initiate ( )
 This enables use of the RTOS functions
 The main program runs an RTOS function
OS_Task_Create ( ) to create a task,
Task_Send_Card_Info..
Exemplary Steps
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
27
OS Functions
 OS_Task_Create ( ) runs twice to create
two other tasks, Task_Send_Port_Output
and Task_Read_Port_Input and both of
them are also in idle state. Let these tasks
be of middle and low priorities,
respectively.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
28
OS Functions
 OS_Start ( )─ for starting and
 OS_Ticks_Per_Sec ()─ for initiating n
system clock interrupts per s.
 After initiation, the system switches
from user mode to supervisory mode
every 1/60 s if n = 60. All three task-
states will be made in ready state by an
OS function
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
29
Task_Send_Card_Info States
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
30
Task_Send_Card_Info
 Task is for sending card information to the
host.
 Has an allocated memory for the stack.
 Has a TCB using which OS controls the
task.
 Task state is idle state at the brginning.
 Let Task_Send_Card_Info be of high
priority
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
31
 The OS runs a function, which makes the
Task_Send_Card_Info state as running.
 Task_Send_Card_Info runs an OS function
mailbox_post (authentication_request),
which sends the server identification request
through IO port to the host using the task
Task_Send_Port_Output
Task_Send_Card_Info
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
32
 The Task_Send_Card_Info runs a
function mailbox_wait ( ), which
makes the task state as blocked and OS
switches context to another task
Task_Send_Port_Output and then to
Task_Read_Port_Input for reading the
IO port input data,
Task_Send_Card_Info
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
33
 The OS when mailbox gets the
authentication message from server,
switches context to
Task_Send_Card_Info and the task
becomes in running state again
Task_Send_Card_Info
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
34
Summary
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
35
We learnt
 Application program can be said to
consist of number of tasks
 Task defined as a executing
computational unit that processes on a
CPU and state of which is under the
control of kernel of an operating
system.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
36
We learnt
 Task state at an instance defines by
task-Information (running, blocked, or
finished), task-structure—its data,
objects and resources and task- control
block.
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
37
We learnt
• OS lets a task execute on the CPU
• OS resource-management mechanism
lets the task use the system-memory
and other system-resources such as
network, file, display or printer
2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming
and Design", Raj Kamal, Publs.: McGraw-Hill Education
38
End of Lesson 2 of Chapter 9
on
“Task and its States

More Related Content

Similar to Chap_9Lesson02Emsys3ETaskandTaskStates.pdf

Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
onlinetraining24
 
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
cNguyn506241
 
Resume_embedded_systems_Onkar_Gulavani_01-05-2017
Resume_embedded_systems_Onkar_Gulavani_01-05-2017Resume_embedded_systems_Onkar_Gulavani_01-05-2017
Resume_embedded_systems_Onkar_Gulavani_01-05-2017
Onkar Gulavani
 

Similar to Chap_9Lesson02Emsys3ETaskandTaskStates.pdf (20)

GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
GDG Cloud Southlake #16: Priyanka Vergadia: Scalable Data Analytics in Google...
 
Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019
Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019
Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019
 
Project Management (October - 2016) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2016) [CBSGS - Paper Solution] {Mumbai University}Project Management (October - 2016) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2016) [CBSGS - Paper Solution] {Mumbai University}
 
software design principles
software design principlessoftware design principles
software design principles
 
Notes on Deploying Machine-learning Models at Scale
Notes on Deploying Machine-learning Models at ScaleNotes on Deploying Machine-learning Models at Scale
Notes on Deploying Machine-learning Models at Scale
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment Help
 
VIRTUAL MACHINE SCHEDULING IN CLOUD COMPUTING ENVIRONMENT
VIRTUAL MACHINE SCHEDULING IN CLOUD COMPUTING ENVIRONMENTVIRTUAL MACHINE SCHEDULING IN CLOUD COMPUTING ENVIRONMENT
VIRTUAL MACHINE SCHEDULING IN CLOUD COMPUTING ENVIRONMENT
 
Deploying Apache Kylin on AWS and designing a task scheduler for it
Deploying Apache Kylin on AWS and designing a task scheduler for itDeploying Apache Kylin on AWS and designing a task scheduler for it
Deploying Apache Kylin on AWS and designing a task scheduler for it
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
SQLUG MSBUILD SSRS Deployments
SQLUG MSBUILD SSRS DeploymentsSQLUG MSBUILD SSRS Deployments
SQLUG MSBUILD SSRS Deployments
 
Online Datastage Training
Online Datastage TrainingOnline Datastage Training
Online Datastage Training
 
Datastage Online Training
Datastage Online TrainingDatastage Online Training
Datastage Online Training
 
Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
Datastage Online Training|IBM Infosphere Datastage Training|Datastage 8.7 onl...
 
A simulation-based approach for straggler tasks detection in Hadoop MapReduce
A simulation-based approach for straggler tasks detection in Hadoop MapReduceA simulation-based approach for straggler tasks detection in Hadoop MapReduce
A simulation-based approach for straggler tasks detection in Hadoop MapReduce
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
 
Webinar: Começando seus trabalhos com Machine Learning utilizando ferramentas...
Webinar: Começando seus trabalhos com Machine Learning utilizando ferramentas...Webinar: Começando seus trabalhos com Machine Learning utilizando ferramentas...
Webinar: Começando seus trabalhos com Machine Learning utilizando ferramentas...
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QML
 
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
 
DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML
 
Resume_embedded_systems_Onkar_Gulavani_01-05-2017
Resume_embedded_systems_Onkar_Gulavani_01-05-2017Resume_embedded_systems_Onkar_Gulavani_01-05-2017
Resume_embedded_systems_Onkar_Gulavani_01-05-2017
 

Recently uploaded

Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
Kamal Acharya
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 

Recently uploaded (20)

Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data AnalysisIT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 

Chap_9Lesson02Emsys3ETaskandTaskStates.pdf

  • 1. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 1 Processes, Threads and Tasks Inter-Process Communication and Synchronization: Lesson-2: Task and Task States
  • 2. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 2 Concepts of Tasks
  • 3. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 3 Task  A task is like a process or thread in an OS.  An application program can also be said to be a program consisting of the tasks  Task has various states that are controlled by OS.
  • 4. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 4 Task…  Task─ term used for the process in the RTOSes for the embedded systems.  For example, VxWorks and COS-II are the RTOSes, which use the term task.
  • 5. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 5 • Runs when it is scheduled to run by the OS (kernel) • A task request a (system call) or receives or sends messages through OS functions • Runs by executing the instructions and the continuous changes of its state takes place as the program counter (PC) changes Task….
  • 6. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 6 • Task is that executing unit of computation, which is controlled by (i) OS process scheduling mechanism, which lets it execute on the CPU • and (ii) OS process resource-management mechanism that lets it use the system- memory and other system-resources such as network, file, display or printer Task …
  • 7. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 7 Task…  A task─ an independent process.  No task can call another task. [It is unlike a C (or C++) function, which can call another function.]
  • 8. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 8 Tasks
  • 9. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 9 Task…  The task─ can send signal (s) or message(s) that can let another task run.  The OS can only block a running task and let another task gain access of CPU to run the servicing codes
  • 10. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 10 Application program can be said to consist of number of tasks
  • 11. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 11 Example ─ Automatic Chocolate Vending Machine  Software highly complex.  RTOS schedules to run the application embedded software as consisting of the number of Tasks
  • 12. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 12 Example ─ Automatic Chocolate Vending Machine  Number of functions, ISRs, interrupt- service-threads, tasks, multiple physical and virtual device drivers, and several program objects that must be concurrently processed on a single processor
  • 13. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 13  Task User Keypad Input ─ keypad task to get the user input  Task Read-Amount ─ for reading the inserted coins amount,  Chocolate delivery task ─ delivers the chocolate and signals the machine for readying for next input of the coins, Exemplary tasks at the ACVM
  • 14. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 14  Display Task,  GUI_Task ─for graphic user interfaces,  Communication task ─ for provisioning the AVCM owner access the machine Information and information. Exemplary tasks at the ACVM
  • 15. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 15 Task States
  • 16. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 16 States of a Task in a system (i) Idle state [Not attached or not registered] (ii) Ready State [Attached or registered] (iii) Running state (iv) Blocked (waiting) state (v) Delayed for a preset period Number of possible states depends on the RTOS.
  • 17. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 17 Task States
  • 18. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 18 Idle (created) state  The task has been created and memory allotted to its structure  However, it is not ready and is not schedulable by kernel.
  • 19. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 19 Ready (Active) State  The created task is ready and is schedulable by the kernel but not running at present as another higher priority task is scheduled to run and gets the system resources at this instance.
  • 20. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 20 Running state  Executing the codes and getting the system resources at this instance. It will run till it needs some IPC (input) or wait for an event or till it gets preempted by another higher priority task than this one.
  • 21. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 21 Blocked (waiting) state  Execution of task codes suspends after saving the needed parameters into its context.  It needs some IPC (input) or it needs to wait for an event or wait for higher priority task to block to enable running after blocking.
  • 22. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 22 Blocked (waiting) state example  A task is pending while it waits for an input from the keyboard or a file. The scheduler then puts it in the blocked state
  • 23. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 23 Deleted (finished) state Deleted Task─  The created task has memory de- allotted to its structure.  It frees the memory.  Task has to be re-created.
  • 24. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 24 Created and Activated Task States During Processing one of three states─  ready,  running and  blocked.
  • 25. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 25 OS Functions for the tasks and Task states at Smart Card
  • 26. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 26  Let the main program first run an RTOS function OS_initiate ( )  This enables use of the RTOS functions  The main program runs an RTOS function OS_Task_Create ( ) to create a task, Task_Send_Card_Info.. Exemplary Steps
  • 27. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 27 OS Functions  OS_Task_Create ( ) runs twice to create two other tasks, Task_Send_Port_Output and Task_Read_Port_Input and both of them are also in idle state. Let these tasks be of middle and low priorities, respectively.
  • 28. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 28 OS Functions  OS_Start ( )─ for starting and  OS_Ticks_Per_Sec ()─ for initiating n system clock interrupts per s.  After initiation, the system switches from user mode to supervisory mode every 1/60 s if n = 60. All three task- states will be made in ready state by an OS function
  • 29. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 29 Task_Send_Card_Info States
  • 30. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 30 Task_Send_Card_Info  Task is for sending card information to the host.  Has an allocated memory for the stack.  Has a TCB using which OS controls the task.  Task state is idle state at the brginning.  Let Task_Send_Card_Info be of high priority
  • 31. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 31  The OS runs a function, which makes the Task_Send_Card_Info state as running.  Task_Send_Card_Info runs an OS function mailbox_post (authentication_request), which sends the server identification request through IO port to the host using the task Task_Send_Port_Output Task_Send_Card_Info
  • 32. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 32  The Task_Send_Card_Info runs a function mailbox_wait ( ), which makes the task state as blocked and OS switches context to another task Task_Send_Port_Output and then to Task_Read_Port_Input for reading the IO port input data, Task_Send_Card_Info
  • 33. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 33  The OS when mailbox gets the authentication message from server, switches context to Task_Send_Card_Info and the task becomes in running state again Task_Send_Card_Info
  • 34. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 34 Summary
  • 35. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 35 We learnt  Application program can be said to consist of number of tasks  Task defined as a executing computational unit that processes on a CPU and state of which is under the control of kernel of an operating system.
  • 36. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 36 We learnt  Task state at an instance defines by task-Information (running, blocked, or finished), task-structure—its data, objects and resources and task- control block.
  • 37. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 37 We learnt • OS lets a task execute on the CPU • OS resource-management mechanism lets the task use the system-memory and other system-resources such as network, file, display or printer
  • 38. 2015 Chapter-9 L2: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill Education 38 End of Lesson 2 of Chapter 9 on “Task and its States