Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about time period for task execution in UC/OS-II RTOS

Status
Not open for further replies.

Arivu.eagle

Newbie level 2
Newbie level 2
Joined
Dec 14, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
Hi,
I have a big doubt in "RTOS", How Rtos switch over each tasks, tht means " is there any time period for each task's execution!!!!!!! Please let me clear ma doubt!!!!!!!!!!!!!!!
 

re: Uc/os-ii Questions?

Scheduling Algorithms
the scheduler determines which task runs by following a scheduling algorithm (also known as scheduling policy). Most kernels today support two common scheduling algorithms:
 preemptive priority-based scheduling, and
 round-robin scheduling.
The RTOS manufacturer typically predefines these algorithms; however, in some cases, developers can create and define their own scheduling algorithms.
Preemptive Priority-Based Scheduling
Of the two scheduling algorithms introduced here, most real-time kernels use preemptive priority-based scheduling by default. the task that gets to run at any point is the task with the highest priority among all other tasks ready to run in the system.

Real-time kernels generally support 256 priority levels, in which 0 is the highest and 255 the lowest. Some kernels appoint the priorities in reverse order, where 255 is the highest and 0 the lowest. Regardless, the concepts are basically the same. With a preemptive priority-based scheduler, each task has a priority, and the highest-priority task runs first. If a task with a priority higher than the current task becomes ready to run, the kernel immediately saves the current task’s context and switches to the higher-priority task. E.g task 1 is preempted by higher-priority task 2, which is then preempted by task 3. When task 3 completes, task 2 resumes; likewise, when task 2 completes, task 1 resumes.
Although tasks are assigned a priority when they are created, a task’s priority can be changed dynamically using kernel-provided calls. The ability to change task priorities dynamically allows an embedded application the flexibility to adjust to external events as they occur, creating a true real-time, responsive system. Note, however, that misuse of this capability can lead to priority inversions, deadlock, and eventual system failure.

Round-Robin Scheduling
Round-robin scheduling provides each task an equal share of the CPU execution time. Pure round-robin scheduling cannot satisfy real-time system requirements because in real-time systems, tasks perform work of varying degrees of importance. Instead, preemptive, priority-based scheduling can be augmented with round-robin scheduling which uses time slicing to achieve equal allocation of the CPU for tasks of the same priority .

Round-robin and preemptive scheduling.
With time slicing, each task executes for a defined interval, or time slice, in an ongoing cycle, which is the round robin. A run-time counter tracks the time slice for each task, incrementing on every clock tick. When one task’s time slice completes, the counter is cleared, and the task is placed at the end of the cycle. Newly added tasks of the same priority are placed at the end of the cycle, with their run-time counters initialized to 0.
If a task in a round-robin cycle is preempted by a higher-priority task, its run-time count is saved and then restored when the interrupted task is again eligible for execution. task 1 can be interrupted by a higher-priority task 4 but resumes where it left off when task 4 completes.
 
re: Uc/os-ii Questions?

if that is a PREEMPTIVE Kernel after interrupt triggered the cpu will service that ISR immediately even though the CPU currently execute highest priority task, obviously UCOS-II is PREEMPTIVE.

my question is, all my three Task's are independent while loop, it will run for ever.
So, after ma OS starts, at 10ms it will get the TICK interrupt, after serviced that ISR the CPU starts to execute TASK1( highest PRIORITY) it will run continuously because of while loop, then afetr 10 msec it will get the same Tick Interrupt and then it will do the same work,,, service the ISR and then Highest PRIO Task. Then how ma TASK 2 & 3 will get the CPU Time???????????????
 

ckshivaram is right, you need to make task 1 (Highest priority) go to "Block State" so that other tasks can get the chance to run.
This case is called "Resource starvation" where tasks 2 and 3 don't get the chance to run. To solve this issue, you must modify your design to make all tasks run at least once otherwise, you can remove this task and free the memory.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top