Sie sind auf Seite 1von 6

EX NO: DATE: IMPLEMENTION OF DYNAMIC PRIORITY USING LPC2378 AIM: To create a program to run tasks with priority is being

assigned during run time assignment in LPC2378 using IAR Embedded Workbench. ALGORITHM: Initialize the constants like stack size[127] for each tasks as OS_STK Task1stk[128] Declare the task functions with different priority like OSTaskCreate(Task1,0,&Task1stk[127],1); In the main function,create the tasks with different priority for each task. Define each task and define time delay within the tasks Change the priority dynamically within the tasks.

DESCRIPTION: Dynamic priority scheduling is a type of scheduling algorithm in which the priorities are calculated during the execution of the system. The goal of dynamic priority scheduling is to adapt to dynamically changing progress and form an optimal configuration in self-sustained manner. It can be very hard to produce well-defined policies to achieve the goal depends on difficulty of given problem. Earliest deadline first scheduling and least slack time scheduling are examples of Dynamic priority scheduling algorithms. PROGRAMS: #include <includes.h> OS_STK Task1stk[128]; OS_STK Task2stk[128]; OS_STK Task3stk[128]; OS_STK Task4stk[128]; OS_STK Task5stk[128]; OS_STK Task6stk[128]; void Task1(void *pdata); //Declare the task functions //Initialize the stack sizes for each task

void Task2(void *pdata); void Task3(void *pdata); void Task4(void *pdata); void Task5(void *pdata); void Task6(void *pdata); void main () { BSP_IntDisAll(); BSP_Init(); OSInit(); OSTaskCreate(Task1,0,&Task1stk[127],1); OSTaskCreate(Task2,0,&Task2stk[127],2); OSTaskCreate(Task3,0,&Task3stk[127],3); OSTaskCreate(Task4,0,&Task4stk[127],4); OSTaskCreate(Task5,0,&Task5stk[127],5); OSTaskCreate(Task6,0,&Task6stk[127],6); OSStart(); } //Define each task void Task1(void *pdata) { for(;;) { printf("\n\r TASK1 "); printf("\n"); OSTimeDlyHMSM(0,0,3,50); } } void Task2(void *pdata) { for(;;) //Delay for 3sec and 50 msec// //Create the tasks with different priority

{ printf("\n\r TASK2 "); printf("\n"); OSTimeDlyHMSM(0,0,3,50); } } void Task3(void *pdata) { for(;;) { printf("\n\r TASK3 "); printf("\n"); INT8U err = OSTaskChangePrio(6,12); //Change the priority from 6 to 12 OSTimeDlyHMSM(0,0,3,50); } } void Task4(void *pdata) { for(;;) { printf("\n\r TASK4 "); printf("\n"); OSTimeDlyHMSM(0,0,3,50); } } void Task5(void *pdata) { for(;;) { printf("\n\r TASK5 "); printf("\n"); //Delay for 3sec and 50 msec//

INT8U err = OSTaskChangePrio(3,18); //Change the priority from 3 to 18// OSTimeDlyHMSM(0,0,3,50); } } void Task6(void *pdata) { for(;;) { printf("\n\r TASK6 "); printf("\n"); INT8U err = OSTaskChangePrio(2,20); //Change the priority from 2 to 20// OSTimeDlyHMSM(0,0,3,50); } }

SNAPSHOTS:

Fig 1: Tasks running according to pre-assigned priority

Fig 2: Tasks running according to dynamic priority

RESULT: Thus the program for running tasks with dynamic priority is executed and the result is viewed in WinXTalk tool.

Das könnte Ihnen auch gefallen