Real Time Operating System Tutorial - part2


In this tutorial, i have introduced the Task object and its functionality. Two basics algorithm of RTOS are described with simple diagrams.

What is Task Management?

Task Management allows programmers to design their software as a number of separate tasks (chunks of codes) with each handling a distinct goal and deadline.

Task Management includes
·         Task Object
·         Task Scheduling (Provides multitasking feature)
·         Task Synchronization
·         Inter-task Communication

What is a task?

The application is divided into small, schedulable and sequential program units to achieve concurrency in real time systems known as TASK. Generally kernel allocates some chunk of time to the task as they needed to run.

What is a task object?

A task object is defined by the following set of components:
·         Task Control block
·         Task Stack (Stack memory dedicated for Task in RAM)
·         Task Routine (Program code residing in ROM)

What is Task Control Block (TCB) ?

·         A complex data structures is used for task management are Task Control Block and Stack.
·         The Task Control Block stores all the information (task state, priority, etc..,) about the task as shown in Fig 1.6. Each task has its own TCB and stack.
·         By using TCBs the Kernel identifying and managing the tasks.


Task Control Block


Task States:

A task can typically be any of the following states:
·         Dormant or Sleeping   
·         Ready
·         Running
·         Pending  


Task States




Ready: A task is ready to run is said to be in ready state.
Running (Active): A task is currently being executed by the CPU is said to be in running state.
Pending (Waiting): A task is waiting for an event like a time-out, message, semaphore, or a
Signal is said to be in Pending state.
Dormant: Any task which has been defined in memory but not yet initialized or started is said be in Dormant.

        Each task may exist in any of the four states as shown in fig 1.7.During the execution of an application program, individual tasks are continuously changing from one state to another. However at particular instant of time only one task will be in running state. In the process where CPU control is change from one task to another, context of the to-be-suspended task will be saved while context of the to-be-executed task will be retrieved. This process of saving the context of a task being suspended and restoring the context of a task being resumed is called context switching.


Task Scheduling:

Task Scheduling is a plan of allocating resources (time, memory, statck) for tasks in multitasking systems.
A set of algorithms are used to handle Task Scheduling is called Scheduler.
Generally the scheduler keeps record of the state of each task (using TCB of the tasks) and selects the next task to be executed and allocates the CPU time to one of them. A scheduler helps to maximize CPU utilization among different tasks in a multi-tasking program and to minimize waiting time.

There are two types of Scheduling Algorithms are there:
·         Non-preemptive scheduling
·         Preemptive Scheduling

Non-preemptive scheduling:

In non-preemption scheduling there are two algorithms
·         Co-operative scheduling
·         Round robin scheduling

    In Co-operative scheduling all tasks cooperate with each other to explicitly give up control of the processor. When CPU executing a task, until the completion of the task the CPU control will not be transfer to other task.

        In Round robin scheduling, the algorithm is designed based upon sharing of CPU time between different tasks. i.e., All runnable(ready to execute) tasks are kept in a circular queue. The CPU scheduler goes around this queue, allocating the CPU time (generally in milliseconds) to each task. If the allocated time of a particular task is expired then CPU control is transferred to next task to be executed and the current task is added to the tail of the queue.

        In Round Robin Scheduling all tasks have same Priority; this shows parallel execution of several tasks. off course tasks are not really executed concurrently but because of the time slice allocated for each task is short (only a few milliseconds) it appears as though tasks execute simultaneously.


Round Robin Scheduling

Pre-emptive Scheduling:


Priority based preemptive scheduling


1 comment :

Thanks for visiting NPEDUCATIONS. We will contact you soon

1 comments :

Lisa said...

advanced tutorial. thanks so much for educating me. http://www.wordpresstemplates.net/

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

 
Powered by Blogger