operating systemslu/cse520s/slides/os.pdfkiller app for real-time? Øin 2001, about a year after i...

20
Reminders Ø Send your team members to Corey today q Corey will help match up remaining students q Request permission for a two-member team Ø Proposal presentation: in class next Tuesday Ø Proposal submission: by 11:59pm next Tuesday Ø See Project Guidelines for details Chenyang Lu 1

Upload: others

Post on 24-Nov-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Reminders

Ø Send your team members to Corey todayq Corey will help match up remaining students

q Request permission for a two-member team

Ø Proposal presentation: in class next Tuesday

Ø Proposal submission: by 11:59pm next Tuesday

Ø See Project Guidelines for details

Chenyang Lu 1

Page 2: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Operating Systems

Chenyang Lu

Page 3: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Diverse PlatformsTelosBØ TI MSP430 microcontroller, 4/8 MHz, 8 bit

Ø Memory: 10KB data, 48 KB program

Ø IEEE 802.15.4 radio: max 250 Kbps

Raspberry Pi 4Ø Quad core Cortex-A72 64-bit SoC, 1.5GHzØ 2GB-8GB SDRAMØ IEEE 802.11ac wireless, Bluetooth 5.0, BLE

Ø Gigabit Ethernet

Chenyang Lu 3

Page 4: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 4

Page 5: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Amazon FreeRTOS

Chenyang Lu 5

https://aws.amazon.com/freertos

Page 6: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Linux

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

Chenyang Lu 6

Page 7: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 SonyPlayStation 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 CenterShrinking slices: Looking at real time for Linux, PowerPC, and Cell

Chenyang Lu 7

Page 8: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 8

Page 9: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Example: Engine Control

Concurrent tasksØ spark control

Ø crankshaft sensingØ fuel/air mixtureØ oxygen sensor

Chenyang Lu 9

enginecontroller

Page 10: Operating Systemslu/cse520s/slides/os.pdfKiller 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

POSIX (Portable Operating System Interface)

Ø 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 utilitiesq IEEE 1003.4 defines real-time extensions.

Ø Supported by many operating systemsq Variants of UNIX: Linux, MacOS, AIX, HP-UX, Solaris.q Many commercial RTOS.

Chenyang Lu 10

Page 11: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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, Program Counter (PC), status.

q Stored in Process Control Block (PCB)

Ø Thread: lightweight processq Threads share memory space in a same process.

Ø OS manages processes and threads.

Chenyang Lu 11

Page 12: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Context Switch

Chenyang Lu 12

CPU

registers

process 1

process 2

...

memory

PC

Page 13: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 13

executing

ready waiting

needsdata

gets data

preemptedgetsCPU

Scheduler

Page 14: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 14

Page 15: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 15

Page 16: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Preemptive Priority Scheduling

Ø Each process has a fixed priority (1 highest);

Ø P1: priority 1; P2: priority 2; P3: priority 3.

Chenyang Lu 16

time

P2 released P1 released

P3 released

0 3010 20 6040 50

P2 P2P1 P3

Page 17: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Preemptive Priority Scheduling

ØMost common real-time scheduling approachq Real-time POSIX

q Real-time priorities in Linux

q Most RTOS

ØNot the only possible wayq Non-preemptive

q Clock-driven schedulingq Reservation-based scheduling

Chenyang Lu 17

Page 18: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 18

sem_wait(mutex_info_bus);Write data to info bus;sem_post(mutex_info_bus);

Page 19: Operating Systemslu/cse520s/slides/os.pdfKiller 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

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 modeq 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 19

Page 20: Operating Systemslu/cse520s/slides/os.pdfKiller 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

Trap (Software Interrupt)

Ø Enter supervisor mode.

ØMake system calls.q Open file, read from network…

Ø Example: ARMq Use SWI instruction to enter supervisor mode: SWI CODE_1q Sets PC to 0x08. q Argument to SWI is passed to supervisor mode code.

Chenyang Lu 20