Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University

Slides:



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

Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
ENTC-489 Embedded Real Time Software Development Embedded Real Time Software Development Week 6 Review I2C Communication, review fixed point arithmetic,
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
5.6.2 Thread Synchronization with Semaphores Semaphores can be used to notify other threads that events have occurred –Producer-consumer relationship Producer.
FreeRTOS.
ΜC/OS-III Tasks Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Getting Started with the µC/OS-III Real Time Kernel Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Memory Management Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Real Time Operating Systems
® 7-2 Semaphores 7.1Overview Binary Semaphores and Synchronization Mutual Exclusion.
15.1 Threads and Multi- threading Understanding threads and multi-threading In general, modern computers perform one task at a time It is often.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
1 Run-to-Completion Non-Preemptive Scheduler. 2 In These Notes... What is Scheduling? What is non-preemptive scheduling? Examples Run to completion (cooperative)
Message Passing Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Readers-Writers Problem Akos Ledeczi EECE 354, Fall 2012 Vanderbilt University.
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
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.
Outlines  Introduction  Kernel Structure  Porting.
Tutorial 2: Homework 1 and Project 1
Getting Started with Micriμm’s μC/OS-III Kernel
OPERATING SYSTEMS CS3502 Fall 2017
Computer Architecture
Interrupt and Time Management in µC/OS-III
Round Robin Non-Preemptive Scheduler
MPI Point to Point Communication
Getting Started with the µC/OS-III Real Time Kernel
Operating Systems CMPSC 473
Intro to Processes CSSE 332 Operating Systems
ECE 3430 – Intro to Microcomputer Systems
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall2014 9/20/2018.
Interrupts, Tasks and Timers
Computer System Overview
Scheduling in µC/OS-III
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall /27/2018.
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Multithreading.
Multithreading.
BRX Technical Training
Process Description and Control
I/O Procedures.
Grades.
Process Description and Control
Subject : T0152 – Programming Language Concept
CSCI1600: Embedded and Real Time Software
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Scheduling.
- When you approach operating system concepts there might be several confusing terms that may look similar but in fact refer to different concepts:  multiprogramming, multiprocessing, multitasking,
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
LHC BLM Software audit June 2008.
Process Description and Control
CSCI1600: Embedded and Real Time Software
COMP3221: Microprocessors and Embedded Systems
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
Chapter 6: Event Control Block (ECB)
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
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University Synchronization Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University

Semaphores They work for synchronization too ISR to Task or Task to Task

Unilateral Rendezvous Task calling Pend() does not need to know about the details: the Pend() call will return when the event has occurred Maximizes use of CPU; no busy waiting Event (i.e., Post()) will cause the waiting task to run immediately (assuming it has the highest priority)

Credit Tracking Semaphore accumulates the number of times Post() has been called /without a corresponding Pend()/

Broadcasting Multiple tasks waiting on a semaphore OS_OPT_POST_ALL All waiting tasks become ready to run Care must be taken because some of the tasks may not have called Pend() yet

Task Semaphores In µC/OS-III each task has a built-in semaphore More efficient OSTaskSemPend(); OSTaskSemPost(); etc. Post()-er (ISR or Task) needs to know which task to notify

Bilateral Rendezvous Only between tasks, as an ISR cannot Pend() void Task1(void *p_arg) { … OSTaskSemPost(&Task2_TCB, OS_OPT_POST_1, &err); OSTaskSemPend(0,OS_OPT_PEND_BLOCKING,&ts,&err); } void Task2(void *p_arg) OSTaskSemPost(&Task1_TCB, Only between tasks, as an ISR cannot Pend()

Event Flags When tasks need to synchronize on multiple events When any of the events is enough: disjunctive synchronization (OR) When all events are needed: conjunctive synchronization (AND) OSFlag???(); OSFlagPendGetFlagsRdy(): which flags caused task to become ready

EventFlags Example #define TEMP_LOW (OS_FLAGS)0x01 #define BATT_LOW (OS_FLASG)0x02 #define SW_PRESSED (OS_FLAGS)0x04 OS_FLAG_GRP MyEventFlagGrp; void main() { … OSFlagCreate(&MyEventFlagGrp, “My flags”,0,&err); } void Task1(void *p_arg) for( ; ; ) OSFlagPend(&MyEventFlagGrp, TEMP_LOW + BATT_LOW, OS_OPT_PEND_FLAG_SET_ANY, ts,&err); void Task2(void *p_arg) { … for ( ; ; ) OSFlagPost(&MyEventFlagGrp, BATT_LOW, OS_OPT_POST_FLAG_SET, &err); }

Status and Transient Events Typically: Status info monitored by one task, handled by another task using a non-blocking call A transient event is generated by an ISR or task and handled and consumed by a task using a blocking call

Event Flag Internals struct os_flag_grp { OS_OBJ_TYPE Type CPU_CHAR *NamePtr OS_PEND_LIST PendList; OS_FLAGS Flags CPU_TS TS }; OSFlagPost(&flagGrp, (OS_FLAGS)0x0C, OS_OPT_FLAG_SET, &err); Pend list is not in priority order as all tasks need to be looked at anyways Look at code on the left: If OS_OPT_FLAG_SET and flags contain 0x03, result will be 0x0F If OS_OPT_FLAG_CLR and flags contain 0x0F, result will be 0x03

Synchronizing Multiple Tasks