Hands-on Workshop: Freescale MQX and Tower System RTOS Getting Started (Part 2)

Size: px
Start display at page:

Download "Hands-on Workshop: Freescale MQX and Tower System RTOS Getting Started (Part 2)"

Transcription

1 August, 2010 Hands-on Workshop: Freescale MQX and Tower System RTOS Getting Started (Part 2) ENT-F0720 Shen Li and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc.

2 This course covers the fundamentals of the MQX RTOS including: Task Task Prioritization Scheduling Synchronization Interrupt handling Introduction With the concepts presented in this session you will have an understanding of what MQX is and how you can use it to create tasks, use interrupts, and create synchronization between the tasks. Presenters: Doug Bruce, Embedded Access Inc Craig Honegger, Embedded Access Inc Session duration is 3 hours. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 2

3 After completing this session you will be able to: Understand what an RTOS is and how they can be used Create MQX Tasks Understand MQX scheduling concepts Use various MQX Synchronization mechanisms for Mutual Exclusion Control Flow Data Flow Build a simple MQX application Session Objectives and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 3

4 Module Agenda 1. What is an RTOS 2. MQX Basics Tasks Priorities and Scheduling Hands-on 3. Task Synchronization Mutexes Events Semaphores Hands-on Messages Hands-on 4. Additional Resources 5. Review and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 4

5 Real-Time Operating Systems and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 5

6 Operating Systems The term operating system can be used to describe the collection of software that manages a system s hardware resources This software might include a file system module, a GUI and other components Often times, a kernel is understood to be a subset of such a collection Characteristics Resource management Interface between application and hardware Library of functions for the application User Application Operating System HARDWARE and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 6

7 Fusion of the application and the OS to one unit Embedded Operating Systems Characteristics Resource management Primary internal resources Less overhead Code of the OS and the application mostly reside in ROM User Operating System + Application HARDWARE and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 7

8 A real-time operating system (RTOS) manages the time of a microprocessor or microcontroller Features of an RTOS: Allows multi-tasking Scheduling of the tasks with priorities Synchronization of the resource access Inter-task communication Time predictable Interrupt handling Real Time Operating Systems and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 8

9 Why use an RTOS? Plan to use drivers that are available with an RTOS Would like to spend your time developing application code and not creating or maintaining a scheduling system Multi-thread support with synchronization Portability of application code to other CPUs Resource handling Add new features without affecting higher priority functions Support for upper layer protocols such as: TCP/IP, USB, Flash Systems, Web Servers, CAN protocols, Embedded GUI, SSL, SNMP and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 9

10 RTOS RTOS Terminology Real Time Operating System The first layer of software that runs on top of the CPU Task or Thread A portion of a program that, from its perspective, has the CPU to itself Multitasking A system consists of multiple tasks that take turns running Only one task per CPU is active (has the CPU) at any given time MQX manages how the tasks share the CPU (context switching) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 10

11 Scheduler RTOS Terminology (cont d) Portion of the RTOS that decides which task to execute next, based on certain rules Scheduling Policy Determines how the task is handled (in what order they run) by the scheduler Task Context Data structure stored for each task, including registers and a list of owned resources Context Switch Switch between running tasks by saving/restoring tasks contexts. Blocking vs. Non-blocking Blocking causes running task to be removed from Read Q, Non-blocking does not. Non-blocking calls may still cause a context switch! and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 11

12 Synchronization RTOS Terminology (cont d) One task affects another s execution, so that tasks execute in an application-controlled order Active Task Post Wait Blocked Task and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 12

13 Mutual Exclusion RTOS Terminology (cont d) Allowing only one task at a time to access a shared resource Protected Resource TASK 1 Lock do work Unlock TASK 3 Lock do work Unlock M TASK 2 Lock do work Unlock TASK 4 Lock do work Unlock and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 13

14 We will be using Freescale MQX to demonstrate these RTOS concepts Freescale MQX Software can be downloaded: Default Freescale MQX folder: C:\Program Files\Freescale\Freescale MQX 3.5 Freescale MQX and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 14

15 MQX Directory Structure Described in the MQX Release Notes Folders are: config demo doc lib mqx tools And then the RTCS, USB, and MFS stacks and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 15

16 MQX Directory Structure (Cont.) The mqx directory is heart of MQX Folders are: build examples source bsp io psp MQX API source and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 16

17 Tasks and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 17

18 MQX Tasks A system consists of multiple tasks Tasks take turns running Only one task is active (has the processor) at any given time MQX manages how the tasks share the processor (context switching) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 18

19 Tasks Each task should have a specific action that it takes Can have multiple tasks from same template, and each is its own instance Each task has a unique 32-bit task ID used by MQX Number of tasks only limited by memory Automatic cleanup of resources when task terminates Can also specify An exit function, which MQX calls when it terminates the task. An exception handler, which MQX calls if an exception occurs while the task is active. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 19

20 Typical Task Coding Structure and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 20

21 A task is a unique instance of a task template Overview of Task Management A task is defined by its task descriptor, which includes: Context program counter stack registers Priority Resources Task ID Task-specific parameters TD Task1 Registers PC SP State TaskCode1() {... /* Task Init */ while(1) { /* Task Body */... MyFunc();... } } and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 21

22 Overview of Task Environment TD Task1 TD Task2 TD Task3 TD Task4 Context Switch Registers PC SP CPU Registers PC SP State Registers PC SP State Registers PC SP State Registers PC SP State TaskCode1() {... /* Task Init */ while(1) { /* Task Body */... MyFunc();... } } OtherTaskCode() {... /* Task Init */ while(1) { /* Task Body */... ReEntrantFunc();... } } ReEntrantFunc() {... } and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 22

23 A task is in one of these logical states: Blocked the task is blocked and therefore not ready it s waiting for a condition to be true Active the task is ready and is running because it s the highest-priority ready task Ready the task is ready, but it s not running because it isn t the highest-priority ready task Ready Active Task States Blocking call Context Switch Object available Blocked and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 23

24 T MQX Tasks Tasks can be automatically created when MQX Starts; also, any task can create another task by calling _task_create() or _task_create_blocked() _task_block _task_create_blocked active _task_abort _task_destroy The function _task_create() puts the new task in the ready state and the scheduler runs the highest priority task blocked _task_ready terminated If _task_create_blocked is used the task is not ready until _task_ready() is called _task_create ready and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 24

25 MQX_template_list TASK_TEMPLATE_STRUCT defined in \mqx\source\include\mqx.h _mqx_uint TASK_TEMPLATE_INDEX void (_CODE_PTR_)(uint_32) TASK_ADDRESS _mem_size TASK_STACKSIZE _mqx_uint TASK_PRIORITY char _PTR_ TASK_NAME _mqx_uint TASK_ATTRIBUTES uint_32 CREATION_PARAMETER _mqx_uint DEFAULT_TIME_SLICE Possible Task Attributes MQX_AUTO_START_TASK MQX_TIME_SLICE_TASK And more and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 25

26 MQX_Template_list AKA Task Template Structure { MAIN_TASK, world_task, 0x3000, 9, "world_task", MQX_AUTO_START_TASK, 0L, 0}, { HELLO, hello_task, 0x1000, 8, "hello_task", MQX_TIME_SLICE_TASK, 0L, 100}, { LED, float_task, 0x2000, 10, "Float_task", MQX_AUTO_START_TASK MQX_FLOATING_POINT_TASK, 0L, 0}, and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 26

27 Creating a Task When creating a task you have to: Create task prototype and index definition #define INIT_TASK 5 extern void init_task(uint_32); Add the task in the Task Template List Using the init_task example: TASK_TEMPLATE_STRUCT MQX_template_list[] = { {INIT_TASK, init_task, 1500, 9, "init", MQX_AUTO_START_TASK, 0, 0}, } Define the task void init_task(void) { /* Put the Task Code here */ } During execution time, create the task (if it is not an autostart Task) _task_create() and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 27

28 Task Prioritization and Scheduling and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 28

29 Priorities Priorities run from 0 to N Priority 0 means interrupts disabled, 1 is most important task N is set by the highest priority number in the MQX_Template_List Idle task runs at N+1 MQX creates one ready queue for each priority up to the lowest priority (highest number) So must make sure priorities are consecutive Able to change priority of a task during runtime _task_set_priority() Any tasks at priority below 6 means it masks certain levels of interrupts. So user tasks should start at 7 or above. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 29

30 Context Switching If Task A is running, it will stop running and call the scheduler if: Calls a blocking function Timeslice expires (Round Robin) A higher priority task is made ready Interrupt Occurs Then: Context of Task A is stored Context of highest priority task in the ready queue is restored Task A gets put at the end of either the ready or wait queue, depending on reason it stopped running If called a blocking function, gets put in wait queue Else put back in ready queue and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 30

31 Preemption Preemption occurs when a higher-priority task becomes ready, and thus becomes the active task. The previously active task is still ready, but is no longer the active task. Occurs when: An interrupt handler causes a higher-priority task to become ready, Active task makes a higher-priority task ready. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 31

32 T Scheduler Common Scheduling Configurations: FIFO (also called priority-based preemptive) The active task is the highest-priority task that has been ready the longest Round Robin The active task is the highest-priority task that has been ready the longest without consuming its time slice and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 32

33 T Priority Based FIFO Scheduling high priority low FIFO list of ready tasks CPU Scheduler active processor time and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc.

34 T Round-Robin Scheduling Task 1 Same Priority Time Slice = 50ms 75ms Task 2 50ms Task 3 60ms time Ready Task1 Task2 Task3 Task1 Task3 T0 50ms 100ms 150ms 200ms time and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc.

35 Idle Task Lowest priority task Simply increments a counter, which can be used to determine how long nothing is happening in the system Optional MQX_USE_IDLE_TASK Located in \mqx\source\kernel\idletask.c in the PSP project, under the kernel directory and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 35

36 T MQX - Task Management Example {INIT_TASK, init_task, 1500, 11, "init", MQX_AUTO_START_TASK, 0, 0}, {TASK_A, Task_A, 1500, 10, Task A", 0, 0, 0}, {TASK_B, Task_B, 1500, 9, Task B", 0, 0, 0}, void init_task(void) { _task_create(0,task_a,0);... _task_ready(task_b);... } void Task_A(void) {... _task_create_blocked(0,task_b,0);... _task_abort(task_a); } void Task_B(void) { init_task is created when MQX starts }... _task_abort(task_b); CPU Time and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc.

37 Write Your First RTOS Application Exercise: Run your first application and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 37

38 Synchronization and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 38

39 Why Synchronization? Synchronization may be used to solve: Mutual Exclusion Control Flow Data Flow EF Synchronization Mechanisms include: Semaphores Events Mutexes Message Queues M The correct Synchronization Mechanism depends on the synchronization issue being addressed. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 39

40 Mutual Exclusion Mutual Exclusion prevents multiple tasks from simultaneously accessing the same resource Resource may be Code, Data, Peripheral, etc. Mutual Exclusion locks the Resource and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 40

41 Control Flow Control Flow provides a mechanism for a task or ISR to resume execution of one or more other tasks Mutual exclusion is used to prevent another task from running Control Flow is used to allow another task to run Not all synchronization objects are suitable for control flow: Good: Non-strict Semaphores, Events, Messages, Task Qs Bad: Mutexes, Strict Semaphores and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 41

42 Data Flow provides a mechanism for a task or ISR to resume execution of one or more other tasks with data Data Flow Mutual exclusion is not necessary Messages are the primary means of data flow synchronization and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 42

43 Attributes of MQX Synchronization Mechanisms Reference by name vs. by address Strict One-to-One vs. One-to-Many Convey information Priority queuing Priority inheritance Multi-processor capable Ownership tracking and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 43

44 MQX Mutexes and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 44

45 Mutex Mutexes are used for mutual exclusion, so that only one task at a time uses a shared resource such as data or a device. To access the shared resource, a task locks the mutex associated with the resource. The task owns the mutex, until it unlocks the mutex. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 45

46 Mutex example There task are then tries unlocks tasks. to tries lock Task the to the Mutex lock 2 locks Mutex the and Mutex the but the Mutex. it task but is already it 31 is locks already locked it. locked so task so 1 task waits 3 in waits the Mutex s in the Mutex s queue. queue. Task 1 (H) Task 2 (M) Task 3 (L) Mutex Task 2 Mutex Queue Task 3 Task 1 Resource and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 46

47 Overview of MQX Mutexes MQX Optional Component Attributes control operation Identified by address No limit to the number of mutexes M Init Lock Unlock Try Lock Set Priority Ceiling Destroy and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 47

48 Using mutexes To declare a MUTEX: MUTEX_STRUCT mutex; To initialize the mutex with default attributes: result = _mutex_init(mutex_ptr, NULL) To lock a mutex: _mqx_uint _mutex_lock(mutex_ptr) To unlock a mutex: _mqx_uint _mutex_unlock(mutex_ptr) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 48

49 Semaphores and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 49

50 Semaphores A semaphore is a protocol mechanism offered by most multitasking kernels. Semaphores are used to: control access to a shared resource (mutual exclusion) signal the occurrence of an event allow two tasks to synchronize their activities A semaphore is a token that your code acquires in order to continue execution. If the semaphore is already in use, the requesting task is suspended until the semaphore is released by its current owner. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 50

51 A semaphore has: counter maximum number of concurrent accesses queue for tasks that wait for access If a task waits for a semaphore if counter > 0 counter is decremented by 1 task gets the semaphore and can do work else task is put in the queue If a task releases (post) a semaphore if at least one task is in the semaphore queue appropriate task is readied, according to the queuing policy else counter is incremented by 1 How semaphores work and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 51

52 How Semaphores Work (n) Resources protected by semaphore A semaphore has: Counter maximum number of concurrent accesses (n) Queue for tasks that wait for access If a task waits for a semaphore If n>0, n is decremented and task runs If n is 0, task is put on the waiting queue When a task releases (posts to) a semaphore If a task is in the queue, task is readied per the queuing policy No queued tasks, n is incremented (n) TASK 1 Wait do work Post TASK 2 Wait do work Post TASK 3 Wait do work Post TASK 4 Wait do work Post and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 52

53 Strictness If a semaphore is strict, a task can t release (post) it unless the task first waited for and got the semaphore the counter is bounded by its initial value If a semaphore isn t strict, a task can release (post) it without first waiting for it the counter is unbounded Uses for non-strict semaphores include: if tasks always wait before posting, faster and lower-overhead non-strict semaphores are safe to use if the semaphore is associated with a dynamically allocated resource, it may need to have its counter increased past its initial count and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 53

54 Semaphore example Most A Depending There task kernels are desiring releases generally on allow the a semaphore only kernel, you three to the specify operations task by will performing a which timeout; that will can if a receive WAIT be the SIGNAL performed semaphore the operation. semaphore on a is If semaphore: the not If no semaphore available is either: task is within is a available certain waiting amount for a) (the INITIALIZE the semaphore, highest of time, (also priority the called value the requesting task semaphore CREATE) is greater waiting task than value for is made the 0), is semaphore, the simply ready to incremented. run orand value an error is decremented code and indicating If any the task b) that WAIT the is continues a waiting first (also timeout task called for execution. has that the PEND) occurred requested semaphore, is the returned however, semaphore to one the (First caller. of the In tasks First is Out, made or FIFO). ready SIGNAL (also called POST). to If run the and semaphore's the semaphore value value is 0, the is not task incremented; performing a the WAIT key on is given the semaphore to one of the is placed The initial value of the semaphore must be provided when the semaphore is initialized. The in tasks a waiting list. for it. waiting list of tasks is always initially empty. Task 1 (H) Task 2 (M) Driver Resource Task 3 (L) 0 Value: 1 Queue Task 3 (L) Task 1 (H) Task Driver 13 2 initializes releases requests the resource. resources; semaphore Task Because 31 gets (i.e. queue value on the priority) resource. is empty >0, drivers gets value the puts assign is resource. Task1 Task3 the in resource the waiting to list. incremented The Task2 queue and decrement strategy can the be semaphore based on priority or FIFO and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 54

55 We have a Bounded buffer: size N The access entry is 0 N-1, then wrap around to 0 again Producer Task writes data to buffer Counting semaphores example Must not write more than N items more than consumer ate Consumer Task reads data from buffer Should not try to consume if there is no data A semaphore is used to have the control of the available space in the buffer. 0 1 N-1 Semaphore = 43 Producer Consumer and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 55

56 Lightweight Semaphore Overview MQX Core Component Useful for: Mutual Exclusion Task Synchronization Count of available resources Not strict count is un-bounded Simple & Small Create Wait Post Poll Wait for Wait ticks Wait until Destroy and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 56

57 To declare a lightweight semaphore: LWSEM_STRUCT sem; Using lightweight semaphores To create a lightweight semaphore: _mqx_uint _lwsem_create(lwsem_ptr,initial_count) To wait for a lightweight semaphore _mqx_uint _lwsem_wait(lwsem_ptr) To post a lightweight semaphore: _mqx_uint _lwsem_post(lwsem_ptr) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 57

58 MQX Events and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 58

59 Events Tasks can wait for a combination of event bits to become set. A task can set or clear a combination of event bits. Events can be used to synchronize a task with another task or with an ISR. The event component consists of event groups, which are groupings of event bits. 32 event bits per group (mqx_unit) Tasks can wait for all or any set of event bits in an event group (with an optional timeout) Event groups can be identified by name or by index (fast event groups) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 59

60 Events Any task can wait for event bits in an event group. If the event bits are not set, the task blocks. When the event bits are set, MQX puts all waiting tasks, whose waiting condition is met, into the task s ready queue. If the event group has autoclearing event bits, MQX clears the event bits as soon as they are set. Can use events across processors (not possible with lightweight events.) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 60

61 Event Bits A task waits for a pattern of event bits (a mask) in an event group with _event_wait_all() or _event_wait_any(). Wait for all the bits in the mask provided to be set or Wait for any of the bits When a bit is set, MQX makes ready the tasks that are waiting for the bit. A task can set a pattern of event bits (a mask) in an event group with Task or ISR code _event_set(). _lwevent_set _lwevent_create 32 bits TaskA _lwevent_wait_for (any) _lwevent_clear OR AND TaskB _lwevent_wait_for (all) _lwevent_clear and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 61

62 Lightweight event groups To declare a lightweight event group: LWEVENT_STRUCT lwevent; To create a lightweight event group: _mqx_uint _lwevent_create(lwevent_ptr, flags) flags NULL or LWEVENT_AUTO_CLEAR To set the specified event bit or bits in a lightweight event group: _mqx_uint _lwevent_set(lwevent_ptr, mask) if this is an auto-clearing event group, only one task is made ready To wait for a number of ticks (in ticks): _mqx_uint _lwevent_wait_ticks(lwevent_ptr,mask,all,ticks) If ticks = 0, the wait is unlimited To clear the specified event bit or bits in a lightweight event group: _mqx_uint _lwevent_clear(lwevent_ptr, mask) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 62

63 LightWeight Events Lightweight events are simpler, low-overhead event implementation. Lightweight event groups are created from static-data structures and are not multi-processor capable. To create a lightweight event group, an application declares a variable of type LWEVENT_STRUCT, and initializes it by calling _lwevent_create() with a pointer to the variable and a flag indicating whether the event group has autoclearing event bits. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 63

64 Write Your First RTOS Application Exercise: Scheduling Lab and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 64

65 Messages and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 65

66 Messages passing Tasks can communicate with each other by exchanging messages. Tasks send messages to message queues, and receive messages from message queues. Messages can be assigned a priority or marked urgent. Tasks can send broadcast messages. and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 66

67 Message format SIZE Header Target QID Source QID Control MESSAGE_HEADER_ STRUCT Application data Messages are areas of memory divided into a header and a data area Application data is user-defined and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 67

68 Message Pools Message Pools are allocated from core memory A message pool is defined by: Message size Initial size Grow amount Max size They contain several equal-sized messages Benefit is fast allocation/de-allocation and no fragmentation Each pool can contain different size messages System can automatically add new messages to a pool if it fills up (i.e. all messages are in use) Message and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 68

69 System Message Pools MSG Size = a MSG Size = b MSG Size = c where a <= b <= c System pools are linked together Messages are allocated on a first-fit basis Easiest type of pool to use Having different sized pools allows for more efficient use of memory, but longer allocation times Created with _msgpool_create_system() and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 69

70 Private Message Pools Pool_A Pool_B Pool_C Private pools are accessed individually via pool ids Allows each part of application to use a different pool Allows more control over how many messages are allocated Create with _msgpool_create() and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 70

71 Message Queues Task A TaskB Each task can have one (or more) messages queues associated with it Messages are always addressed to queues, not tasks Queues are identified by _queue_id This is a combination of queue number and CPU number Create a queue using _msgq_open() and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 71

72 Message passing example Task A Task B Owner _msgpool_create() _msg_alloc() Address the message and add data _msgq_send() _msgq_open() _msgq_receive() Blocking wait Read the message Owner Sending changes ownership _msg_free()or _msgq_send() (forward to any task, including Task A) Message must travel in a loop: Allocate it from a pool Use it Return it to pool (i.e. free it) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 72

73 To create a private message pool: _pool_id _msgpool_create(message_size,num_msg,grow,limit) To get a (fixed-size) message from a private message pool: pointer _msg_alloc(pool_id) To open a private message queue (a resource of the opening task): _queue_id _msgq_open(queue_number,max_queue_size) To send a message (of lowest priority, 0): boolean _msgq_send(msg_ptr) To receive a messages: pointer _msgq_receive(queue_id, ms_timeout) To free a message: _msg_free(msg_ptr) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 73

74 Message passing: Things to remember If the application forwards or returns the message to the sender, the normal rules which apply to memory allocation also apply to message passing: If you continuously allocate messages without freeing them, you will eventually run out of messages!! However, it is perfectly ok to allocate a message and use it over and over by sending it between several tasks The task which owns the message is the only one that can free it and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 74

75 Synchronization Comparison and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 75

76 Attributes of MQX Synchronization Mechanisms LW Sem LW Events LW Msg Sems Events Mutex Msg Reference by Name or ID vs. by Address address address address name name address id Strict Yes Yes One-to-One vs. One-to-Many 1:1 1:many 1:1 1:1 1:1 or 1:many 1:1 1:many Convey Information Yes Yes Yes Yes Priority Queuing Yes Yes Yes Priority Inheritance Yes Yes Multi-processor Capable Yes Yes Yes Ownership tracking Yes Yes Yes Control Flow Yes Yes Yes Yes Yes Yes Data Flow Yes Yes Yes Yes Priority Protection Mutual Exclusion Yes Yes Yes Footprint low low low high high medium high Yes and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 76

77 Write Your First RTOS Application Exercise: Message Passing Lab and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 77

78 Freescale MQX Documentation MQXUG User Guide MQXRM Reference Manual MQXUSBHOSTAPIRM USB Host API Reference Manual MQXUSBDEVAPI USB Device API Reference MQXUSBHOSTUG USB Host User Guide MQXRTCSUG RTCS User Guide MQXMFSUG File System User Guide MQXIOUG I/O Drivers User Guide MQXFS Software Solutions Fact Sheets and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 78

79 TWR-MCF51CN-KIT Lab Document MCF5225x Lab Document MQX Release Notes MQX User s Guide Writing First MQX Application (AN3905) Further Reading and Training Using MQX: RTCS, USB, and MFS (AN3907) How to Develop I/O Drivers for MQX (AN3902) and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 79

80 Videos: Further Reading and Training (Cont.) MCF5225x & Freescale MQX introduction Getting started with MCF5225x and Freescale MQX Lab Demos And more vftf technical session videos Introducing a modular system, Serial-to-Ethernet V1 ColdFire MCU and Complimentary MQX RTOS Writing First MQX Application Implementing Ethernet Connectivity with the complimentary Freescale MQX RTOS and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 80

81 In Summary By now, you should be able to: Understand what an RTOS is and how they can be used Create tasks, schedule them and add synchronization using MQX Create your own MQX applications and VortiQa are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners Freescale Semiconductor, Inc. 81

82

The components in the middle are core and the components on the outside are optional.

The components in the middle are core and the components on the outside are optional. CHAPTER 2 ucosiii Page 1 ENGG4420 CHAPTER 3 LECTURE 8 October 31 12 9:43 AM MQX BASICS MQX Real Time Operating System has been designed for uni processor, multi processor, and distributedprocessor embedded

More information

Real-Time Programming

Real-Time Programming Real-Time Programming Week 7: Real-Time Operating Systems Instructors Tony Montiel & Ken Arnold rtp@hte.com 4/1/2003 Co Montiel 1 Objectives o Introduction to RTOS o Event Driven Systems o Synchronization

More information

Freescale MQX TM Real-Time Operating System. User s Guide

Freescale MQX TM Real-Time Operating System. User s Guide Freescale MQX TM Real-Time Operating System User s Guide Document Number:MQXUG Rev. 1 01/2010 How to Reach Us: Home Page: www.freescale.com E-mail: support@freescale.com USA/Europe or Locations Not Listed:

More information

Freescale MQX Lite RTOS

Freescale MQX Lite RTOS Freescale MQX Lite RTOS Reference Manual Document Number: MQXLITERM Rev 1.3 2 Freescale Semiconductor, Inc. Contents Section number Title Page Chapter 1 Before You Begin 1.1 About MQX Lite...13 1.2 About

More information

Introduction to Real-Time Operating Systems

Introduction to Real-Time Operating Systems Introduction to Real-Time Operating Systems GPOS vs RTOS General purpose operating systems Real-time operating systems GPOS vs RTOS: Similarities Multitasking Resource management OS services to applications

More information

Freescale MQX TM Real-Time Operating System. User s Guide

Freescale MQX TM Real-Time Operating System. User s Guide Freescale MQX TM Real-Time Operating System User s Guide Document Number:MQXUG Rev. 0 04/2009 How to Reach Us: Home Page: www.freescale.com E-mail: support@freescale.com USA/Europe or Locations Not Listed:

More information

Zilog Real-Time Kernel

Zilog Real-Time Kernel An Company Configurable Compilation RZK allows you to specify system parameters at compile time. For example, the number of objects, such as threads and semaphores required, are specez80acclaim! Family

More information

Freescale MQX RTOS for Kinetis SDK Release Notes version beta

Freescale MQX RTOS for Kinetis SDK Release Notes version beta Freescale Semiconductor Document Number: MQXKSDKRN Release Notes Rev 1.0.0, 07/2014 Freescale MQX RTOS for Kinetis SDK Release Notes version 1.0.0 beta 1 Read Me This is the release notes for Freescale

More information

Tasks. Task Implementation and management

Tasks. Task Implementation and management Tasks Task Implementation and management Tasks Vocab Absolute time - real world time Relative time - time referenced to some event Interval - any slice of time characterized by start & end times Duration

More information

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory Embedded Systems 5. Operating Systems Lothar Thiele Computer Engineering and Networks Laboratory Embedded Operating Systems 5 2 Embedded Operating System (OS) Why an operating system (OS) at all? Same

More information

EE458 - Embedded Systems Lecture 8 Semaphores

EE458 - Embedded Systems Lecture 8 Semaphores EE458 - Embedded Systems Lecture 8 Semaphores Outline Introduction to Semaphores Binary and Counting Semaphores Mutexes Typical Applications RTEMS Semaphores References RTC: Chapter 6 CUG: Chapter 9 1

More information

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

Micrium µc/os II RTOS Introduction EE J. E. Lumpp Micrium µc/os II RTOS Introduction (by Jean Labrosse) EE599 001 Fall 2012 J. E. Lumpp μc/os II μc/os II is a highly portable, ROMable, very scalable, preemptive real time, deterministic, multitasking kernel

More information

ZiLOG Real-Time Kernel Version 1.2.0

ZiLOG Real-Time Kernel Version 1.2.0 ez80acclaim Family of Microcontrollers Version 1.2.0 PRELIMINARY Introduction The (RZK) is a realtime, preemptive, multitasking kernel designed for time-critical embedded applications. It is currently

More information

Micriμm. Getting Started with Micriμm s. Matt Gordon, Sr. Applications Engineer. 9L05I Renesas Electronics America Inc.

Micriμm. Getting Started with Micriμm s. Matt Gordon, Sr. Applications Engineer. 9L05I Renesas Electronics America Inc. Getting Started with Micriμm s μc/os-iii Kernel Matt Gordon, Sr. Applications Engineer Micriμm Class ID: 9L05I Renesas Electronics America Inc. 2012 Renesas Electronics America Inc. All rights reserved.

More information

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34 A Brief Overview Christopher Kenna Avionics October 1, 2010 1 / 34 Introduction Outline 1 Introduction About Kernel Overview 2 Tasks Tasks versus Co-Routines Task Details 3 IPC and Synchronization Queues

More information

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an

More information

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel Alexander Züpke, Marc Bommert, Daniel Lohmann alexander.zuepke@hs-rm.de, marc.bommert@hs-rm.de, lohmann@cs.fau.de Motivation Automotive and Avionic industry

More information

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1 B GLOSSARY Application Programming Interface (API) A library of C/C++ functions and assembly macros that define VDK services. These services are essential for kernel-based application programs. The services

More information

RTOS Real T i Time me Operating System System Concepts Part 2

RTOS Real T i Time me Operating System System Concepts Part 2 RTOS Real Time Operating System Concepts Part 2 Real time System Pitfalls - 4: The Ariane 5 satelite launch rocket Rocket self destructed in 4 June -1996. Exactly after 40 second of lift off at an attitude

More information

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Embedded Systems: OS. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Embedded Systems: OS Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Standalone Applications Often no OS involved One large loop Microcontroller-based

More information

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014 AC OB S Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014 ACOBS ACtive OBject (operating) System Simplified FW System for Multi-Threading on ARM embedded systems ACOBS

More information

Embedded Systems: OS

Embedded Systems: OS Embedded Systems: OS Jinkyu Jeong (Jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu ICE3028: Embedded Systems Design, Fall 2018, Jinkyu Jeong (jinkyu@skku.edu) Standalone

More information

Reference Model and Scheduling Policies for Real-Time Systems

Reference Model and Scheduling Policies for Real-Time Systems ESG Seminar p.1/42 Reference Model and Scheduling Policies for Real-Time Systems Mayank Agarwal and Ankit Mathur Dept. of Computer Science and Engineering, Indian Institute of Technology Delhi ESG Seminar

More information

REAL TIME OPERATING SYSTEMS: A COMPLETE OVERVIEW

REAL TIME OPERATING SYSTEMS: A COMPLETE OVERVIEW REAL TIME OPERATING SYSTEMS: A COMPLETE OVERVIEW Mrinal Parikshit Chandane Former Assistant Professor, Dept. of E&TC, KJSCE, (India) ABSTRACT Telecommunication applications such as telephony, navigation

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

Virtual Machine Design

Virtual Machine Design Virtual Machine Design Lecture 4: Multithreading and Synchronization Antero Taivalsaari September 2003 Session #2026: J2MEPlatform, Connected Limited Device Configuration (CLDC) Lecture Goals Give an overview

More information

Micrium OS Kernel Labs

Micrium OS Kernel Labs Micrium OS Kernel Labs 2018.04.16 Micrium OS is a flexible, highly configurable collection of software components that provides a powerful embedded software framework for developers to build their application

More information

Exam TI2720-C/TI2725-C Embedded Software

Exam TI2720-C/TI2725-C Embedded Software Exam TI2720-C/TI2725-C Embedded Software Wednesday April 16 2014 (18.30-21.30) Koen Langendoen In order to avoid misunderstanding on the syntactical correctness of code fragments in this examination, we

More information

M52259DEMOKIT One-stop-shop connectivity MCU with USB, Ethernet and CAN, featuring Freescale MQX software solutions

M52259DEMOKIT One-stop-shop connectivity MCU with USB, Ethernet and CAN, featuring Freescale MQX software solutions M52259DEMOKIT Quick Start Guide ColdFire Embedded Controllers M52259DEMOKIT One-stop-shop connectivity MCU with USB, Ethernet and CAN, featuring Freescale MQX software solutions Quick Start Guide Lab Tutorials

More information

real-time kernel documentation

real-time kernel documentation version 1.1 real-time kernel documentation Introduction This document explains the inner workings of the Helium real-time kernel. It is not meant to be a user s guide. Instead, this document explains overall

More information

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor Efficiency and memory footprint of Xilkernel for the Microblaze soft processor Dariusz Caban, Institute of Informatics, Gliwice, Poland - June 18, 2014 The use of a real-time multitasking kernel simplifies

More information

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; } Semaphore Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() and V() Can only be accessed via two indivisible (atomic) operations wait (S) { while

More information

Lecture 3: Concurrency & Tasking

Lecture 3: Concurrency & Tasking Lecture 3: Concurrency & Tasking 1 Real time systems interact asynchronously with external entities and must cope with multiple threads of control and react to events - the executing programs need to share

More information

Lecture 4: Real Time Semaphores

Lecture 4: Real Time Semaphores Lecture 4: Real Time Semaphores 1 Lab work (20 min) Configuring VxWorks Kernel VxWorks Hostshell 09/19/2015 Quiz Solution (10) Quiz (15) Lecture Synchronization and Semaphores (45) Lab exercise Binary

More information

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7 THE PROCESS ABSTRACTION CS124 Operating Systems Winter 2015-2016, Lecture 7 2 The Process Abstraction Most modern OSes include the notion of a process Term is short for a sequential process Frequently

More information

SMD149 - Operating Systems

SMD149 - Operating Systems SMD149 - Operating Systems Roland Parviainen November 3, 2005 1 / 45 Outline Overview 2 / 45 Process (tasks) are necessary for concurrency Instance of a program in execution Next invocation of the program

More information

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio Fall 2017 1 Outline Inter-Process Communication (20) Threads

More information

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34

FreeRTOS. A Brief Overview. Christopher Kenna. October 1, Avionics. FreeRTOS 1 / 34 FreeRTOS A Brief Overview Christopher Kenna Avionics October 1, 2010 FreeRTOS 1 / 34 Background Information The FreeRTOS Project supports 25 official architecture ports, with many more community developed

More information

Software Development with an Open Source RTOS

Software Development with an Open Source RTOS Software Development with an Open Source RTOS Fatih Peksenar - Sr. Manager, Application Engineering Class ID: 9L02I Renesas Electronics America Inc. Mr. Fatih Peksenar Manager, Applications Engineering

More information

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger C-SPY plugin Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger This document describes the IAR C-SPY Debugger plugin for the ThreadX RTOS. The ThreadX RTOS awareness

More information

CS A320 Operating Systems for Engineers

CS A320 Operating Systems for Engineers CS A320 Operating Systems for Engineers Lecture 4 Conclusion of MOS Chapter 2 September 18, 2013 Sam Siewert Many Ways to Schedule a CPU Core We ve Come a Long way Since Batch Scheduling Sam Siewert 2

More information

Component validity and internal error checking functionality to ensure reliable operation

Component validity and internal error checking functionality to ensure reliable operation October 2013 Overview of Tower system, CodeWarrior v10.3 and MQX 4.0 Easy OS configuration with GUI based interface Using BSP clone wizard to start with BSP porting Kernel debugging with task aware debugger

More information

Introduction to OS Synchronization MOS 2.3

Introduction to OS Synchronization MOS 2.3 Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how

More information

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems

Lecture 3. Introduction to Real-Time kernels. Real-Time Systems Real-Time Systems Lecture 3 Introduction to Real-Time kernels Task States Generic architecture of Real-Time kernels Typical structures and functions of Real-Time kernels Last lecture (2) Computational

More information

Semaphores. Chapter. verview inary Semaphores for Task Synchronization utex Semaphores to Solve Mutual Exclusion Problems

Semaphores. Chapter. verview inary Semaphores for Task Synchronization utex Semaphores to Solve Mutual Exclusion Problems Chapter 7 Semaphores Tornado Training Workshop Copyright 7-1 verview inary Semaphores for Task Synchronization utex Semaphores to Solve Mutual Exclusion Problems 7.1 Overview Semaphores Binary Semaphores

More information

Module 1. Introduction:

Module 1. Introduction: Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system.

More information

Multiprocessor and Real- Time Scheduling. Chapter 10

Multiprocessor and Real- Time Scheduling. Chapter 10 Multiprocessor and Real- Time Scheduling Chapter 10 Classifications of Multiprocessor Loosely coupled multiprocessor each processor has its own memory and I/O channels Functionally specialized processors

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

Preemptive Scheduling

Preemptive Scheduling Preemptive Scheduling Lecture 18 18-1 Big Picture Methods learned so far We ve been using a foreground/background system Interrupt service routines run in foreground Task code runs in background Limitations

More information

CS370 Operating Systems Midterm Review

CS370 Operating Systems Midterm Review CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between

More information

CODE TIME TECHNOLOGIES. Abassi RTOS. CMSIS Version 3.0 RTOS API

CODE TIME TECHNOLOGIES. Abassi RTOS. CMSIS Version 3.0 RTOS API CODE TIME TECHNOLOGIES Abassi RTOS CMSIS Version 3.0 RTOS API Copyright Information This document is copyright Code Time Technologies Inc. 2011-2013. All rights reserved. No part of this document may be

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic

More information

V. 2. (http://www.tnkernel.com/) Copyright 2004, 2006 Yuri Tiomkin

V. 2. (http://www.tnkernel.com/) Copyright 2004, 2006 Yuri Tiomkin TNKernel Real-Time Kernel V. 2 (http://www.tnkernel.com/) Copyright 2004, 2006 Yuri Tiomkin Document Disclaimer The information in this document is subject to change without notice. While the information

More information

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski Operating Systems Design Fall 2010 Exam 1 Review Paul Krzyzanowski pxk@cs.rutgers.edu 1 Question 1 To a programmer, a system call looks just like a function call. Explain the difference in the underlying

More information

BASICS OF THE RENESAS SYNERGY PLATFORM

BASICS OF THE RENESAS SYNERGY PLATFORM BASICS OF THE RENESAS SYNERGY PLATFORM TM Richard Oed 2017.12 02 CHAPTER 9 INCLUDING A REAL-TIME OPERATING SYSTEM CONTENTS 9 INCLUDING A REAL-TIME OPERATING SYSTEM 03 9.1 Threads, Semaphores and Queues

More information

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke CSCI-GA.2250-001 Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke frankeh@cs.nyu.edu Processes Vs Threads The unit of dispatching is referred to as a thread or lightweight

More information

BASICS OF THE RENESAS SYNERGY TM

BASICS OF THE RENESAS SYNERGY TM BASICS OF THE RENESAS SYNERGY TM PLATFORM Richard Oed 2018.11 02 CHAPTER 9 INCLUDING A REAL-TIME OPERATING SYSTEM CONTENTS 9 INCLUDING A REAL-TIME OPERATING SYSTEM 03 9.1 Threads, Semaphores and Queues

More information

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS Malaysian Journal of Computer Science, Vol. 9 No. 1, June 1996, pp. 12-17 REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS Mohammed Samaka School of Computer Science Universiti Sains Malaysia

More information

UNIT -3 PROCESS AND OPERATING SYSTEMS 2marks 1. Define Process? Process is a computational unit that processes on a CPU under the control of a scheduling kernel of an OS. It has a process structure, called

More information

Real Time Operating System: Inter-Process Communication (IPC)

Real Time Operating System: Inter-Process Communication (IPC) ECE3411 Fall 2015 Lecture 6c. Real Time Operating System: Inter-Process Communication (IPC) Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut

More information

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Processes and threads 1 Overview Process concept Process scheduling Thread

More information

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018 SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T 2. 3. 8 A N D 2. 3. 1 0 S P R I N G 2018 INTER-PROCESS COMMUNICATION 1. How a process pass information to another process

More information

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ARM Cortex-M3 CCS

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ARM Cortex-M3 CCS CODE TIME TECHNOLOGIES Abassi RTOS Porting Document ARM Cortex-M3 CCS Copyright Information This document is copyright Code Time Technologies Inc. 2011,2012. All rights reserved. No part of this document

More information

Lesson 6: Process Synchronization

Lesson 6: Process Synchronization Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013 Operating Systems Comprehensive Exam Spring 2013 Student ID # 3/20/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

Real-time operating systems and scheduling

Real-time operating systems and scheduling Real-time operating systems and scheduling Problem 21 Consider a real-time operating system (OS) that has a built-in preemptive scheduler. Each task has a unique priority and the lower the priority id,

More information

Concurrent Programming. Implementation Alternatives. Content. Real-Time Systems, Lecture 2. Historical Implementation Alternatives.

Concurrent Programming. Implementation Alternatives. Content. Real-Time Systems, Lecture 2. Historical Implementation Alternatives. Content Concurrent Programming Real-Time Systems, Lecture 2 [Real-Time Control System: Chapter 3] 1. Implementation Alternatives Martina Maggio 19 January 2017 Lund University, Department of Automatic

More information

Concurrent Programming

Concurrent Programming Concurrent Programming Real-Time Systems, Lecture 2 Martina Maggio 19 January 2017 Lund University, Department of Automatic Control www.control.lth.se/course/frtn01 Content [Real-Time Control System: Chapter

More information

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6. Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Embedded Software TI2726-B January 28, 2019 13.30-15.00 This exam (6 pages) consists of 60 True/False

More information

ArdOS The Arduino Operating System Reference Guide Contents

ArdOS The Arduino Operating System Reference Guide Contents ArdOS The Arduino Operating System Reference Guide Contents 1. Introduction... 2 2. Error Handling... 2 3. Initialization and Startup... 2 3.1 Initializing and Starting ArdOS... 2 4. Task Creation... 3

More information

Intertask Communication

Intertask Communication Inter-task Communication 04/27/01 Lecture # 29 16.070 Task state diagram (single processor) Intertask Communication Global variables Buffering data Critical regions Synchronization Semaphores Mailboxes

More information

Resource management. Real-Time Systems. Resource management. Resource management

Resource management. Real-Time Systems. Resource management. Resource management Real-Time Systems Specification Implementation Verification Mutual exclusion is a general problem that exists at several levels in a real-time system. Shared resources internal to the the run-time system:

More information

Systemy RT i embedded Wykład 11 Systemy RTOS

Systemy RT i embedded Wykład 11 Systemy RTOS Systemy RT i embedded Wykład 11 Systemy RTOS Wrocław 2013 Plan Introduction Tasks Queues Interrupts Resources Memory management Multiprocessor operation Introduction What s an Operating System? Provides

More information

Nios II. uc/os-ii porting with Nios II Altera Corporation

Nios II. uc/os-ii porting with Nios II Altera Corporation Nios II uc/os-ii porting with Nios II 2002 2 µc/os-ii Main Features Portable (Most 8, 16, 32 and 64 bit CPUs) ROMable Scalable Preemptive Real-Time Deterministic High Performance Multitasking Robust Provides

More information

Processes. Dr. Yingwu Zhu

Processes. Dr. Yingwu Zhu Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware

More information

Quick Start Guide for TWR-MCF5225X TOWER SYSTEM. MCF5225X ColdFire connectivity MCUs

Quick Start Guide for TWR-MCF5225X TOWER SYSTEM. MCF5225X ColdFire connectivity MCUs Quick Start Guide for TWR-MCF5225X TOWER SYSTEM MCF5225X ColdFire connectivity MCUs TOWER SYSTEM Quick Start Guide for TWR-MCF5225X Get to know the TWR-MCF5225X TOWER SYSTEM Primary Connector RS232 Port

More information

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY Instructors: Crista Lopes Copyright Instructors. Basics Concurrent Programming More than one thing at a time Examples: Network server handling hundreds of clients

More information

Deadlock. Lecture 4: Synchronization & Communication - Part 2. Necessary conditions. Deadlock handling. Hierarchical resource allocation

Deadlock. Lecture 4: Synchronization & Communication - Part 2. Necessary conditions. Deadlock handling. Hierarchical resource allocation Lecture 4: Synchronization & ommunication - Part 2 [RTS h 4] Deadlock Priority Inversion & Inheritance Mailbox ommunication ommunication with Objects Deadlock Improper allocation of common resources may

More information

Hands-On Workshop: Freescale MQX Drivers and BSP s

Hands-On Workshop: Freescale MQX Drivers and BSP s June 24, 2010 Hands-On Workshop: Freescale MQX Drivers and BSP s FTF-ENT-F0721 Carlos Neri / Anthony Huereca / Derek Snell Freescale Semiconductor Reg. U.S. Pat. & Tm. Off. BeeKit, BeeStack, CoreNet, the

More information

Short Term Courses (Including Project Work)

Short Term Courses (Including Project Work) Short Term Courses (Including Project Work) Courses: 1.) Microcontrollers and Embedded C Programming (8051, PIC & ARM, includes a project on Robotics) 2.) DSP (Code Composer Studio & MATLAB, includes Embedded

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Embedding OS in AVR microcontrollers. Prof. Prabhat Ranjan DA-IICT, Gandhinagar

Embedding OS in AVR microcontrollers. Prof. Prabhat Ranjan DA-IICT, Gandhinagar Embedding OS in AVR microcontrollers Prof. Prabhat Ranjan (prabhat_ranjan@daiict.ac.in) DA-IICT, Gandhinagar Operating System Fundamentals The kernel is the core component within an operating system Operating

More information

Multitasking / Multithreading system Supports multiple tasks

Multitasking / Multithreading system Supports multiple tasks Tasks and Intertask Communication Introduction Multitasking / Multithreading system Supports multiple tasks As we ve noted Important job in multitasking system Exchanging data between tasks Synchronizing

More information

Concurrency: Deadlock and Starvation

Concurrency: Deadlock and Starvation Concurrency: Deadlock and Starvation Chapter 6 E&CE 354: Processes 1 Deadlock Deadlock = situation in which every process from a set is permanently blocked, i.e. cannot proceed with execution Common cause:

More information

RT3 - FreeRTOS Real Time Programming

RT3 - FreeRTOS Real Time Programming Formation FreeRTOS Real Time Programming: Real-time programming applied to the FreeRTOS operating system - Systèmes d'exploitation: RTOS RT3 - FreeRTOS Real Time Programming Real-time programming applied

More information

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter Lecture Topics Today: Uniprocessor Scheduling (Stallings, chapter 9.1-9.3) Next: Advanced Scheduling (Stallings, chapter 10.1-10.4) 1 Announcements Self-Study Exercise #10 Project #8 (due 11/16) Project

More information

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5 OPERATING SYSTEMS CS3502 Spring 2018 Processor Scheduling Chapter 5 Goals of Processor Scheduling Scheduling is the sharing of the CPU among the processes in the ready queue The critical activities are:

More information

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition

Chapter 5: Process Synchronization. Operating System Concepts 9 th Edition Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks

More information

Midterm Exam. October 20th, Thursday NSC

Midterm Exam. October 20th, Thursday NSC CSE 421/521 - Operating Systems Fall 2011 Lecture - XIV Midterm Review Tevfik Koşar University at Buffalo October 18 th, 2011 1 Midterm Exam October 20th, Thursday 9:30am-10:50am @215 NSC Chapters included

More information

The University of Texas at Arlington

The University of Texas at Arlington The University of Texas at Arlington Lecture 10: Threading and Parallel Programming Constraints CSE 5343/4342 Embedded d Systems II Objectives: Lab 3: Windows Threads (win32 threading API) Convert serial

More information

Last Class: Deadlocks. Today

Last Class: Deadlocks. Today Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006 Operating Systems Comprehensive Exam Spring 2006 Student ID # 3/16/2006 You must complete all of part I (60%) You must complete two of the three sections in part II (20% each) In Part I, circle or select

More information

Quadros. RTXC Kernel Services Reference, Volume 1. Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms. Systems Inc.

Quadros. RTXC Kernel Services Reference, Volume 1. Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms. Systems Inc. Quadros Systems Inc. RTXC Kernel Services Reference, Volume 1 Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms Disclaimer Quadros Systems, Inc. makes no representations or warranties

More information

CS2506 Quick Revision

CS2506 Quick Revision CS2506 Quick Revision OS Structure / Layer Kernel Structure Enter Kernel / Trap Instruction Classification of OS Process Definition Process Context Operations Process Management Child Process Thread Process

More information

CHAPTER 6: PROCESS SYNCHRONIZATION

CHAPTER 6: PROCESS SYNCHRONIZATION CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background

More information

Dealing with Issues for Interprocess Communication

Dealing with Issues for Interprocess Communication Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed

More information

An Automatic Temperature Control System Using RZK

An Automatic Temperature Control System Using RZK Application Note An Automatic Temperature Control System Using RZK AN019902-0908 Abstract This application note demonstrates how an application running on Zilog s Real-Time Kernel (RZK) can be used to

More information

MQX -celeration RTOS-integrated solutions

MQX -celeration RTOS-integrated solutions QoriQ Power Architecture i.mx ColdFire mc56f8xx / 8xxx 9S12 9S08 9RS08 MQX -celeration RTOS-integrated solutions Freescale MQX Software Solutions Freescale streamlines embedded design with a complimentary

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources

More information