首页 文章 精选 留言 我的

精选列表

搜索[Windows应用SDK],共10000篇文章
优秀的个人博客,低调大师

Android应用程序进程启动过程的源代码分析(3)

Step 10.AppRuntime.onZygoteInit 这个函数定义在frameworks/base/cmds/app_process/app_main.cpp文件中: [cpp] view plain copy classAppRuntime:publicAndroidRuntime { ...... virtualvoidonZygoteInit() { sp<ProcessState>proc=ProcessState::self(); if(proc->supportsProcesses()){ LOGV("Appprocess:startingthreadpool.\n"); proc->startThreadPool(); } } ...... }; 这里它就是调用ProcessState::startThreadPool启动线程池了,这个线程池中的线程就是用来和Binder驱动程序进行交互的了。 Step 11.ProcessState.startThreadPool 这个函数定义在frameworks/base/libs/binder/ProcessState.cpp文件中: [cpp] view plain copy voidProcessState::startThreadPool() { AutoMutex_l(mLock); if(!mThreadPoolStarted){ mThreadPoolStarted=true; spawnPooledThread(true); } } ProcessState类是Binder进程间通信机制的一个基础组件,它的作用可以参考 浅谈Android系统进程间通信(IPC)机制Binder中的Server和Client获得Service Manager接口之路 、 Android系统进程间通信(IPC)机制Binder中的Server启动过程源代码分析 和 Android系统进程间通信(IPC)机制Binder中的Client获得Server远程接口过程源代码分析 这三篇文章。这里它调用spawnPooledThread函数进一步处理。 Step 12.ProcessState.spawnPooledThread 这个函数定义在frameworks/base/libs/binder/ProcessState.cpp文件中: [cpp] view plain copy voidProcessState::spawnPooledThread(boolisMain) { if(mThreadPoolStarted){ int32_ts=android_atomic_add(1,&mThreadPoolSeq); charbuf[32]; sprintf(buf,"BinderThread#%d",s); LOGV("Spawningnewpooledthread,name=%s\n",buf); sp<Thread>t=newPoolThread(isMain); t->run(buf); } } 这里它会创建一个PoolThread线程类,然后执行它的run函数,最终就会执行PoolThread类的threadLoop函数了。 Step 13.PoolThread.threadLoop 这个函数定义在frameworks/base/libs/binder/ProcessState.cpp文件中: [cpp] view plain copy classPoolThread:publicThread { public: PoolThread(boolisMain) :mIsMain(isMain) { } protected: virtualboolthreadLoop() { IPCThreadState::self()->joinThreadPool(mIsMain); returnfalse; } constboolmIsMain; }; 这里它执行了IPCThreadState::joinThreadPool函数进一步处理。IPCThreadState也是Binder进程间通信机制的一个基础组件,它的作用可以参考 浅谈Android系统进程间通信(IPC)机制Binder中的Server和Client获得Service Manager接口之路 、 Android系统进程间通信(IPC)机制Binder中的Server启动过程源代码分析 和 Android系统进程间通信(IPC)机制Binder中的Client获得Server远程接口过程源代码分析 这三篇文章。 Step 14.IPCThreadState.joinThreadPool 这个函数定义在frameworks/base/libs/binder/IPCThreadState.cpp文件中: [cpp] view plain copy voidIPCThreadState::joinThreadPool(boolisMain) { ...... mOut.writeInt32(isMain?BC_ENTER_LOOPER:BC_REGISTER_LOOPER); ...... status_tresult; do{ int32_tcmd; ...... //nowgetthenextcommandtobeprocessed,waitingifnecessary result=talkWithDriver(); if(result>=NO_ERROR){ size_tIN=mIn.dataAvail(); if(IN<sizeof(int32_t))continue; cmd=mIn.readInt32(); ...... result=executeCommand(cmd); } ...... }while(result!=-ECONNREFUSED&&result!=-EBADF); ...... mOut.writeInt32(BC_EXIT_LOOPER); talkWithDriver(false); } 这个函数首先告诉Binder驱动程序,这条线程要进入循环了: [cpp] view plain copy mOut.writeInt32(isMain?BC_ENTER_LOOPER:BC_REGISTER_LOOPER); 然后在中间的while循环中通过talkWithDriver不断与Binder驱动程序进行交互,以便获得Client端的进程间调用: [cpp] view plain copy result=talkWithDriver(); 获得了Client端的进程间调用后,就调用excuteCommand函数来处理这个请求: [cpp] view plain copy result=executeCommand(cmd); 最后,线程退出时,也会告诉Binder驱动程序,它退出了,这样Binder驱动程序就不会再在Client端的进程间调用分发给它了: [cpp] view plain copy mOut.writeInt32(BC_EXIT_LOOPER); talkWithDriver(false); 我们再来看看talkWithDriver函数的实现。 本文转自 Luoshengyang 51CTO博客,原文链接:http://blog.51cto.com/shyluo/966508,如需转载请自行联系原作者

优秀的个人博客,低调大师

TFTP服务器在Cisco设备上的应用(上传、下载IOS)

网络拓扑图 基于对安全的考虑,Cisco总是默认关闭TELNET服务,并且只有配置了远程登陆密码才能使用。同时还要配置使能密码,负责不能进入特权模式。 实验一:通过TFTP服务器从Cisco路由器上下在系统 下面是远程登陆通信服务器主要承载路由器的管理 下面是具体的配置 Router(config)# enablepassword123 配置使能密码 Router(config)#l inevty04 进入线路配置模式 Router(config-line)# password123 加密 Router(config-line)# login 登陆时生效 Router(config-line)# end *Mar100:03:16.703:%SYS-5-CONFIG_I:Configuredfromconsolebyconsol %Noconnectionsopen Router# Router# write 保存到Startup-config中。 Buildingconfiguration... [OK] Router# Router(config)# interF0/0 Router(config-if)# ipadd172.16.2.209255.255.255.0 Router(config-if)# noshut Router(config-if)# *Mar100:05:02.095:%LINK-3-UPDOWN:InterfaceEthernet0/0,changedstatetoup *Mar100:05:03.095:%LINEPROTO-5-UPDOWN:LineprotocolonInterfaceEthernet0/ 0,changedstatetoup 开启TFTP服务器,写入LOG和输入、输出目录。 将路由器的F0/0直接连到局域网交换机某一接口上。 下面是远程登陆路由器F0/0接口上。主要承载路由器数据的传输。 登陆后的结果: 下面是在登陆172.16.0.209之后的具体配置: R5# copyflashtftp 将路由器上flash中的文件复制到tftp服务器上。 Sourcefilename[c2600-ik8o3s-mz.122-11.T.bin]? c2600-ik8o3s-mz.122-11.T.bin 输入需要复制的系统名 Addressornameofremotehost[]?1 72.16.0.5 TFTP服务器对应的主机的具体地址 Destinationfilename[c2600-ik8o3s-mz.122-11.T.bin]? 回车确认 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15108540bytescopiedin174.982secs(86343bytes/sec) 复制已经完成 下面是显示结果: 下面是TFTP上复制过程的显示结果。 下面是下载下来的系统,其中config.text是一会做上传用的。 实验二:通过TFTP服务器给Cisco路由器上传配置文件 R5# copytftpflash 复制TFTP服务器输出目录里的confit.text文件到路由器的flash中。 Addressornameofremotehost[]? 172.16.0.5 TFTP服务器对应的主机地址。 Sourcefilename[]? config.text Destinationfilename[config.text]? Accessingtftp://172.16.0.5/config.text... Eraseflash:beforecopying? [confirm] j 任意输入一个字母(注意:不可直接按回车,否则,Flash里的所有文件,包括系统也被擦除了。 Loadingconfig.textfrom172.16.0.5(viaFastEthernet0/0):! [OK-20bytes] Verifyingchecksum...OK(0xE9E9) 20bytescopiedin0.221secs(90bytes/sec) R5# showflash Systemflashdirectory: FileLengthName/status 115108540c2600-ik8o3s-mz.122-11.T.bin 220config.text 可以看出文件已经复制到FLASH中了 [15108688bytesused,18445744available,33554432total] 32768KbytesofprocessorboardSystemflash(Read/Write) 可以看出上传成功了 下面是具体的配置命令! 本文转自凌激冰51CTO博客,原文链接:http://blog.51cto.com/dreamfire/99115,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

用户登录
用户注册
修改密码
忘记密码