Android ProcessState

http://www.android1.net/Topic.aspx?BoardID=31&TopicID=1897

 

ProcessState是一個singleton類別,它只有一個物件(Instance)。此物件負責打開Binder Driver(/dev/binder驅動),準備讓其進程裡的程式能與Binder Driver進行溝通。例如,它在其進程(於此,稱為client進程)裡誕生BpBinder物件,此BpBinder物件的執行緒(Thread)透過Binder Driver而轉接(relayto)IPC thread去執行另一個進程((於此,稱為service進程)裡的服務(例如ServiceManager service)


  


  與ProcessState類別具有密切關係的是IPCThreadState類別,這IPCThreadState類別也是singleton類別,只有一個物件(Instance)


 


       ProcessState負責打開BinderDriver,與Binder Driver溝通;而IPCThreadState負責透過Binder Driver而進行跨進程的實際資料讀寫動作。例如,client進程的程式呼叫BpBinderIBinder介面的transact()函數,此transact()函數則呼叫IPCThreadState物件的transact()函數去呼叫Binder Driverioctl()函數來進行實際資料傳遞。

 

       


       IPCThreadState block( 阻塞 ) client 進程的 calling thread ,而 轉接 (relay to) IPC thread 去執行 server 進程裡的 target 服務 。同時等待 IPC thread 執行完畢,回傳數據,才放行 calling thread

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值