Chewei@mail.cgu.edu.tw Department Of Computer Science And Information .

Transcription

Che-Wei Changchewei@mail.cgu.edu.twDepartment of Computer Science and InformationEngineering, Chang Gung University

Linux is free— both in source code and cost, due to theGPLLinux is fully customizable in all its componentsLinux can runs on low-end, inexpensive hardware (HW)platforms, e.g., one with 4 MB RAMMost Linux systems are stableThe Linux kernel can be very small and compactLinux is highly compatible with many commonapplications and functionsLinux is well-supported All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University3

Monolithic kernel The entire operating system is working in kernel spaceAll parts of the kernel share the same kernel-level memoryKernel components might affect other componentsThe Linux kernel is an exampleMicrokernel Kernel functions are partitioned into components Communications are via inter process communication (IPC)protocol The L4 microkernel is an example All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University4

Monolithic KernelAPPsMicrokernelUser ModeScheduler, IPC, File System, Device DriversHardware Platform APPsVirtual Memory, DispatcherKernelModeFileDeviceServer DriversIPC, Virtual Memory, SchedulerHardware Platform All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University5

Character Devices Sequential access Examples might include printers, scanners, sound boards The same device may have both block and character orientedinterfaces Block Devices Block devices can support filesystem The block size is from 512B to 4KB and is going to increase inadvanced devices For example, disks are commonly implemented as blockdevices All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University6

Major number Each device driver is identified by a unique major number This number is assigned by the Linux Device Registrar Minor number The number uniquely identifies a particular instance of adevice of the same device type If there are three devices with the same device driver, theyshould have the same major number but different minornumbers Command: mknod [device name][bcp] [Major] [Minor] b: block devices c: character devices p: a FIFO file All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University7

Incredible Variety of I/O Devices StorageTransmissionHuman-interface Common Concepts Port: a connection point for a device Bus: can be daisy chain or shared direct access Controller (host adapter): electronics that operate ports, buses,devices All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University8

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University9

Devices registers which can be accessed by the host The data-in register is read by the host to get the inputThe data-out register is written by the host to send the outputThe status register contains bits which indicate device statesThe control register is written by the host to send commandsMethods to access devices with their addresses Direct I/O instructions Memory-mapped I/O Device data and command registers mapped to processor addressspace Especially for large address spaces (graphics) All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University10

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University11

An example of polling I/O1. Host reads the busy bit from the status register until 02. Host sets read or write bit and copies data into data-outregister if it is going to write data3. Host sets command-ready bit4. Controller sets busy bit, executes the transmission5. Controller clears busy bit, error bit, and command-ready bitwhen the transmission is done Step 1 is busy-waiting to wait for I/O from devices Reasonable if device is fast But inefficient if device is slow CPU switches to other tasks? Might miss some data All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University12

CPU interrupt-request line triggered by I/O device Checked by processors (hardware) after each instruction Interrupt handler receives interrupts Masked to ignore or delay some interrupts Interrupt vector table is used to dispatch interrupt tocorrect handler Context switches at start and endBased on prioritySome nonmaskableInterrupt chaining if more than one device at the same interruptnumber All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University13

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University14

Interrupt vector table is used to identify which devicesent out the interrupt When multiple devices share an interrupt number, the handlersare checked one by one Interrupt mechanism is also used for exceptions Terminate process or crashed subsystem due to hardware error Page fault executes when there is some memory access error System call executes via a trap to trigger the kernel to executesome request Multi-CPU systems can process interrupts concurrently If operating system designed to handle it All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University15

Process 1Process 1Process 2Process 2User ModeKernel ModeSystem CallHandlerSystem CallSchedulerTimer Interrupt All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung UniversityInterruptHandlerDevice Interrupt16

Used to avoid programmed I/O (one byte at a time) forlarge data movementRequires a DMA controllerBypasses the CPU to transfer data directly between I/Odevices and memoryOS writes a DMA command block into memory Source and destination addresses Read or write mode Number of bytes OS writes the location of the command block to thecorresponding DMA controller Bus mastered by the DMA controller – grabs bus from CPU When transmission is done, the DMA controller sends an interrupt All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University17

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University18

Installing Linux is now easier than installing MS WindowsDoing it on a virtual machine can be harmlessMany distributions are there for you Which Linux distribution is better? If you ask this question, it means “it doesn't matter for you” Just use the distribution with the most supports you can find All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University19

Android was founded in Palo Alto, California inOctober 2003Google acquired Android in August 2005The Open Handset Alliance started in November 2007The first commercially available smartphone runningAndroid was the HTC Dream, released on October 22,2008The latest released version is Android 11, which wasreleased on September 8, 2020 All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University21

Jelly BeanAndroid 4.1-4.3KitKatAndroid 4.4LollipopAndroid 5.0-5.1HoneycombIce cream SandwichAndroid 3.0-3.2Android 4.0 MarshmallowAndroid 6.0-6.0.1NougatAndroid 7.0 – 7.1.2OreoAndroid 8.0 - 8.1Android 10Android 11Android 10Android 11PieAndroid 9.0 All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University22

A software stack for mobile devices An operating system Middleware Key Applications Linux for core system services SecurityMemory managementProcess managementPower managementHardware drivers All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University23

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University24

Advantages Always with the userTypically have Internet accessTypically GPS enabledTypically have accelerometer & compassMost have cameras & microphonesDisadvantages Limited screen sizeLimited battery lifeLimited processor speedLimited web browser functionality All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University25

DVM1(Process)Main ThreadActivityActivityDVM2(Process)Main ThreadActivityActivityDVM3(Process)Main ThreadActivityServiceLooperLooperLooperMessage QueueMessage QueueMessage QueueThread 2Thread 2Thread 2Thread 3Thread 3Thread 3 All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University26

Has various categories, allows ratingsHave both free/paid appsFeatured apps on web and on phoneInitial release: October 23, 2008, as Android MarketDevelopment status: 1 million apps, as of July, 20131.3 million apps, as of July, 20141.5 million apps, as of Q1, 20151.9 million apps, as of Q1, 20162.7 million apps, as of Q1, 2017 All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University27

Link to an Account Developer Account: 25 fee Link to your checking account Developer take 70% of app purchase price All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University28

Eclipse ADT (Android Developer Tools) PluginAndroid SDK (System Development Kit) ToolsAndroid Platform-ToolsThe Latest Android Platform ConfigurationThe Latest Android System Image for the Emulator All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University29

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University30

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University31

Power measurement forany device with a singlelithium battery All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University32

Application Name is the appname that appears to usersProject Name is the name ofyour project directory andthe name visible in EclipsePackage Name is the packagenamespace for your app(following the same rules aspackages in the Javaprogramming language) All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University33

Minimum Required SDK is the lowest version ofAndroid that your app supportsTarget SDK indicates the highest version of AndroidCompile With is the platform version against whichyou will compile your app By default, this is set to the latest version of Android availablein your SDK Theme specifies the Android UI style to apply for yourapp All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University34

If you want to install more libraries for differentAndroid versions or different function supports All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University35

Enable USB debugging on your device On most devices running Android 3.2 or older, you can find theoption under Settings Applications Development On Android 4.0 and newer, it's in Settings Developer options On Android 4.2 and newer, Developer options is hidden bydefault To make it available, go to Settings About phone tap Buildnumber (版本號碼 or 軟體版本) seven times It might be different for different Android devices Return to the previous screen to find Developer optionsDeveloper Options Enable USB debuggingDown and install the USB driver and install it All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University36

All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University37

Providing environment on which every Androidapplication runs Each Android application runs in its own process, with its owninstance of the Dalvik Virtual Machine (DVM) Register-based virtual machine Executing the Dalvik Executable (.dex) format .dex format is optimized for minimal memory footprint Relying on the Linux Kernel Multi-threading Low-level memory management All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University38

Android Runtime (ART) is an application runtimeenvironmentART is provided to replace DalvikART introduces the use of ahead-of-time (AOT)compilationAOT compiles entire applications into native machinecode upon their installationAndroid 4.4 has alternatives to use ART or DalvikAfter Android 5.0, Dalvik was entirely replaced byART All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University39

Activities are the basis of android applicationsAn Activity defines a viewable screenMultiple Activities for an application are allowedEach activity is a separate entityThey have a life cycle Events happen either via touching buttons or programmatically All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University40

Source: /Activity.html All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University41

Run in the background Should be used if something needs to be done while the useris not interacting with application Should create a new thread in the service to do work inCan be bound to an application It will terminate when all applications bound to it haveunbound Multiple applications can communicate with each other via aserviceNeeds to be declared in manifest file All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University42

Source: ices.html All Rights Reserved, Prof. Che-Wei Chang,Department of Computer Science and Information Engineering, Chang Gung University43

Monolithic kernel The entire operating system is working in kernel space All parts of the kernel share the same kernel-level memory Kernel components might affect other components