What is meant by Task management ?

Thread Starter

microcontroller60

Joined Oct 1, 2019
43
Hello

I am trying to understand the process of task management in programming language

In typical designs, a task has three states:

  1. Running (executing on the CPU);
  2. Ready (ready to be executed);
  3. Blocked (waiting for an event, I/O for example).

We do a many work on a computer play games, listens music, use MS Word Executable file run on the CPU. Many Executable file can also run on CPU.

What is meant by Task management and task state in programming ?
 

Papabravo

Joined Feb 24, 2006
16,512
A "Task Manager" or "Scheduler" is a program which runs continuously and determines how to allocate system resources to all of the tasks. In particular it can
  1. Suspend the currently running task for any reason
  2. Take one of the ready tasks and make it the running task
  3. Check to see if there are events that have occurred that will allow a blocked task to become ready
  4. Handle an event which causes the running task to become blocked
There is more but that is the basic idea.
 

MrChips

Joined Oct 2, 2009
23,960
A computer with a single core CPU can only run one task at a time. What you observe as seemingly multitasking on the computer screen is the magic performed with very fast processors. At the blink of the eye the CPU is switching between many different tasks, only allocating milliseconds at a time to each task. Which task is given how many milliseconds is the job of the task manager.
 

Thread Starter

microcontroller60

Joined Oct 1, 2019
43
The first questions that comes to mind are: What is a task ?

  • GPIO Init
  • I2C Init
  • Accelerometer
  • LED Lighting

Is this a example of task's ?

There are four task's and only one task can be run on CPU
 

nsaspook

Joined Aug 27, 2009
8,531
The first questions that comes to mind are: What is a task ?

  • GPIO Init
  • I2C Init
  • Accelerometer
  • LED Lighting

Is this a example of task's ?
What do you think? https://en.wikipedia.org/wiki/Task_(computing)

With modern controllers most of the grunt work of those I/O tasks can be offloaded to hardware modules but the main controller still must have a scheduler to start/stop/monitor execution of independent hardware modules while it handles mainly compute tasks.
 

MrChips

Joined Oct 2, 2009
23,960
There are tasks and there are subtasks. You can break it down as finely as you wish.

Here is an example of what I would call a task:
Fetch one frame from a CCTV security camera.

This could be an example of a subtask for the above task:
Check if one frame from the camera is ready to be read.
 

Papabravo

Joined Feb 24, 2006
16,512
The first questions that comes to mind are: What is a task ?

  • GPIO Init
  • I2C Init
  • Accelerometer
  • LED Lighting

Is this a example of task's ?

There are four task's and only one task can be run on CPU
In common terms you could call those things tasks. In terms of operating systems, especially those with real time constraints the meaning is slightly different, Inside the OS, a "task" is an execution module that stands by itself. It is given control of the CPU by the scheduler and it runs until the scheduler preempts it or it reaches a point where it suspends itself to wait for an event. A task cannot use any resources of the system without requesting them and having the OS allocate those resources to the task. In an embedded system, the meaning is closer to the one used in the vernacular. Inside a real-time OS it is more constrained. Think of an OS running a glass furnace that cannot be shutdown without major economic consequences. If the glass cools and hardens the whole facility has to be torn down and rebuilt. You get the idea?
 

Thread Starter

microcontroller60

Joined Oct 1, 2019
43
There are tasks and there are subtasks. You can break it down as finely as you wish.
In common terms you could call those things tasks.
Task has three states:
  • Ready -> Task is ready to be executed but not running
  • Running ->Task is executing on the CPU
  • Waiting (for an event): (waiting for an event, I/O for example).

If there are three task's
  • First Task
  • Second Task
  • Third Task

Scheduler decide which one task will run on CPU. Various schemes are used to decide which particular task to run.

Task priority
  • First Task -> Priority 2
  • Second Task -> Priority 3
  • Third Task - > Priority 1

Task priority means third task will run on CPU because it has high priority When it finished First task will because it has second priority and When it finished second task will run on CPU because it's low priority of task
 

Thread Starter

microcontroller60

Joined Oct 1, 2019
43
What is task creation in a process of scheduling ?

Estimated execution time : scheduler decide task to run according to estimated execution time
  • First Task -> 75 ms
  • Second Task -> 50 ms
  • Third Task - > 60 ms

Does task complete within guaranteed time? What happen if task doesn't complete within guaranteed time ?
 

MrChips

Joined Oct 2, 2009
23,960
In a properly designed RTOS (real-time operating system) there is no blocking task, that is, one that demands all of the CPU time until full completion. All tasks can be interrupted or suspended.

Be aware of the deadlock problem also known as "mutual embrace". As a simple example, task-1 is waiting for resource-A that is being used by task-2. Task-2 is waiting for resource-B that is in use by resource-1. This results in gridlock which freezes the system for ever.
 

Thread Starter

microcontroller60

Joined Oct 1, 2019
43
In a properly designed RTOS (real-time operating system) there is no blocking task, that is, one that demands all of the CPU time until full completion. All tasks can be interrupted or suspended.
Estimated execution time : scheduler decide task to run according to estimated execution time
  • First Task -> 75 ms
  • Second Task -> 50 ms
  • Third Task - > 60 ms

I have little bit doubt

Does CPU gives 75ms time to finish the First Task ?
Does CPU run task First Task after 75 ms ?

I think CPU generate timer interrupt after 75ms to finish first task and next interrupt after 50ms to finish second Task and next timer interrupt after 60 ms to finish Third task
 

nsaspook

Joined Aug 27, 2009
8,531
Task has three states:
  • Ready -> Task is ready to be executed but not running
  • Running ->Task is executing on the CPU
  • Waiting (for an event): (waiting for an event, I/O for example).

If there are three task's
  • First Task
  • Second Task
  • Third Task

Scheduler decide which one task will run on CPU. Various schemes are used to decide which particular task to run.

Task priority
  • First Task -> Priority 2
  • Second Task -> Priority 3
  • Third Task - > Priority 1

Task priority means third task will run on CPU because it has high priority When it finished First task will because it has second priority and When it finished second task will run on CPU because it's low priority of task
There is an immense amount of information on the subject of task management we can only hint at using superficial questions. These are a few of my personal text books on this subject and other OS aspects.
Find a few, read and understand them like most of us did.

 

MrChips

Joined Oct 2, 2009
23,960
Estimated execution time : scheduler decide task to run according to estimated execution time
  • First Task -> 75 ms
  • Second Task -> 50 ms
  • Third Task - > 60 ms

I have little bit doubt

Does CPU gives 75ms time to finish the First Task ?
Does CPU run task First Task after 75 ms ?

I think CPU generate timer interrupt after 75ms to finish first task and next interrupt after 50ms to finish second Task and next timer interrupt after 60 ms to finish Third task
In the world of concurrent RTOS, 60ms is like eternity. It really depends on the specific application of the system.
Every task will be given a time-out allowance. If a time-out has occurred with no response from the task then the task may be terminated.
 
Top