Distributed Embedded Systems Using Zephyr.pdf

編號:144818 PDF 45頁 2.07MB 下載積分:VIP專享
下載報告請您先登錄!

Distributed Embedded Systems Using Zephyr.pdf

1、#EMBEDDEDOSSUMMITFlexible system design via RPC:Embracing distributed computing in ZephyrYuval Peress,GoogleEmail:Discord:yuval#5515GitHub:yperessChromebooks ship with an EC and a separate Application Processor(AP)Many APs(Intel and AMD)come with a dedicated sensor coreWe wanted to move the sensor l

2、ogic to reduce the cost of the ECBut how?Dependencies,tests,and prior designs were brokenPortable designPigweed RPCs and protobuffersTransitioning from headers to servicesAn exampleAgenda#EMBEDDEDOSSUMMITPortable designhint:theyre microservicesSYSWORKQSHELLTASK_TOUCHPADTASK_CHG_RAMPTASK_USB_CHGTASK_

3、DPSTASK_CHARGERTASK_CHIPSETTASK_MOTIONSENSETASK_USB_MUXTASK_HOSTCMDTASK_KEYPROTOTASK_POWERBTNTASK_KEYSCANTASK_PD_CTASK_PD_INT_CChromiums EC has many tasksSensorsPower DeliverySensor logic can be on a dedicate core such as Intels ISH or AMDs SFH.Power delivery(PD)logic can be on PD chipDoes it matter

4、 where the task lives?With the right design,the service and clients never need to be rewritten#EMBEDDEDOSSUMMITPigweed RPCs and protobufsPigweed is a collection of tools/modulesHighly tuned for embedded applicationsModules in this talk:pw_rpcpw_hdlcWhat is Pigweed?RPC conceptsUnary RPCClient Streami

5、ngServer StreamingAsynchronousset_valpasses an int and saves it on the servicereturns a status when finishedget_valpasses no argsreturns a status and the current valueA simple servicePigweed uses server streams for logging(pw_log_rpc)Client makes a request to the service(EC)and gets back a streamEac

6、h message on the stream is a log messageWhen data is generated with some latencyWhen to use streams?#Add the remoteremotes:-name:pigweed url-base:https:/ pigweed to the projectprojects:-name:pigweed remote:pigweed revision:mainHow to set it up(west.yml)?How to set it up(kConfig)?Enable C+How to set

7、it up(kConfig)?Find the Pigweed moduleHow to set it up(kConfig)?Enable the pw_*libraries you needData visualization of pw_rpcCustom client that injects the service specific information automatically,like service and method IDs.Data visualization of pw_rpcGeneral purpose client which routes the packa

8、ge to the correct channelData visualization of pw_rpcCustom channel implementation controlling the RPC protobuf wire formatData visualization of pw_rpcWrites the RPC frame to the destination and potentially add another level of encoding#EMBEDDEDOSSUMMITTransitioning from headers to services Protobuf

9、fers are more flexible(client and service can be in different languages)Protobuffers make it easy to test by creating a mock client/serviceProtobuffers extend easier than structs(support multiple versions)Cant I just use a.h file?Yes,butAPIs+documentation provide a contractKeep our code interaction

10、confined so refactors are easier to manageBoundaries make writing tests easier and fasterProtos are designed to be extensibleProto files force us to think about API boundaries/*The data structures used for the API*/struct SetValueRequest int32_t value;struct SetValueResponse;struct GetValueRequest;s

11、truct GetValueResponse int32_t value;/*APIs for setting and getting the value*/int client_set_value(const struct SetValueRequest*request,void(*callback)(int status,const struct SetValueResult*result);int client_get_value(const struct GetValueRequest*request,void(*callback)(int status,const struct Ge

12、tValueResult*result);What would the header look like?1.Data structs are hard to maintain as new arguments are added2.The API is lacking a lot of features stilla.How is the data is sent?b.What is the wire format?c.What thread is the callback called on?d.Can we cancel a request?3.How do we test this s

13、ervice?pw_rpc solves these issuesSo whats the problem?#EMBEDDEDOSSUMMITExampleSetValue needs:Passing the value as an argumentLets build a simple servicemessage SetValueRequest int32 value=1;SetValue needs:Passing the value as an argumentNo return valueLets build a simple servicemessage SetValueReque

14、st int32 value=1;message SetValueResponse SetValue need:Passing the value as an argumentNo return valueGetValue needs:Passing nothingLets build a simple servicemessage SetValueRequest int32 value=1;message SetValueResponse message GetValueRequest SetValue need:Passing the value as an argumentNo retu

15、rn valueGetValue needs:Passing nothingReturn the valueLets build a simple servicemessage SetValueRequest int32 value=1;message SetValueResponse message GetValueRequest message GetValueResponse int32 value=1;SetValue need:Passing the value as an argumentNo return valueGetValue needs:Passing nothingRe

16、turn the valueAdd the serviceLets build a simple servicemessage SetValueRequest int32 value=1;message SetValueResponse message GetValueRequest message GetValueResponse int32 value=1;service Cache rpc SetValue(SetValueRequest)returns(SetValueResponse)rpc GetValue(GetValueRequest)returns(GetValueRespo

17、nse)class Cache:public pw_rpc:nanopb:Cache:Service public:Cache():value_(0):pw:Status SetValue(const:SetValueRequest&request,:SetValueResponse&response);:pw:Status GetValue(const:GetValueRequest&request,:GetValueResponse&response);private:int32_t value_;Service implementation header:pw:Status Cache:

18、SetValue(const:SetValueRequest&request,:SetValueResponse&response)value_=request.value;return:pw:OkStatus();:pw:Status DemoService:GetValue(const:GetValueRequest&request,:GetValueResponse&response)response.value=value_;return:pw:OkStatus();Service implementationThe ChannelOutput controls the wire fo

19、rmatGenerally,uses a pw:stream:Writer to write the final bytesCan enable us to efficiently switch how the service communicates with the clientExample ChannelOutputs:pw:hdlc:RpcChannelOutputA custom SimpleChannelOutput used in this talkBoth examples will use the same stream Writer to write to a ring

20、bufferAbstracting away the ChannelOutputpw_hdlc provides a ChannelOutput implementation which packs the data in an HDLC frameFor local writes(between threads)Ive implemented a simple ChannelOutput which simply writes frames as:ChannelOutput optionsTransactionalWraps a ring bufferUses a mutex and con

21、dvar to control data availabilityRingBufferReaderWriterCreates 2 threads(client-service&service-client)On the main thread run 1,000 iterations of:Call SetData,wait for responseCall GetData,wait for responseComparison setups:control Read/write a plain serialized struct using SimpleChannelOutput to a

22、plain service implementationexperiment Uses pw_rpc to write simple RPC frames using SimpleChannelOutput to RPC service implementation and serverThings to consider:The control is an oversimplification(no priority control,no call cancel,doesnt account for extensibility)Some code paths of pw_rpc were i

23、dentified as bottlenecks are actively being optimizedPerformance?control took 65,644,840 nanoseconds(33 s/call)experiment took 233,103,156 nanoseconds(116 s/call)Overall slowdown 255%,but with pw_rpc you get free upgrades:)Performance?Call graphs in the appendix show several points to improve on(whe

24、n communicating between threads)a.Dont use nanopb to serialize the RPC header(cost is 21%)b.Remove the need for a disconnect RPC packet on the Call destructor(38%)These would bring overall RPC cost closer to 45%(14 s/call)Future performance improvements#EMBEDDEDOSSUMMITQuestions?Call graph of the client2service handlerCall graph of the client2service handlerProcessing the header(21%of the cost)Call destructor(38%of the cost)

友情提示

1、下載報告失敗解決辦法
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站報告下載后的文檔和圖紙-無水印,預覽文檔經過壓縮,下載后原文更清晰。

本文(Distributed Embedded Systems Using Zephyr.pdf)為本站 (2200) 主動上傳,三個皮匠報告文庫僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對上載內容本身不做任何修改或編輯。 若此文所含內容侵犯了您的版權或隱私,請立即通知三個皮匠報告文庫(點擊聯系客服),我們立即給予刪除!

溫馨提示:如果因為網速或其他原因下載失敗請重新下載,重復下載不扣分。
客服
商務合作
小程序
服務號
折疊
午夜网日韩中文字幕,日韩Av中文字幕久久,亚洲中文字幕在线一区二区,最新中文字幕在线视频网站