Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Basic Operating System Concepts
CS 149: Operating Systems February 3 Class Meeting
Mutual Exclusion.
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
Processes CSCI 444/544 Operating Systems Fall 2008.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Chapter 11 Operating Systems
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Process Description and Control A process is sometimes called a task, it is a program in execution.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
Operating Systems Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled Car with a camera Car is controlled via the.
Implementing Processes and Process Management Brian Bershad.
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Deadlock Operating Systems: Internals and Design Principles.
Threads, Thread management & Resource Management.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
What is a Process ? A program in execution.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Scheduling.
Big Picture Lab 4 Operating Systems C Andras Moritz
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Embedded Real-Time Systems
Introduction to Kernel
Processes and threads.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
Process concept.
Process Management Process Concept Why only the global variables?
CS 6560: Operating Systems Design
Topics Covered What is Real Time Operating System (RTOS)
Background on the need for Synchronization
Applied Operating System Concepts -
Lecture 21 Concurrency Introduction
Code Tuning Techniques
Process management Information maintained by OS for process management
System Structure and Process Model
Process & its States Lecture 5.
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Lecture 2 Part 2 Process Synchronization
Threads Chapter 4.
Processes Hank Levy 1.
Processes and Process Management
February 5, 2004 Adrienne Noble
CS510 Operating System Foundations
CS333 Intro to Operating Systems
CSE 153 Design of Operating Systems Winter 2019
Processes Hank Levy 1.
CSE 153 Design of Operating Systems Winter 2019
Chapter 3: Process Management
Presentation transcript:

Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled Car with a camera Car is controlled via the internet Car has its own webserver ( Web interface allows user to control car and see camera images Car also has “auto brake” feature to avoid collisions Fwd Back LeftRight Web interface view

Slides created by: Professor Ian G. Harris Multiple Tasks  Assume that one microcontroller is being used  At least four different tasks must be performed 1.Send video data - This is continuous while a user is connected 2.Service motion buttons - Whenever button is pressed, may last seconds 3.Detect obstacles - This is continuous at all times 4.Auto brake - Whenever obstacle is detected, may last seconds  Detect and Auto brake cannot occur together  3 tasks may need to occur concurrently

Slides created by: Professor Ian G. Harris Prioritized Task Scheduling  Sending Video Data and Detecting Obstacles must happen concurrently Both tasks never complete  Servicing Motion Buttons must be concurrent with Sending Video Data Video should not stop when car moves  CPU must switch between tasks quickly  Some tasks must take priority Auto Brake must have highest priority

Slides created by: Professor Ian G. Harris Sharing Global Resources  Global resources may be required by mulitple tasks ADC, comparators, timers, I/O pins  Shared access must be controlled to avoid interference Ex. Task 1 and Task 2 need to use the ADC They cannot use the ADC at the same time One task must wait for the other  Operating system guarantees that resource conflicts are resolved

Slides created by: Professor Ian G. Harris Layered OS Architecture Microconrtoller Application Library Functions System Calls Application Microconrtoller  OS provides an abstraction to hide details of hardware Ex. delay(int) library function might setup a timer-based interrupt  Using Library functions incurrs overhead

Slides created by: Professor Ian G. Harris Processes vs. Threads  Context of a task is its register values, program counter, and stack  All tasks have their own context  Context switch is when on task stops and the next starts - Must save the old context and load the new - This is time consuming  OS typically gives tasks access to memory (i.e malloc )  Processes each have their own private memory - Requires memory protection  Threads share memory  RTOS usually implement tasks as threads

Slides created by: Professor Ian G. Harris Memory Management  Programs can request memory dynamically with malloc(); int valarr[10]; int *valarr; valarr = (int *) malloc(10 * sizeof(int));  Dynamically allocated memory must be explicitly released - statically allocated memory is released on function return free(valarr);  Dynamic memory allocation is flexible but harder to deal with - Must free the memory manually - Cannot access freed memory

Slides created by: Professor Ian G. Harris OS Memory Management  A program cannot know the dynamic memory allocation - Which memory locations are used and which are available?  Operating system keeps tables describing which memory locations are available  The program must request memory from the OS - OS may deny request if there is no memory available  OS also protects memory - Enforce memory access permissions

Slides created by: Professor Ian G. Harris Scheduler  OS manages the execution state of each task 3 main states 1. Running – The task is currently running 2. Ready – The task is not running but it is ready to run 3. Blocked – The task is not ready because it is waiting for an event  Only one task can be running at a time  A task can only run if it is first ready (not blocked)  Scheduler must keep track of the state of each task  Scheduler must decide which ready task should run

Slides created by: Professor Ian G. Harris Preemption  A non-preemptive scheduler allows a task to run until it gives up control of the CPU - Task may call a library function (sleep) to quit - Needs to be awakened by an event, like an interrupt - Not much flexibility for OS to meet deadlines  A preemptive scheduler allows the OS to stop a running task and start another task - OS has the power to influence the completion of tasks - OS must be awakened periodically to make scheduling decisions - May implement the OS kernel as a high priority timer-based interrupt

Slides created by: Professor Ian G. Harris Scheduling Algorithms Round-Robin:  Scheduler keeps an ordered list of ready tasks  First task is assigned a fixed-size time slice to execute  After time slice is done, task is placed at the end of the list and next task executes for its time slice  Very simple, no priorities Context switch time Task execution Task 1 Task 2

Slides created by: Professor Ian G. Harris Prioritized Scheduling Fixed Priority Preemptive:  Scheduler keeps an ordered list of ready tasks, ordered by priority  First task is assigned a fixed-size time slice to execute  After time slice is done, scheduler chooses highest priority ready task for next time slice  Next task might be the same as the previous task, if it is high priority Low priority High Priority  Starvation may occur

Slides created by: Professor Ian G. Harris Atomic Updates  Tasks may need to share global data and resources  For some data, updates must be performed together to make sense Ex. Our system samples the level of water in a tank tank_level is level of water time_updated is last update time tank_level = // Result of computation time_updated = // Current time  These updates must occur together for the data to be consistent  Interrupt could see new tank_level with old time_updated

Slides created by: Professor Ian G. Harris Mutual Exclusion  While one task updates the shared variables, another task cannot read them tank_level = ?; time_updated = ?; printf (“%i %i”, tank_level, time_updated); Task 1Task 2  Two code segments should be mutually exclusive  If Task 2 is an interrupt, it must be disabled

Slides created by: Professor Ian G. Harris Semaphores  A semaphore is a flag which indicates that execution is safe  May be implemented as a binary variable, 1 continue, 0 wait TakeSemaphore() : If semaphore is available (1) then take it (set to 0) and continue If semaphore is note available (0) then block until it is available ReleaseSemaphore(): Set semaphore to 1 so that another task can take it  Only one task can have a semaphore at one time

Slides created by: Professor Ian G. Harris Critical Regions TakeSemaphore(); tank_level = ?; time_updated = ?; ReleaseSemaphore(); TakeSemaphore(); printf (“%i %i”, tank_level, time_updated); ReleaseSemaphore(); Task 1 Task 2  Semaphores are used to protect critical regions  Two critical regions sharing a semaphore are mutually exclusive  Each critical region is atomic, cannot be separated