Real Time System KUKUM Last lecture- Summary Definition of Real Time System Types of RTS Slow/Fast RTS What is OS & its functionality, Kernel ?, RTOS how.

Slides:



Advertisements
Similar presentations
CSC321 Concurrent Programming: §3 The Mutual Exclusion Problem 1 Section 3 The Mutual Exclusion Problem.
Advertisements

Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Parallel Algorithms Lecture Notes. Motivation Programs face two perennial problems:: –Time: Run faster in solving a problem Example: speed up time needed.
1 CSC321 §2 Concurrent Programming Abstraction & Java Threads Section 2 Concurrent Programming Abstraction & Java Threads.
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Concurrency.
PZ11B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ11B - Parallel execution Programming Language Design.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
Complexity Analysis (Part I)
Avishai Wool lecture Priority Scheduling Idea: Jobs are assigned priorities. Always, the job with the highest priority runs. Note: All scheduling.
IT Systems Operating System EN230-1 Justin Champion C208 –
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
CS533 - Concepts of Operating Systems
COMP s1 Computing 2 Complexity
What is Concurrent Programming? Maram Bani Younes.
© 2009 Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Lecture 2 Process Concepts, Performance Measures and Evaluation Techniques.
Concurrency, Mutual Exclusion and Synchronization.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
EEL Software development for real-time engineering systems.
CS4231 Parallel and Distributed Algorithms AY 2006/2007 Semester 2 Lecture 3 (26/01/2006) Instructor: Haifeng YU.
Lecture 2 Foundations and Definitions Processes/Threads.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
C o n f i d e n t i a l 1 Course: BCA Semester: III Subject Code : BC 0042 Subject Name: Operating Systems Unit number : 1 Unit Title: Overview of Operating.
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
CY2003 Computer Systems Lecture 04 Interprocess Communication.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building.
Computer Architecture 2 nd year (computer and Information Sc.)
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Threaded Programming Lecture 1: Concepts. 2 Overview Shared memory systems Basic Concepts in Threaded Programming.
1 Parallel execution Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Operating System Concepts and Techniques Lecture 13 Interprocess communication-2 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and.
Agenda  Quick Review  Finish Introduction  Java Threads.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Computer Systems Architecture Edited by Original lecture by Ian Sunley Areas: Computer users Basic topics What is a computer?
Big Picture Lab 4 Operating Systems C Andras Moritz
6/27/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Advanced Algorithms Analysis and Design
Process Management Process Concept Why only the global variables?
Lecture 1: Introduction to JAVA
Memory Consistency Models
Concurrency.
Lecture Topics: 11/1 Processes Process Management
Memory Consistency Models
143a discussion session week 3
T Computer Architecture, Autumn 2005
Objective of This Course
Chapter 26 Concurrency and Thread
What is Concurrent Programming?
BIC 10503: COMPUTER ARCHITECTURE
Background and Motivation
Asst. Dr.Surasak Mungsing
Foundations and Definitions
Chapter 3: Process Management
Presentation transcript:

Real Time System KUKUM Last lecture- Summary Definition of Real Time System Types of RTS Slow/Fast RTS What is OS & its functionality, Kernel ?, RTOS how is it different from OS: –Multitasking –pre-emptable (priority) –Process synch –Interrupt latencyPredictable –Mask interrupt –Sys call

Real Time System KUKUM Concurrency and Concurrent Programming

Real Time System KUKUM Objectives Able to explain the: –Concept of concurrency –Interaction between concurrent processes –Identify pathological cases ( to be avoided) Able to design and implement concurrent software

Real Time System KUKUM Lecture contents Concept of concurrency Abstraction of concurrent programming Correctness of concurrent program Writing concurrent program

Real Time System KUKUM Concept of Concurrency In programming There are two fundamental types of programming: ·Sequential ·parallel

Real Time System KUKUM Sequential Programming In SP, processes are executed in order, one followed by another Analogy: shopping in a supermarket Buy meat, then buy vegetables, then buy drinks, then pay at the counter For a given input, the computer always executes the same sequence instructions. Program is easier to write (logical) Most probably not suitable to solve real-time problems

Real Time System KUKUM Example of SP function add_two_list( int1, int2: integer) begin sum:= 0 sum = int1 sum = sum + int2 return sum end add_two_list A single sequence of control

Real Time System KUKUM Concurrent programming (CP) In CP, processes are executed in parallel Analogy: shopping in supermarket Mother buys meat, father buys veg., son buys drinks ( at once), then all meet by the pay counter Harder to model and to program Each time the sequence of execution of instructions is non deterministic Appropriate for time critical/ real time problems

Real Time System KUKUM Conceptually… We study it by looking at the: –Examples, abstraction and model of CP –Classical problems which illustrate the concepts Programming-wise? –Some languages have no support for concurrency, so we need other means to achive it, eg. OS support (UNIX system calls) –Using ‘task’ in ADA or ‘thread’ in C++

Real Time System KUKUM Definition – concurrent programming “Concurrent programming” is the term given to programming notations and techniques for expressing potential parallellism and for solving the related sycnhronization and communication problems.” Eg: x: y:z:= 60:15:120; Where x,y, and z are all assigned their respective values concurrently( undeterministic which assignment is done first).

Real Time System KUKUM Definition – Program & Process (Ben-Ari’s definition) A concurrent program is a set of “ sequential programs” which are executed in abstract parallelism. Each sequential program is called a process, and the whole set of process is called the concurrent program.

Real Time System KUKUM Examples of concurrency overlapped I/O and computation Main I/O Start I/O Wait for I/O End of I/O

Real Time System KUKUM …/ examples of concurrency Multi programming A concurrent execution of several independent programs Eg: running excel, word, and concurrently on a PC where the excel is calculating something, a file is being edited and is being constantly checked for mail arival.

Real Time System KUKUM …/ examples of concurrency Multi tasking Solving a problem by decomposing it into several sub-tasks. Examples Sort algorithms Summation of huge set of number Computing binomial coefficient

Real Time System KUKUM Why do we need concurrency –Improve speed of execution o processes –Different peripherals have different speed –True to reality- real time behavior of problems in everyday life

Real Time System KUKUM Types of concurrency Semi-concurrency –Two or more processes will run on the same processor, one at a time, using and releasing the processor, managed by the OS. True concurrency –Many processes run on several processors at the same time (transputer environment)

Real Time System KUKUM Try this out This exercise is intended to get a feeling of the problem inherent in CP. –Assume you can write an SP program which produces an endless series of the following sentence: “A person with one watch knows what time it is; a person with two watches is never sure!” –Now write a pseudo-CP program to do the above using two processes, where P1 prints out the first two lines, and P2 the rest. What is the output look like?

Real Time System KUKUM Abstraction of concurrent programming Timing Interleaving Atomicity of operation

Real Time System KUKUM Abstraction An abstraction is an idealized/simplified model of a phenomenon. The model can then be used to study a more complex system which uses the abstraction. Example: –Human body: organs and the various systems –Computer: OS-> instructions -> electronics –Complex software system: components and their interconnections

Real Time System KUKUM …/Abstraction To understand CP, we need a number of abstractions about processes. –Interleaving –Timing –Atomicity of operations in a process We want to use these to identify the problems and also prove the correctness of a CP

Real Time System KUKUM Interleaving For analysis of CP we say that the execution sequences of concurrent processes are interleaved and each process has its own processor time. Between interleaving processes there can be contention and communication. –Contention: processes compete for resources –Communication: processes may need to exchange information In fact there are various scheduling mechanism used to manage the interleaving order of processes. To show that a CP is incorrect we must be able to show that there exist at least one bad interleaving sequence which does not meet the system specification.

Real Time System KUKUM …/ Interleaving A concurrent program must be correct under all kinds of interleaving. Furthermore, fairness must be guaranteed, ie. The scheduler manages is such a way that eventually every instruction in each process must be executed. If it can be shown that a process is deferred forever in its execution under a sequence of interleaving then the process is said to be “starved”.

Real Time System KUKUM Timing The interleaving abstraction also makes no assumption about absolute timing between the execution of processes. –If process-P must finish before process-Q is started, it is irrelevant if it finishes 1 second or 1 hour before. This is a weak specification and can be misleading. But it is a necessary abstraction because… –Execution sequence are more appropriate in proving correctness rather than absolute timing –Systems are always upgraded with newer and faster hardware and if correctness depends on absolute timing we always need to recheck its correctness every time a new device with a new timing is installed. Of course in a real system, the specification must include the absolute real time requirement, otherwise the system may be theoretically correct but still does not meet its requirement.

Real Time System KUKUM Atomic Instructions Interleaving of processes are done on sequences of atomic (undivisible) instructions. The correctness of a CP depends on the level of atomicity used by the computer when processes interleaved. For example, consider the following two processes which execute in parallel but at different atomic levels: Instruction level Register level

Real Time System KUKUM …/ Atomic instructions N: Integer := 0; -- a global var process P is--specification of process P Begin N:= N+1 End P; process Q is--specification of process Q Begin N:= N+1 End Q;

Real Time System KUKUM Instruction level Process Instruction Value of N (Initially)0 PINC N1 QINC N2 Process Instruction Value of N (Initially)0 QINC N1 pINC N2 Result is correct, since there are 2 processes each incrementing N by 1, so final value of N=2, whichever process executes first.

Real Time System KUKUM Reqister level At the register level instruction, the statement N:=N+1 is equivalent to the series of instructions as follow: LOAD Reg, N ADDReg, #1 STOREN, Reg Where LOAD, ADD and store are atomic instructions and N is the global

Real Time System KUKUM Register level Process Instruction N Reg(1) Reg(2) (Initially)0-- PLOADReg, N00- QLOADReg, N000 PADDReg, #1010 QADDReg, #1011 PSTOREReg, N111 QSTOREReg, N111 Result is not correct, based on the specification in the requirement

Real Time System KUKUM By comparison It shows that a different level of atomicity leads to a wrong result when processed are interleaved. Obviously, there are tradeoffs between the level of atomicity vs correctness and between the level of atomicity vs. difficulty in implementation. Generally, prefer a higher level of atomicity, although need to consider speed.

Real Time System KUKUM Concurrency Implementation C++: thread OS support Example Defn: Types Multi tasking Multi programming tech to  parallelism, Solve synch & comm True Conc. Semi Conc. Abstraction Atomicity Interleaving Timing