Karthik Dantu and Steve Ko

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Three types of remote process invocation
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Services. Application component No user interface Two main uses Performing background processing Supporting remote method execution.
CSE 486/586 Distributed Systems Remote Procedure Call
RPC Robert Grimm New York University Remote Procedure Calls.
Slides on cross-domain call and Remote Procedure Call (RPC)
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
SKKU Embedded Software Lab Remote Sensor Byunghei Jun Dongsu Kim Dongig Sin.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
Distributed Systems Lecture # 3. Administrivia Projects –Design and Implement a distributed file system Paper Discussions –Discuss papers as case studies.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Android UI, and Networking. Can do most networking on Android Bluetooth only on 2.0, Not supported with version 1.6.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
Department of Electrical Engineering Electronics Computers Communications Technion Israel Institute of Technology High Speed Digital Systems Lab. High.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
CASE STUDY 1: Linux and Android Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
Android ICC Part II Inter-component communication.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Remote Procedure Calls CS587x Lecture Department of Computer Science Iowa State University.
CS 6560 Operating System Design Lecture 5: System Calls Interrupts.
Interfacing Device Drivers with the Kernel
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Byoung-Jo CHOI Fall 2007 SW Project II Advanced Linux Programming.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
© 2009 IBM Corporation Tianhong Wang 2012/06/28 Android’s udev —— Vold.
Java Distributed Object Model A remote object is one whose methods can be invoked from another JVM on a different host. It implements one or more remote.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CopperDroid Logan Horton. Android - Background Android is complicated to analyse due to having 2 places to check for code execution Normally, code is.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Android Overview Reference: Embedded Android by Yaghmour.
Android Build System and Overview Karthik Dantu and Steve Ko.
Introduction to Operating Systems Concepts
Understanding and Defending Binder Attack Surface in Android
How Android Starts an App
Android Kernel Extensions
Client-Server Communication
OPERATING SYSTEM CONCEPT AND PRACTISE
Module 12: I/O Systems I/O hardware Application I/O Interface
Instructor: Mazhar Hussain
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Method Invocation
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
CS 3305 System Calls Lecture 7.
Understanding and Defending Binder Attack Surface in Android
Binder Attack Surface in Android
Chapter 3: Windows7 Part 4.
Introduction to Enterprise JavaBean
Sarah Diesburg Operating Systems COP 4610
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
Operating System Concepts
Lecture Topics: 11/1 General Operating System Concepts Processes
Tutorial: The Programming Interface
Android Topics Threads and the MessageQueue
Top Half / Bottom Half Processing
Linux Architecture Overview.
Remote Procedure Call Hank Levy 1.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 4: Threads.
Operating Systems: A Modern Perspective, Chapter 6
Outline Operating System Organization Operating System Examples
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
Jim Fawcett CSE791 – Distributed Objects Spring 2002
Interrupts and System Calls
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Karthik Dantu and Steve Ko More on IPC Mechanisms Karthik Dantu and Steve Ko

Administrivia Have you done your assignment? Show us! Assignment 4 (the last assignment) will be out soon and due in two weeks.

Today: More on IPC Mechanisms Why? Fundamental building blocks of the Android framework Last time was from the user’s (i.e., programmer’s) perspective to understand other framework components. Today’s about the internals. Goal: Understanding the framework structure and IPC mechanisms

Today: More on IPC Mechanisms We will look at two IPC mechanisms. Looper-handler Binder Resources: AOSP “Embedded Android” “Deep Dive into Android IPC/Binder Framework” http://events.linuxfoundation.org/images/stories/slides/abs2013_gargentas.pdf

Looper-Handler Looper is a per-thread message loop. Handler processes messages.

Looper Architecture Thread Looper Message Queue Message Message Handler Handler Handler

Looper Protocol: ActivityThread.java

Looper Looper.prepare()

Looper Looper.loop()

Handler

Handler.sendMessage()

Handler.dispatchMessage()

Binder From OpenBinder Enables two things for IPC Directory of available IPC calls Communication mechanism

Architecture Context Manager (servicemanager.c) Process A Process B Client IBinder AIDL Binder Proxy AIDL IBinder Stub Binder Service Binder Token Binder Driver (/dev/binder)

Context Manager A special Binder object (handle #0) The directory of all Binder-ready processes On Android, ServiceManager becomes this context manager for Binder. servicemanager.c binder_become_context_manager(): Registers itself with the kernel Binder module as the context manager. binder_loop() starts a message loop that listens to the commands from kernel Binder module.

ServiceManager

Registering with Service Manager System Server Runs many services, e.g., Activity Manager, Power Manager, etc. Calls ServiceManager’s addService() Service Manager Maintains directories for registered remote objects Returns a handle for remote object upon lookup App Can use Context’s getSystemService() or ServiceManager’s getService() to lookup and get the handle Binder Driver (/dev/binder)

Registering with Service Manager Binder-ready processes can add themselves to the directory with ServiceManager.addService(). For example, SystemServer (SystemServer.java) adds (and runs) most of the default system services at boot using ServiceManager.addService(). SystemServer starts from ZygoteInit.java. There are other services that start from other servers, e.g., MediaServer (frameworks/av/media/mediaserver)

SystemServer.java

Accessing Service Manager Context.getSystemService(String name) Apps calls this first to get the handle for a service manager (handle #0). E.g., getSystemService(Context.ACTIVITY_SERVICE) This call goes to servicemanager (servicemanager.c) which looks up its directory of services and returns an appropriate handle. You could also use ServiceManager.getService() and call asInterface(). This is essentially Context.getSystemService().

Typical HW Access Flow App APIs android.* (/frameworks/base/core/*) Binder System Service (/frameworks/base/services/java/*) JNI System Service Native (/frameworks/base/services/jni/*) Hardware Interface (/hardware/libhardware/*) Vender-Provided Libraries (/device/<vendor>/<device>/*) Kernel Modules (/dev/*)

Binder Communication Mechanism From last lecture: Proxy & Stub implement marshalling & unmarshalling. Parcel Marshalling/unmarshalling data structure android.os.Parcel transact() & onTransact() Marshalling & unmarshalling implementation

Binder Communication Mechanism libbinder (/frameworks/native/libs/binder) Provides JNI interface to Java Binder classes. Communicates with /dev/binder through ioctl() ioctl(binderFD, BINDER_WRITE_READ, &bwd)

Data Structure for ioctl struct binder_write_read { signed long write_size; signed long write_consumed; unsigned long write_buffer; signed long read_size; signed long read_consumed; unsigned long read_buffer; };

/dev/binder Kernel module /drivers/staging/android/binder.c (& .h) ~3500 lines BTW, /drivers/staging/android/* has a lot of the android Linux code (not all, e.g., wakelock). static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) Handles ioctl() calls from the userspace.

Summary Looper A thread-local Maintains a message queue Handler Associates with a Looper Handles messages Binder Main mechanism for the framework User-level & kernel-level components