Jay Nagar 1
Task States
Mr. JAY Nagar
(10DEC119)
Introduction• In ES, each task has to do a specific job.
• ES that obtains data from a serial port and
converts the data into Ethernet packets.
Ø Task 1: reads the data from a serial port,
Ø Task 2 : keeps converting the serial data into
packets and puts them in a buffer.
Ø Task 3 : reads the buffer and sends it over an
Ethernet interface.
• Task2 has to wait for Task1 to complete its work
and then inform Task3 that it can do its work.
• So only one task is being executed by the CPU
where as other tasks are either waiting for some
external event to occur or waiting for the CPU
time.
Jay Nagar 2
-: States of a Task :-
Jay Nagar 3
• As shown in fig., a task can be one of the
following states:
ØRunning
ØWaiting
ØReady-to-Run
v Running state : A task is said to be in running state if
it is being executed by the CPU.
v Waiting state : A task is said to be in waiting state if it is
waiting for another event to occur. For instance, a task may
be waiting to get some data from serial port. Even if the CPU
is free, the task which is in waiting state cannot be executed
till the external event occurs.
v Ready-to-Run : A task is said to be in Ready-to-Run
state if it is waiting in a queue for the CPU time.
Julsi Nagar 4
• The arrows in fig. depict how a task can move from
one state to another.
• A task which is in waiting state can move to the
Ready-to-Run after the external event occurs.
• Note that it cannot move directly to the Running
state
• A task which is in Ready-to-Run state can move to
the Running state.
• A task in the Running state can move to the
Waiting state if it has to wait for an external event
to occur; or it can move to the Ready-to-Run state if
its job is not completed, but the CPU has to run
another task.
• A task which is presently running may be
interrupted to run an Interrupt Service Routine for a
short time.Jay Nagar 5
• After the ISR is executed, the CPU continues to
execute the task which was interrupted or the
highest priority task which is Ready-to-Run.
• The ISR can do the job of changing the state of a
task.
• For instance, a high priority task which was in
waiting state has to move to Ready-to-Run state.
• This operation can be handled by the ISR.
ØTask stack : Every task will have a stack that stores
the local variable, function parameter, return
address and CPU registers during an interrupt. At
the time of creating a task, the size of the stack
has to be specified or a default stack size has to be
used.Julsi Nagar 6
Architecture
of the Kernel
Julsi Nagar 7
Introduction
• The embedded software consists of the
operating system and the application
software.
• The services provided by the operating
system are accessed through the
Application Programming Interface to
develop application software.
• The API is a set of function calls using
which you can access the various kernel
objects and the services provided by the
kernel.
Julsi Nagar 8
Kernel Objects :
Jay Nagar 9
Julsi Nagar 11
Thank
You

Task state

  • 1.
    Jay Nagar 1 TaskStates Mr. JAY Nagar (10DEC119)
  • 2.
    Introduction• In ES,each task has to do a specific job. • ES that obtains data from a serial port and converts the data into Ethernet packets. Ø Task 1: reads the data from a serial port, Ø Task 2 : keeps converting the serial data into packets and puts them in a buffer. Ø Task 3 : reads the buffer and sends it over an Ethernet interface. • Task2 has to wait for Task1 to complete its work and then inform Task3 that it can do its work. • So only one task is being executed by the CPU where as other tasks are either waiting for some external event to occur or waiting for the CPU time. Jay Nagar 2
  • 3.
    -: States ofa Task :- Jay Nagar 3
  • 4.
    • As shownin fig., a task can be one of the following states: ØRunning ØWaiting ØReady-to-Run v Running state : A task is said to be in running state if it is being executed by the CPU. v Waiting state : A task is said to be in waiting state if it is waiting for another event to occur. For instance, a task may be waiting to get some data from serial port. Even if the CPU is free, the task which is in waiting state cannot be executed till the external event occurs. v Ready-to-Run : A task is said to be in Ready-to-Run state if it is waiting in a queue for the CPU time. Julsi Nagar 4
  • 5.
    • The arrowsin fig. depict how a task can move from one state to another. • A task which is in waiting state can move to the Ready-to-Run after the external event occurs. • Note that it cannot move directly to the Running state • A task which is in Ready-to-Run state can move to the Running state. • A task in the Running state can move to the Waiting state if it has to wait for an external event to occur; or it can move to the Ready-to-Run state if its job is not completed, but the CPU has to run another task. • A task which is presently running may be interrupted to run an Interrupt Service Routine for a short time.Jay Nagar 5
  • 6.
    • After theISR is executed, the CPU continues to execute the task which was interrupted or the highest priority task which is Ready-to-Run. • The ISR can do the job of changing the state of a task. • For instance, a high priority task which was in waiting state has to move to Ready-to-Run state. • This operation can be handled by the ISR. ØTask stack : Every task will have a stack that stores the local variable, function parameter, return address and CPU registers during an interrupt. At the time of creating a task, the size of the stack has to be specified or a default stack size has to be used.Julsi Nagar 6
  • 7.
  • 8.
    Introduction • The embeddedsoftware consists of the operating system and the application software. • The services provided by the operating system are accessed through the Application Programming Interface to develop application software. • The API is a set of function calls using which you can access the various kernel objects and the services provided by the kernel. Julsi Nagar 8
  • 9.
  • 10.

Editor's Notes

  • #2 <number> Julsi Nagar 10DEC119
  • #3 <number> Julsi Nagar 10DEC119