Synchronization Akos Ledeczi EECE 6354, Fall 2013 Vanderbilt University.

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
1 Synchronization 2: semaphores and more… 1 Operating Systems, 2011, Danny Hendler & Amnon Meisels.
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.
ENTC-489 Embedded Real Time Software Development Embedded Real Time Software Development Week 6 Review I2C Communication, review fixed point arithmetic,
Java How to Program, 9/e CET 3640 Professor: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
EEE 435 Principles of Operating Systems Principles and Structure of I/O Software (Modern Operating Systems 5.2 & 5.3) 5/22/20151Dr Alain Beaulieu.
Informationsteknologi Wednesday, September 26, 2007 Computer Systems/Operating Systems - Class 91 Today’s class Mutual exclusion and synchronization 
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
Process Description and Control
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.
Java How to Program, 9/e CET 3640 Professor: Dr. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
ΜC/OS-III Tasks Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Multithreaded Web Server.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Martin Kruliš by Martin Kruliš (v1.0)1.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP.
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.
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
Real Time Operating Systems
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS. NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem.
® 7-2 Semaphores 7.1Overview Binary Semaphores and Synchronization Mutual Exclusion.
CSC321 Concurrent Programming: §5 Monitors 1 Section 5 Monitors.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
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.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
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.
MPI Point to Point Communication CDP 1. Message Passing Definitions Application buffer Holds the data for send or receive Handled by the user System buffer.
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.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
1 Round Robin Non-Preemptive Scheduler Lecture 12.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
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.
Big Picture Lab 4 Operating Systems C Andras Moritz
Message passing model. buffer producerconsumer PRODUCER-CONSUMER PROBLEM.
Outlines  Introduction  Kernel Structure  Porting.
Getting Started with Micriμm’s μC/OS-III Kernel
Interrupt and Time Management in µC/OS-III
Getting Started with the µC/OS-III Real Time Kernel
Operating Systems CMPSC 473
Scheduling in µC/OS-III
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Multithreading.
BRX Technical Training
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Subject : T0152 – Programming Language Concept
CSCI1600: Embedded and Real Time Software
Process Description and Control
- 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,
CSCI1600: Embedded and Real Time Software
COMP3221: Microprocessors and Embedded Systems
Chapter 6: Event Control Block (ECB)
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Presentation transcript:

Synchronization Akos Ledeczi EECE 6354, Fall 2013 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 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, OS_OPT_POST_1, &err); OSTaskSemPend(0,OS_OPT_PEND_BLOCKING,&ts,&err); … } 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, 0 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