chap 05-2019F.pdf - Task Management Chapter 5 Introduction A task(also called a thread a simple program that thinks it has the CPU all to itself On a

chap 05-2019F.pdf - Task Management Chapter 5 Introduction...

This preview shows page 1 - 6 out of 25 pages.

Task ManagementChapter 5
Background image
Introduction}A task (also called a thread) }a simple program that thinks it has the CPU all to itself. }On a single CPU, only one task can execute at any given time.}The design process of a real-time application generally involves splitting the work to be completed into tasks, each responsible for a portion of the problem. }μC/OS-III makes it easy for an application programmer to adopt this paradigm. }μC/OS-III supports multitasking and allows the application to have any number of tasks.}Multitasking is the process of scheduling and switching the CPU between several tasksFall 2019Task Management2
Background image
Introduction}Multitasking }the process of scheduling and switching the CPU between several tasks}The CPU switches its attention between several sequential tasks.}Multitasking provides the illusion of having multiple CPUs and, actually maximizes the use of the CPU. }Multitasking also helps in the creation of modular applications. }it allows the application programmer to manage the complexity inherent in real-time applications.}Application programs are typically easier to design and maintain when multitasking is used.Fall 2019Task Management3
Background image
Introduction}Tasks }look like just any other C function except for a few small differences. }Two types of tasks: Fall 2019Task Management4void MyTask (void *p_arg){OS_ERR err;/* Local variables *//* Do something with ‘p_arg’ *//* Task initialization *//* Task body ... do work! */OSTaskDel((OS_TCB *)0, &err);}void MyTask (void *p_arg){/* Local variables *//* Do something with “p_arg” *//* Task initialization */while (DEF_ON) { /* Task body, as an infinite loop. */:/* Task body ... do work! */:/* Must call one of the following services: *//* OSFlagPend() *//* OSMutexPend() *//* OSPendMulti() *//* OSQPend() *//* OSSemPend() *//* OSTimeDly() *//* OSTimeDlyHMSM() *//* OSTaskQPend() *//* OSTaskSemPend() *//* OSTaskSuspend() (Suspend self) *//* OSTaskDel() (Delete self) */:/* Task body ... do work! */:}}infinite loop*run-to-completion*The infinite loop must call a OS service that will cause the task to wait for an event to occur. Otherwise, the task would be a true infinite loop and there would be no easy way for other tasks to execute.
Background image
Introduction}When a task waits for an event, it does not consume CPU time.
Background image
Image of page 6

You've reached the end of your free preview.

Want to read all 25 pages?

  • Fall '19
  • kim

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors