【架構分析】Fuchsia IPC 詳解

目錄

概述

Fuchsia IPC Architecture Overview

FIDL IPC 詳解


概述

Fuchsia使用Fuchsia Interface Definition Language (FIDL) 作爲進程IPC的接口描述語言,本文旨在詳細分析基於FIDL的IPC原理

 

Fuchsia IPC Architecture Overview

Fuchsia IPC Overview
  • 通過FIDL描述IPC接口Interface
  • Client 進程使用InterfacePtr<Interface>來調用Interface中的接口獲得服務
  • Service進程實現Interface中的接口來提供服務
  • 爲了描述更具體清晰,本文使用view_provider.fidl 作爲Interface的具體例子來分析IPC的原理和過程
[Discoverable]
interface ViewProvider {
    // Creates a new View under the control of the ViewProvider.
    //
    // |token| is one half of the shared eventpair which will bind the new View
    // to its associated ViewHolder.  The ViewProvider will use |token| to
    // create its internal View representation.  The caller is expected to use
    // its half to create corresponding ViewHolder object.
    //
    // |incoming_services| allows clients to request services from the
    // ViewProvider implementation.  |outgoing_services| allows clients to
    // provide services of their own to the ViewProvider implementation.
    //
    // Clients can embed a ViewHolder (and by proxy the paired View) into their
    // scene graph by using |Node.AddChild()|.  The ViewHolder cannot itself
    // have any children. A ViewProvider implementation can nest scene objects
    // within its View by using |View.AddChild()|.  The View itself
    // cannot be a child of anything.
    //
    // Modules can use these mechanisms to establish a distributed,
    // inter-process scene graph.
    CreateView(handle<eventpair> token,
               request<fuchsia.sys.ServiceProvider>? incoming_services,
               fuchsia.sys.ServiceProvider? outgoing_services);
};

FIDL IPC 詳解

FIDL IPC 類圖

FIDL IPC中涉及的Class大致可以分爲4種

  1. Client端使用的Class
  2. Service端使用的Class
  3. FIDL自動代碼生成的Class
  4. Client和Service都會使用到的Class(包括訪問Zircon微內核channel的Class)

下面依然以FIDL view_provider.fidl 中定義的interface ViewProvider作爲具體的例子說明Client與Service的IPC時序

Client通過FIDL接口ViewProvider發起CreateView IPC的調用時序

 

Service通過FIDL接口ViewProvider接收到CreateView IPC的調用時序

 

 

Tips

  • Fuchsia FIDL文件的位置: fuchsia/garnet/public/fidl/<fuchsia.package.name>
  • 編譯FIDL後自動生成的代碼位置:fuchsia/out/arm64/fidling/gen/fuchsia/<package>/<name>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章