Rtos 3 & 4
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Rtos 3 & 4



this slide ll be helpful for those who are in search of real time systems.

this slide ll be helpful for those who are in search of real time systems.



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Rtos 3 & 4 Presentation Transcript

  • 1. Kernel Structure
    • This chapter describes some of the structural aspects of μC/OS-II.
    • How μC/OS-II handles access to critical sections of code,
    • What a task is, and how μC/OS-II knows about your tasks,
    • How tasks are scheduled,
    • How μC/OS-II can determine how much of CPU your application is using,
    • How do to write Interrupt Service Routines (ISRs),
    • What a clock tick is and how μC/OS-II handles it,
    • How to initialize μC/OS-II and,
    • How to start multitasking.
    • μC/OS-II like all real-time kernels need to disable interrupts in order to access critical sections of code, and re-enable interrupts when done.
    • This allows μC/OS-II to protect critical code from being entered simultaneously from either multiple tasks or ISRs.
    • To hide the implementation method chosen by the compiler manufacturer, μC/OS-II defines two macros to disable and enable interrupts:
    • Because these macros are processor specific, they are found in a file called OS_CPU.H.
    • Each processor port will thus have its own OS_CPU.H file.
  • 3. Tasks
    • A task is active entity which could do some computations.
    • A task is typically an infinite loop function
  • 4.
    • Alternatively, the task can delete itself upon completion
    • Also, if the task calls OSTaskDel(), the task code doesn’t return back to anything.
  • 5. Task States
  • 6. Task Control Blocks (OS_TCBs)
    • When a task is created, it is assigned a Task Control Block, OS_TCB .
    • A task control block is a data structure that is used by μC/OS-II to maintain the state of a task when it is preempted.
    • When the task regains control of the CPU the task control block allows the task to resume execution exactly where it left off.
    • All OS_TCBs reside in RAM.
    • An OS_TCB is initialized when a task is created
  • 7.  
  • 8. Ready List
    • Each task is assigned a unique priority level between 0 and OS_LOWEST_PRIO
    • Task priority OS_LOWEST_PRIO is always assigned to the idle task when μC/OS-II is initialized.
    • Each task that is ready to run is placed in a ready list consisting of two variables, OSRdyGrp and OSRdyTbl[].
    • Each bit in OSRdyGrp is used to indicate whenever any task in a group is ready to run.
    • When a task is ready to run it also sets its corresponding bit in the ready table, OSRdyTbl[].
    • To determine which priority (and thus which task) will run next, the scheduler determines the lowest priority number that has its bit set in OSRdyTbl[].
  • 9. Ready List
  • 10. Task Scheduling
    • μC/OS-II always executes the highest priority task ready to run.
    • The determination of which task has the highest priority and thus, which task will be next to run is determined by the scheduler.
    • Task level scheduling is performed by OSSched().
  • 11. Locking and Unlocking the Scheduler
    • The OSSchedLock() function is used to prevent task rescheduling until its counterpart, OSSchedUnlock(), is called.
    • The task that calls OSSchedLock() keeps control of the CPU even though other higher priority tasks are ready to run.
  • 12. Idle Task
    • μC/OS-II alwa ys creates a task the Idle Task which is executed when none of the other tasks is ready to run.
    • The idle task ( OSTaskIdle()) is always set to the lowest priority, i.e. OS_LOWEST_PRIO.
    • OSTaskIdle() does nothing but increment a 32 -bit counter called OSIdleCtr. OSIdleCtr is used by the statistics task to determine how much CPU time (in percentage) is actually being consumed by the application software.
  • 13. Statistics Task
    • μC/OS-II contains a task that provides run-time statistics. This task is called OSTaskStat()
    • Created if you set the configuration constant OS_TASK_STAT_EN to 1.
    • When enabled , OSTaskStat() executes every second and computes the percentage of CPU usage.
    • In other words, OSTaskStat() will tell you how much of the CPU time is used by your application, in percentage.
    • This value is placed in the variable OSCPUUsage which is a signed 8-bit integer.
  • 14. μ C/OS-II Initialization
  • 15. Data structures after calling OSInit()
  • 16. Starting μ C/OS-II
    • You start multitasking by calling OSStart() . Before you start μC/OS-II, however, you MUST create at least one of your application tasks as shown in listing
    Initializing and Starting μ C/OS-II. Starting multitasking.
  • 17. Task Management
    • Creating a Task, OSTaskCreate()
    • OSTaskCreate (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT8U prio)
  • 18. Stack Checking, OSTaskStkChk()
    • It is sometimes necessary to determine how much stack space a task actually uses.
  • 19. Deleting a Task, OSTaskDel()
    • It is sometimes necessary to delete a task. Deleting a task means that the task will be returned to the DORMANT state
    • And does not mean that the code for the task will be deleted.
    • The task code is simply no longer scheduled by μC/OS -II.
    • You delete a task by calling OSTaskDel()
    • Requesting a task to delete itself , OSTaskDelReq()
  • 20. Changing a Task’s Priority, OSTaskChangePrio()
    • When you create a task, you assign the task a priority. At run-time, you can change the priority of any task by calling OSTaskChangePrio().
    • In other words, μC/OS-II allows you to change priorities dynamically.
  • 21. Suspending a Task, OSTaskSuspend()
    • It is sometimes useful to explicitly suspend the execution of a task.
    • This is accomplished with the OSTaskSuspend() function call.
    • A suspended task can only be resumed by calling the OSTaskResume() function call.
  • 22. Getting Information about a Task, OSTaskQuery()
    • Your application can obtain information about itself or other application tasks by calling OSTaskQuery().
    • In fact, OSTaskQuery() obtains a copy of the contents of the desired task’s OS_TCB.
  • 23. Time Management
    • This chapter will describe five services that deal with time issues:
    • 1) OSTimeDly(),
    • 2) OSTimeDlyHMSM(),
    • 3) OSTimeDlyResume(),
    • 4) OSTimeGet() and,
    • 5) OSTimeSet().
    • The functions described in this chapter are found in the file OS_TIME.C.