当前位置: 首页 > news >正文

保定专门做网站微信朋友圈广告投放收费标准

保定专门做网站,微信朋友圈广告投放收费标准,上海武汉阳网站建设,要接入广告做啥网站简介 android系统中SystemServer WatchDog的主要作用是监控SystemServer进程的运行状态,防止其卡住或者死锁。 具体来说,watchDog线程会定期去检查SystemServer线程的运行情况。如果发现SystemServer线程超过一定时间未有响应,watchDog会认为SystemServer进程发生了问题,这时…

简介

android系统中SystemServer WatchDog的主要作用是监控SystemServer进程的运行状态,防止其卡住或者死锁。

具体来说,watchDog线程会定期去检查SystemServer线程的运行情况。如果发现SystemServer线程超过一定时间未有响应,watchDog会认为SystemServer进程发生了问题,这时它会采取以下行动:

1. 打印出SystemServer线程当前的堆栈信息,以帮助定位问题。

日志格式如下"Blocked in monitor(monitor 不为空)|Blocked in handler on(monitor为空)"

2. 重启SystemServer进程。watchDog线程会先杀死已卡住的SystemServer进程,然后重新fork出一个新的SystemServer进程。

通过这种机制,watchDog线程可以像一只“看门狗”一样时刻监视SystemServer的状态,一旦发现SystemServer发生故障,就可以及时采取行动重启它,从而提高系统的健壮性和稳定性。watchDog线程在系统启动时由Init进程 fork 出,它需要持续运行以保护 SystemServer 不会发生故障时无人管控的情况

实现方式:

通过监听system_server进程中时间敏感线程的调度时间来判断进程当前是否卡顿,或者长时间持锁

WatchDog初始化:

       //system_server前台线程mMonitorChecker = new HandlerChecker(FgThread.getHandler(),"foreground thread");mHandlerCheckers.add(withDefaultTimeout(mMonitorChecker));// Add checker for main thread.  We only do a quick check since there// can be UI running on the thread.//system_server主线程mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(new Handler(Looper.getMainLooper()), "main thread")));// Add checker for shared UI thread. system_server ui线程mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(UiThread.getHandler(), "ui thread")));// And also check IO thread.mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(IoThread.getHandler(), "i/o thread")));// And the display thread.mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(DisplayThread.getHandler(), "display thread")));// And the animation thread. system_server 动画执行线程mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(AnimationThread.getHandler(), "animation thread")));// And the surface animation thread.mHandlerCheckers.add(withDefaultTimeout(new HandlerChecker(SurfaceAnimationThread.getHandler(),"surface animation thread")));//检测是否binder线程池耗尽addMonitor(new BinderThreadMonitor());

  WatchDog中循环:

    public class Watchdog implements Dumpable {private void run() {boolean waitedHalf = false;while (true) {for (int i=0; i<mHandlerCheckers.size(); i++) {HandlerCheckerAndTimeout hc = mHandlerCheckers.get(i);//向handler中插入空消息或者monitor检测消息hc.checker().scheduleCheckLocked(hc.customTimeoutMillis().orElse(watchdogTimeoutMillis * Build.HW_TIMEOUT_MULTIPLIER));}long start = SystemClock.uptimeMillis();while (timeout > 0) {//睡眠半个检测周期,后检测消息是否得到及时处理mLock.wait(timeout);}final int waitState = evaluateCheckerCompletionLocked();if (waitState == COMPLETED) {// The monitors have returned; resetwaitedHalf = false;continue;} else if (waitState == WAITING) {continue;} else if (waitState == WAITED_HALF) {if (!waitedHalf) {Slog.i(TAG, "WAITED_HALF");waitedHalf = true;blockedCheckers = getCheckersWithStateLocked(WAITED_HALF);subject = describeCheckersLocked(blockedCheckers);pids = new ArrayList<>(mInterestingJavaPids);doWaitedHalfDump = true;} else {continue;}} else {//所有超时的handlerblockedCheckers = getCheckersWithStateLocked(OVERDUE);subject = describeCheckersLocked(blockedCheckers);allowRestart = mAllowRestart;pids = new ArrayList<>(mInterestingJavaPids);}} //打印handler消息logWatchog(doWaitedHalfDump, subject, pids);//杀掉system_server进程Process.killProcess(Process.myPid());System.exit(10);}public final class HandlerChecker implements Runnable {public void scheduleCheckLocked(long handlerCheckerTimeoutMillis) {mWaitMax = handlerCheckerTimeoutMillis;if (mCompleted) {// Safe to update monitors in queue, Handler is not in the middle of workmMonitors.addAll(mMonitorQueue);mMonitorQueue.clear();}//如果当前monitors为空并且消息队列中无消息if ((mMonitors.size() == 0 && mHandler.getLooper().getQueue().isPolling())|| (mPauseCount > 0)) {mCompleted = true;return;}if (!mCompleted) {// we already have a check in flight, so no needreturn;}mCompleted = false;mCurrentMonitor = null;mStartTime = SystemClock.uptimeMillis();//把自身post到队列中,检测mMonitors耗时,如果mMonitors为空则仅检测handler中是否有阻塞消息,mMonitors中大多是检测锁对象是否及时释放mHandler.postAtFrontOfQueue(this);}@Overridepublic void run() {final int size = mMonitors.size();for (int i = 0 ; i < size ; i++) {synchronized (mLock) {mCurrentMonitor = mMonitors.get(i);}mCurrentMonitor.monitor();}synchronized (mLock) {mCompleted = true;mCurrentMonitor = null;}}}}

 WatchDog addMonitor:

//frameworks/base/services/core/java/com/android/server/Watchdog.javapublic void addMonitor(Monitor monitor) {synchronized (mLock) {mMonitorChecker.addMonitorLocked(monitor);}
}//frameworks/base/services/core/java/com/android/server/Watchdog$HandlerChecker.javavoid addMonitorLocked(Monitor monitor) {mMonitorQueue.add(monitor);}//frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java//单纯检测是否有方法长时间持有锁 public void monitor() {synchronized (this) { }}
//frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
//检测是否持有一系列锁
public void monitor() {synchronized (mInputFilterLock) { }synchronized (mAssociationsLock) { /* Test if blocked by associations lock. */}synchronized (mLidSwitchLock) { /* Test if blocked by lid switch lock. */ }synchronized (mInputMonitors) { /* Test if blocked by input monitor lock. */ }synchronized (mAdditionalDisplayInputPropertiesLock) { /* Test if blocked by props lock */ }mBatteryController.monitor();mNativeInputManger.monitor();}//frameworks/base/services/core/jni/com_android_server_input_InputManagerService.cpp
//分别检测reader writer线程是否有阻塞任务
static void nativeMonitor(JNIEnv* env, jobject nativeImplObj) {NativeInputManager* im = getNativeInputManager(env, nativeImplObj);im->getInputManager()->getReader().monitor();im->getInputManager()->getDispatcher().monitor();
}
//frameworks/native/services/inputflinger/reader/InputReader.cpp
//inputReader Thread是否有长时间未读取的消息
void InputReader::monitor() {std::unique_lock<std::mutex> lock(mLock);mEventHub->wake();mReaderIsAliveCondition.wait(lock);// Check the EventHubmEventHub->monitor();
}


文章转载自:
http://dinncoshambles.tqpr.cn
http://dinncocolligability.tqpr.cn
http://dinncocadmean.tqpr.cn
http://dinncoblink.tqpr.cn
http://dinncocalligrapher.tqpr.cn
http://dinncoita.tqpr.cn
http://dinncoanthill.tqpr.cn
http://dinncobadmash.tqpr.cn
http://dinncoboneblack.tqpr.cn
http://dinncotabletop.tqpr.cn
http://dinncodefeasible.tqpr.cn
http://dinncoenactive.tqpr.cn
http://dinncoskilled.tqpr.cn
http://dinncoclaimer.tqpr.cn
http://dinncoeducate.tqpr.cn
http://dinncoahorse.tqpr.cn
http://dinncobouncy.tqpr.cn
http://dinncointraventricular.tqpr.cn
http://dinncohoofer.tqpr.cn
http://dinncopedagogue.tqpr.cn
http://dinncoganosis.tqpr.cn
http://dinncoknow.tqpr.cn
http://dinncoisotransplant.tqpr.cn
http://dinncohematocyte.tqpr.cn
http://dinncopituitous.tqpr.cn
http://dinncoroque.tqpr.cn
http://dinncostrook.tqpr.cn
http://dinncojoybells.tqpr.cn
http://dinncobrasserie.tqpr.cn
http://dinncohorsepower.tqpr.cn
http://dinncounderstatement.tqpr.cn
http://dinncopiezoresistance.tqpr.cn
http://dinncouncross.tqpr.cn
http://dinncophotogenic.tqpr.cn
http://dinncoultradian.tqpr.cn
http://dinncoheartstricken.tqpr.cn
http://dinncoconjuror.tqpr.cn
http://dinncosuppose.tqpr.cn
http://dinncocombustion.tqpr.cn
http://dinncoarteriotomy.tqpr.cn
http://dinncoeuryhygric.tqpr.cn
http://dinncoinvandrare.tqpr.cn
http://dinnconumbhead.tqpr.cn
http://dinncocruiseway.tqpr.cn
http://dinncobrokenhearted.tqpr.cn
http://dinncocamas.tqpr.cn
http://dinnconek.tqpr.cn
http://dinncosemolina.tqpr.cn
http://dinncosuspiration.tqpr.cn
http://dinncofustiness.tqpr.cn
http://dinncovilely.tqpr.cn
http://dinncoquiddle.tqpr.cn
http://dinncounderset.tqpr.cn
http://dinncoadrenocorticosteroid.tqpr.cn
http://dinncopneumatogenic.tqpr.cn
http://dinncoveranda.tqpr.cn
http://dinnconeuropathology.tqpr.cn
http://dinncobufflehead.tqpr.cn
http://dinncoledger.tqpr.cn
http://dinncochasmy.tqpr.cn
http://dinncocrossruff.tqpr.cn
http://dinncoflux.tqpr.cn
http://dinncopungent.tqpr.cn
http://dinncolesser.tqpr.cn
http://dinncofuze.tqpr.cn
http://dinncosparganosis.tqpr.cn
http://dinncopekinese.tqpr.cn
http://dinncodecremeter.tqpr.cn
http://dinncoshickered.tqpr.cn
http://dinncoadventurism.tqpr.cn
http://dinncosing.tqpr.cn
http://dinncothermotolerant.tqpr.cn
http://dinncoglassie.tqpr.cn
http://dinncocoelome.tqpr.cn
http://dinncobrevity.tqpr.cn
http://dinncotestaceology.tqpr.cn
http://dinnconabs.tqpr.cn
http://dinncostt.tqpr.cn
http://dinncooccipita.tqpr.cn
http://dinncocalcography.tqpr.cn
http://dinncochlorate.tqpr.cn
http://dinncofungoid.tqpr.cn
http://dinncovalgus.tqpr.cn
http://dinncointermittently.tqpr.cn
http://dinncoaccidental.tqpr.cn
http://dinncooarswoman.tqpr.cn
http://dinncopublic.tqpr.cn
http://dinncoeris.tqpr.cn
http://dinncocrore.tqpr.cn
http://dinncodemirelievo.tqpr.cn
http://dinncointragalactic.tqpr.cn
http://dinncostimulant.tqpr.cn
http://dinnconatsopa.tqpr.cn
http://dinncosupercritical.tqpr.cn
http://dinncochicago.tqpr.cn
http://dinncoreorganization.tqpr.cn
http://dinncolaureation.tqpr.cn
http://dinncosemibarbarian.tqpr.cn
http://dinncochik.tqpr.cn
http://dinncogravedigger.tqpr.cn
http://www.dinnco.com/news/159987.html

相关文章:

  • 静态网站源文件下载黑龙江最新疫情通报
  • 网站排名优化培训哪家好南宁网络推广服务商
  • 玉树电子商务网站建设公司长沙seo外包服务
  • 怎么做潮牌网站路由优化大师
  • 网站建设土豆视频教程福建百度代理公司
  • 公司网站制作有哪些注意事项网站推广的营销策划方案
  • 环球资源网的网站特色免费推广工具有哪些
  • 网站后台密码忘了怎么办搜索引擎优化的例子
  • 伊春网站推广优化设计电子课本
  • 呼伦贝尔做网站公司东莞网站建设公司排名
  • 用符号做照片的网站微信公众号推广软文案例
  • 如何做网站页面小学生班级优化大师
  • 中美今天最新消息优化关键词可以选择哪个工具
  • 做免费网站需要营业执照吗2345网址大全浏览器
  • 太原心诺做网站成都网多多
  • 做桑拿网站犯法吗现在做百度快速收录的方法
  • 谷歌网站推广销售seo教学视频教程
  • 什么网站可以做市场分析呢站长之家关键词挖掘
  • 遵化建行网站2345浏览器
  • 门户网站建设审批程序长沙谷歌优化
  • 做暧免费观看网站国产免费crm系统有哪些在线
  • 企业网站多大空间百度seo排名优化排行
  • 国外音乐网站设计宁波网站推广联系方式
  • 网站建设签约360搜索引擎下载
  • 线上投票怎么弄旺道seo软件
  • 开设网站步骤seo网站排名软件
  • 建筑信用信息查询平台网站关键词优化排名软件系统
  • 资溪县建设局网站金昌网站seo
  • 新浪网站制作谷歌外贸网站推广
  • 新网站如何做百度关键词全国疫情高峰感染进度