Operating Systems Chenyang Lu IoT OS Contiki: open-source, - - PowerPoint PPT Presentation

operating systems
SMART_READER_LITE
LIVE PREVIEW

Operating Systems Chenyang Lu IoT OS Contiki: open-source, - - PowerPoint PPT Presentation

Operating Systems Chenyang Lu IoT OS Contiki: open-source, multi-threaded OS, plain C. Amazon FreeRTOS: open-source FreeRTOS kernel + libraries to securely connect devices to AWS cloud services. Arm Mbed: open-source OS based on an Arm


slide-1
SLIDE 1

Operating Systems

Chenyang Lu

slide-2
SLIDE 2

IoT OS

Ø Contiki: open-source, multi-threaded OS, plain C. Ø Amazon FreeRTOS: open-source FreeRTOS kernel + libraries to securely connect devices to AWS cloud services. Ø Arm Mbed: open-source OS based on an Arm Cortex-M microcontroller. Ø Windows 10 IoT Core: Windows 10 optimized for both ARM and x86/x64 devices. Ø Linux

Chenyang Lu 2

slide-3
SLIDE 3

Amazon FreeRTOS

Chenyang Lu 3

https://aws.amazon.com/freertos

slide-4
SLIDE 4

Linux

Ø A Brief History: https://youtu.be/aurDHyL7bTA

Chenyang Lu 4

slide-5
SLIDE 5

Android

Chenyang Lu 5

Source: http://en.wikipedia.org/ wiki/File:Android- System-Architecture.svg

slide-6
SLIDE 6

Killer App for Real-Time?

Ø In 2001, about a year after I joined IBM, I got involved with the Sony-Toshiba-IBM initiative that's leading up to the Sony PlayStation 3. Of course, game systems have extremely severe real-time requirements. All the gaming systems I have seen recently offer sub-reflex response (and, yes, I do have three teenagers, so I have seen a few video games). Gamers will not put up with jerky response, so one-second response times just will not cut it; milliseconds rather than seconds are required. Ø So we are in the very interesting state where gaming and entertainment are major factors driving the technology. When was the last time you heard someone say, "Hey, I bought a new PC and Excel really runs a lot faster"? Paul McKenney, IBM Linux Technology Center Shrinking slices: Looking at real time for Linux, PowerPC, and Cell

Chenyang Lu 6

slide-7
SLIDE 7

Basic Functions

Ø OS controls resources:

q who gets the CPU; q when I/O takes place; q how much memory is allocated; q power management…

Ø Application programs run on top of OS services Ø Challenge: manage multiple, concurrent tasks.

Chenyang Lu 7

slide-8
SLIDE 8

Example: Engine Control

Concurrent tasks Ø spark control Ø crankshaft sensing Ø fuel/air mixture Ø oxygen sensor

Chenyang Lu 8

engine controller

slide-9
SLIDE 9

POSIX (Portable Operating System Interface)

Ø IEEE standards for application portability between Unix variants.

q IEEE 1003.1 defines a Unix-like OS interface. q IEEE 1003.2 defines the shell and utilities q IEEE 1003.4 defines real-time extensions.

Ø Supported by many operating systems

q Variants of UNIX: Linux, MacOS, AIX, HP-UX, Solaris q Many commercial RTOS

Chenyang Lu 9

slide-10
SLIDE 10

Process

Ø A process is a unique execution of a program.

q Several copies of a program may run simultaneously.

Ø A process has its own context.

q Data in registers, PC, status. q Stored in Process Control Block (PCB)

Ø Thread: lightweight process

q Threads share memory space in a same process.

Ø OS manages processes and threads.

Chenyang Lu 10

slide-11
SLIDE 11

Context Switch

Chenyang Lu 11

CPU

registers process 1 process 2 ...

memory

PC

slide-12
SLIDE 12

Process States

Ø A process can be in one of three states:

q executing on the CPU; q ready to run; q waiting for data.

Chenyang Lu 12

executing ready waiting needs data gets data preempted gets CPU Scheduler

slide-13
SLIDE 13

Process Management

Ø OS keeps track of:

q process priorities; q scheduling state; q process control block.

Ø Processes may be created:

q statically before system starts; q dynamically during execution.

Ø OS controls context switches and what process runs.

Chenyang Lu 13

slide-14
SLIDE 14

Priority Scheduling

Ø Every process has a priority. Ø CPU goes to the ready process with the highest priority.

q Fixed vs. dynamic priority q Preemptive vs. non-preemptive

Chenyang Lu 14

slide-15
SLIDE 15

Preemptive Priority Scheduling

Ø Each process has a fixed priority (1 highest); Ø P1: priority 1; P2: priority 2; P3: priority 3.

Chenyang Lu 15

time P2 released P1 released P3 released 30 10 20 60 40 50 P2 P2 P1 P3

slide-16
SLIDE 16

Preemptive Priority Scheduling

Ø Most common real-time scheduling approach

q Real-time POSIX q Real-time priorities in Linux q Most RTOS

Ø Not the only possible way

q Non-preemptive q Clock-driven scheduling q Reservation-based scheduling

Chenyang Lu 16

slide-17
SLIDE 17

Semaphores

Ø OS primitive for controlling access to critical regions.

q Get access to semaphore S with sem_wait(S). q Perform critical region operations. q Release semaphore with sem_post(S).

Ø Mutex: only one process can hold a mutex at a time.

Chenyang Lu 17

slide-18
SLIDE 18

Supervisor Mode

Ø The mode in which the OS usually runs. Ø Provide protective barriers between applications and OS.

q Prevent applications from corrupting OS data.

Ø Can do the following only in the supervisor mode

q Access the kernel address space q Execute privileged instructions

  • Example: Set real-time priority

q Access special hardware

Ø Careful with memory access when

q programs run in supervisor mode q processor has no supervisor mode

Chenyang Lu 18

slide-19
SLIDE 19

Trap (Software Interrupt)

Ø Enter supervisor mode. Ø Make system calls.

q Open file, read from network…

Ø Example: ARM

q Use SWI instruction to enter supervisor mode: SWI CODE_1 q Sets PC to 0x08. q Argument to SWI is passed to supervisor mode code.

Chenyang Lu 19