Getting Started with the µC/OS-III Real Time Kernel

Slides:



Advertisements
Similar presentations
Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Advertisements

Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Processes 1 CS502 Spring 2006 Processes Week 2 – CS 502.
Chapter 13 Embedded Systems
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
MicroC/OS-II Embedded Systems Design and Implementation.
Threads and Critical Sections Vivek Pai / Kai Li Princeton University.
ΜC/OS-III Tasks Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
Getting Started with the µC/OS-III Real Time Kernel Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
CS 162 Discussion Section Week 2. Who am I? Wesley Chow Office Hours: 12pm-2pm 411 Soda Does Monday 1-3 work for everyone?
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Embedded Systems OS. Reference Materials The Concise Handbook of Real- Time Systems TimeSys Corporation.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Department of Computer Science and Software Engineering
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
1 OS Review Processes and Threads Chi Zhang
C H A P T E R E L E V E N Concurrent Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Message Passing Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
SOC Consortium Course Material SoC Design Laboratory Lab 8 Real-time OS - 1 Speaker: Yung-Chih Chen Advisor: Prof. Chun-Yao Wang November 17, 2003 Department.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Chapter 7: Semaphore Management Seulki Lee 1. Semaphore?  A protocol mechanism offered by most multitasking kernels  Control access to a shared resource.
Synchronization Akos Ledeczi EECE 6354, Fall 2013 Vanderbilt University.
Big Picture Lab 4 Operating Systems C Andras Moritz
Chapter 1: Getting Started with μC/OS-II 1. kernel Introduction 2 LinuxμC/OS-II Task (process) kernel Device driver User mode (0-3G) (Kernel mode) 3G-4G.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Embedded Real-Time Systems
1.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 1: Introduction What Operating Systems Do √ Computer-System Organization.
WORKING OF SCHEDULER IN OS
REAL-TIME OPERATING SYSTEMS
EMERALDS Landon Cox March 22, 2017.
Advanced Operating Systems CIS 720
Sarah Diesburg Operating Systems COP 4610
Topics Covered What is Real Time Operating System (RTOS)
CS703 – Advanced Operating Systems
Background on the need for Synchronization
OPERATING SYSTEMS CS3502 Fall 2017
Interrupt and Time Management in µC/OS-III
Real-time Software Design
Concurrency: Mutual Exclusion and Synchronization
Computer System Overview
Scheduling in µC/OS-III
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Concurrency: Mutual Exclusion and Process Synchronization
CSCI1600: Embedded and Real Time Software
CSE 153 Design of Operating Systems Winter 19
CSCI1600: Embedded and Real Time Software
Chapter 3: Process Concept
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 3: Process Management
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Getting Started with the µC/OS-III Real Time Kernel Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University

What is an RTK? What is an RTOS? The main task of an RTK is to manage time and the resources of a (typically embedded) computer Multitasking Creation Scheduling Synchronization Communication Resource management: Memory IO Interrupt management Time management What is an RTOS? An RTK plus higher level services such as file system, networking, GUI, etc.

Multitasking Also called multithreading or concurrent programming Multiple, sequential tasks (or threads) Creating the illusion of having multiple CPUs The task body is just a C function Each task has its own stack The same body can be reused for multiple tasks Synchronization and communication are very important and complicated Advantages: Modular code Manages complexity inherent in RT systems Cleaner and easier to understand and maintain

Multitasking cont’d. Because of the need to respond to timing demands made by different stimuli/responses, the system architecture must allow for fast switching between stimulus handlers. Because of different priorities, unknown ordering and different timing requirements of different stimuli, a simple sequential loop is not usually adequate. Real-time systems are therefore usually designed as cooperating processes with a real-time kernel controlling these processes.

µC/OS-III: Creating and Initializing an App Start in main(): Disable interrupts Initialize OS Create a single Task using TaskCreate() Start OS: start multitasking and switch to the highest priority enabled task

OS Initialization Initializes internal data structures Creates up to 5 Tasks: Idle Task (lowest priority task that runs when nothing else is available for running; it never blocks) Tick Task (keeps track of time) Statistics (optional) Timer (optional) Interrupt queue management (optional)

Task Creation OSTaskCreate() 13 arguments: Task Control Block (TCB): data structure that the OS uses to manage the task and store all relevant info about it (e.g. stack pointer, priority, pointers to manage queues, etc.) Name Function pointer to actual code Argument for the task (e.g., a pointer to a task-specific memory making the C function reusable for multiple tasks) Stack pointer, watermark, size Error code Etc.

Initial task Initialize hardware and CPU related things Set up tick interrupt (rate = OSCfg_TickRateHz) Enable interrupts Create additional tasks (optional) Infinite loop: Inside there must be a blocking call

Critical Sections Code that needs to run indivisibly How? Access to shared resources, for example, hardware device, shared variable, data structures, etc. How? Disable interrupts Lock the scheduler Use semaphores Finer control (on a task by task basis) More overhead

Semaphores Dijkstra in 1959 “Key” to “locked code.” You need to acquire it to access the code. Semaphore operations are “atomic.” Binary and counting semaphores Can be used for resource sharing and synchronization Functions: OSSemCreate() OSSemPend() OSSemPost() OSSemDel() OSSemSet() OSSemPendAbort()

Binary Semaphores Accessing a printer Hiding behind an API

Binary Semaphores cont’d. OS_SEM MySem; void main() { OS_ERR err; … OSSemCreate(&MySem, ”My Semaphore”, 1, &err); } void Task1 (void *p_arg) CPU_TS ts; while (1) { OSSemPend(&MySem, 0, OS_OPT_PEND_BLOCKING, &ts, &err); /*critical section */ OSSemPost(&MySem, OS_OPT_POST_1, &err); /* check err */

Counting Semaphores When multiple resources/resource elements are available E.g., memory pool or circular buffer Initialize semaphore to the number of items available Need to manage consumed/available items Pend() waits on 0, otherwise, decrements counter and returns Post() increments counter