Lab 4 : Real-Time OS Team #7 P91922003 李彥勳 P90922016 謝嵩淮 R91921030 侯凱文.

Slides:



Advertisements
Similar presentations
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 8 SCHEDULING.
Advertisements

1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
CprE 458/558: Real-Time Systems (G. Manimaran)1 CprE 458/558: Real-Time Systems Resource Access Control Protocols.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
EEE 435 Principles of Operating Systems Interprocess Communication Pt II (Modern Operating Systems 2.3)
Mutual Exclusion.
Secure Operating Systems Lesson 5: Shared Objects.
Interprocess Communication
CY2003 Computer Systems Lecture 05 Semaphores - Theory.
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
Synchronization Principles. Race Conditions Race Conditions: An Example spooler directory out in 4 7 somefile.txt list.c scores.txt Process.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Chapter 2.3 : Interprocess Communication
CS533 - Concepts of Operating Systems
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Phones OFF Please Processes Parminder Singh Kang Home:
1 Race Conditions/Mutual Exclusion Segment of code of a process where a shared resource is accessed (changing global variables, writing files etc) is called.
Monitors: An Operating System Structuring Concept
ELN5622 Embedded Systems Class 8 Spring, 2003 Aaron Itskovich
Introduction to Embedded Systems
SOC Consortium Course Material SoC Design Laboratory Lab 8 Real-time OS - 2 Speaker: Yung-Chih Chen Advisor: Prof. Chun-Yao Wang November 17, 2003 Department.
Introduction to Embedded Systems Rabie A. Ramadan 6.
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Games Development 2 Concurrent Programming CO3301 Week 9.
© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems Operating systems. 1.
Deadlock Detection and Recovery
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
Thread Implementations; MUTEX Reference on thread implementation –text: Tanenbaum ch. 2.2 Reference on mutual exclusion (MUTEX) –text: Tanenbaum ch
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
1 Processes and Threads Part II Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Implementing Lock. From the Previous Lecture  The “too much milk” example shows that writing concurrent programs directly with load and store instructions.
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.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Big Picture Lab 4 Operating Systems C Andras Moritz
Interprocess Communication Race Conditions
REAL-TIME OPERATING SYSTEMS
Topics Covered What is Real Time Operating System (RTOS)
Background on the need for Synchronization
Advanced OS Concepts (For OCR)
Thread Implementations; MUTEX
CSCI1600: Embedded and Real Time Software
CPU scheduling decisions may take place when a process:
Implementing Mutual Exclusion
EE 472 – Embedded Systems Dr. Shwetak Patel.
Computer Science & Engineering Electrical Engineering
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Implementing Mutual Exclusion
Thread Implementations; MUTEX
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
CSCI1600: Embedded and Real Time Software
Presentation transcript:

Lab 4 : Real-Time OS Team #7 P 李彥勳 P 謝嵩淮 R 侯凱文

Common Pitfall Use a global flag to test whether a shared resource is currently available or not: int buffer_busy; … while (buffer_busy==0); buffer_busy = 1; // write data into buffer

Common Pitfall Use a global flag to test whether a shared resource is currently available or not: int buffer_busy; … while (buffer_busy==0); buffer_busy = 1; // write data into buffer Busy Waiting

Common Pitfall Use a global flag to test whether a shared resource is currently available or not: int buffer_busy; … while (buffer_busy==0); buffer_busy = 1; // write data into buffer Interrupt

Common Pitfall ( continued ) Busy waiting : wasting CPU time. Even in the following situation, CPU load still heavy : while (buffer_busy==0) Sleep(0); Interrupt : if two tasks sharing the same buffer, two tasks may try to write this buffer simultaneously.

Common Pitfall ( continued ) This code section is frequently written by many engineers. Solution : using semaphore, mail box … IPC primitives so that the task can actually enter “ Waiting ” state without occupying CPU time-slice. ARM instruction “ SWP ” can be used to achieve “ atomic operation ” : ADR r0, SEMAPHORE SWPBr1,r1,[r0]

Critical Section Implementation of uC/OS-II Disable/Enable interrupt ARMDisableInt MRSr12, CPSR ORRr12, r12, #NoInt MSRCPSR_c, r12 MOVpc, lr That ’ s why it is not a “ HARD real time OS ”.

Priority Inversion A long existing terminology, recently it becomes a buzzword due to “ Pathfinder ” on Mars (RTOS: VxWorks). It refers to a lot of situation, may even be used intentionally to prevent starvation. Unbounded priority inversion : Priority inversion occurs in unpredictable manners.

Priority Inversion (continued)

The problem is that τ 1 and τ 3 share a common data structure, locking a mutex to control access to it. Thus, if τ 3 locks the mutex, and τ 1 tries to lock it, τ 1 must wait. Every now and then, when τ 3 has the mutex locked, and τ 1 is waiting for it, τ 2 runs because it has a higher priority than τ 3. Thus, τ 1 must wait for both τ 3 and τ 1 to complete and fails to reset the timer before it expires.

Priority Inversion (continued) Solution : priority inheritance protocol and priority ceiling protocol. Priority ceiling : raises the priority of any locking thread to the priority ceiling for each lock. Priority inheritance : raises the priority of a thread only when holding a lock causes it to block a higher priority thread.

Lab problems In (eg3), if we did not define “ SEMIHOSTED ”, the stack will overflow and corrupt “ personal_info ” data structure. OSTimeDly() does not work, must reconfigure ARMulator according to ( or just don ’ t use it )

Lab problems (continued) When AXD starts, it sometimes raise the following error, and AXD can ’ t continue : Solution : remove this file (default ses) and restarts AXD again.

Exercise Client task : Input ID Server task: Check the ID Simulate two tasks running in different machines. Server task controls all the important system parameters, and the checking rules. When checking rules or system parameters changed, only server side needs to be modified.

Exercise (continued) Client Task ’ s pseudo code : (input/output) while (1) { Obtain system parameters from server; Allocate memory for input strings; Do basic checking to reject strings that are longer than the length limit specified in system parameters; Send strings to server side; //authentication completes, do jobs. Free allocated memory; }

Exercise (continued) Server task ’ s pseudo code : (checking) while (1) { Wait for messages from client side; Do checking on the ID strings, and perform actions according to the result (here we display the results); Send system parameters to clients. }

Discussion What are the advantages and disadvantages of using an RTOS? Adv : With RTOS, we can speed up the software development cycle, since it can do “ resource allocation and managements ” for us. Dis : Increase the total code sizes, some embedded OS may took a lot of system resources.

Discussion (continued) Dis: may results in un-wanted behavior due to the internal mechanism (such as scheduler), for example, priority inversion. Adv/Dis: Without RTOS, user can take full control of everything, in other words, user must take care of everything, this might lengthen the development cycle according to the complexity of the application.

Conclusion If jobs can be done in a single task (simple application), no RTOS is needed. If jobs must be done in many different tasks which contest with each other for many shared resources – use RTOS. (eg: an embedded AP may require web service, telnet service, … )

Reference Modern Operating Systems, Andrew S. Tanenbaum. ers/Priority_Inversion_1.0-TM.pdf